cat motd.pl #!/usr/bin/perl # motdbot for unrealircd by linkz (llinkz@gmail.com) # Inspired from O'Reilly irc hacks #32. # Visit http://hacks.oreilly.com/pub/h/1964 for more details. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. use strict; use IO::Socket; # variables my $motdfile = "/home/ircd/Unreal3.2.4-geeknode/ircd.motd"; my $minusers = 15; my $server = "lcf.geeknode.org"; my $adminname = "bragon"; my $location = "caen, normandie, france"; my $date = `date`; my $uptime = `uptime`; my $kernel = `uname -a`; my $logo = `linux_logo -L 3 -a -u | grep -v Version`; chomp($date);chomp($uptime);chomp($kernel);chomp($logo); # code my $ident = "-----------"; my $realname = "motdbot"; my @letters = ('A' .. 'Z', 'a' .. 'z', '0' .. '9'); my $nick = "motdbot-".$letters[rand@letters]; my $sock = new IO::Socket::INET(PeerAddr => $server,PeerPort => 6667,Proto => 'tcp') or die "Can't connect\n"; print $sock "NICK $nick\r\n"; print $sock "USER $ident 8 * :$realname\r\n"; while (my $input = <$sock>) { if ($input =~ /004/) { last; } elsif ($input =~ /433/) { die "Nickname is already in use."; } } print $sock "LIST\r\n"; open(FILE,">$motdfile"); print FILE "\n Bonjour et bienvenue sur \n\n\n"; print FILE " ..|'''.| '|| '|. '|' '|| .|' ' .... .... || .. |'| | ... .. || .... || .... .|...|| .|...|| || .' | '|. | .| '|. .' '|| .|...|| '|. || || || ||'|. | ||| || || |. || || ''|...'| '|...' '|...' .||. ||. .|. '| '|..|' '|..'||. '|...'\n\n\n"; print FILE " Le t'chat des plus geeks - pour les geeks (tm)\n\n"; print FILE " ~~~~~~\n\n"; print FILE " INFO SERVEUR:\n"; print FILE " serveur: $server\n"; print FILE " root: $adminname\n"; print FILE " localisation: $location\n"; print FILE " running: je cache la version de mon kernel \n"; print FILE " uptime et load :\n $uptime\n"; print FILE " ~~~~~~\n\n"; print FILE " Le but de ce réseau est de réunir des personnes ayant un goût particulier\n"; print FILE " (voire une passion) pour l'informatique, et notamment pour les OS de type\n"; print FILE " Unix ou GNU/Linux.\n"; print FILE " En favorisant l'échange de connaissances, nous espérons contribuer à\n"; print FILE " l'épanouissement intellectuel de chacun.\n\n"; print FILE " ~~~~~~\n\n"; print FILE " Liste des plus gros canaux actuellement sur GeekNode:\n\n"; while (my $input = <$sock>) { chomp $input; if ($input =~ /^:$server\s322\s.*?\s(\#.*?)\s(\d*?)\s/) { if ($2 >= $minusers) { print FILE " $1 ($2)\n"; } } elsif ($input =~ /^:$server\s323\s(.*)/) { print FILE " ~~~~~~\n\n"; print FILE " Pour plus d'informations, rendez-vous sur http://www.geeknode.org\n\n"; print FILE " N'oubliez pas de lire les règles d'usage de l'irc en tapant /rules\n\n"; print FILE " lcf tourne sous :\n\n\n $logo \n\n"; close(FILE); exec('/home/ircd/Unreal3.2.4-geeknode/unreal rehash'); # modifiez cette ligne die; } }