#!/usr/bin/perl #smirc is a perl irc client written by smapdi(BubbaGnush@earthlink.net) with help from deo and sub of #ct2600 in irc.2600.net #Copyright (C) 2000 SMAPDI #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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use Term::ANSIColor; use IO::Socket; print color("red"), "WELCOME TO SMIRC 0.04!\n"; $server=""; print "Enter the server: "; chomp($server = ); $nick=""; print "Enter the nick: "; chomp($nick = ); print "Enter the channel: "; $chan=""; chomp($chan = ); print color("reset"); $EOL="\r\n"; $bah = chr(14); $mdir = "/music/music/"; $mp3pid; $os = `uname -sr`; chomp($os); $svmsg = "--->"; &connect; sub connect { $sock = IO::Socket::INET->new(PeerAddr => "$server", PeerPort => 6667, Proto => 'tcp') || die "can't connect\n"; $sock->autoflush(1); print $sock "NICK $nick$EOL"; print $sock "USER $nick foo bar :$nick$EOL"; print $sock "JOIN $chan$EOL"; &connected; } sub connected { while($sock) { die "can't fork: $!" unless defined($kidpid = fork()); if ($kidpid) { while (defined($line = <$sock>)) { say: chomp($say = ); if ($say =~ /\/quit/i){ print $sock "QUIT :Smirc, its what's for dinner$EOL"; print color("reset"); goto end; exit(0); die "toodles"; } elsif ($say =~ /\/nick/i){ ($foo, $newnick) = split(/ /, $say); print $sock "NICK $newnick$EOL"; goto say; } elsif ($say =~ /\/me/i){ ($foo, $action) = split(/ /, $say, 2); print $sock "PRIVMSG $chan :" .chr(1). "ACTION $action" .chr(1). "$EOL"; goto say; } elsif ($say =~ /\/mode/i){ ($foo, $chan, $mode, $nick) = split(/ /, $say, 4); print $sock "MODE $chan $mode $nick$EOL"; } elsif ($say =~ /\/NAMES/i){ print $sock "NAMES $chan$EOL"; goto say; } elsif ($say =~ /\/msg/i){ ($foo, $mnick, $wee) = split(/ /, $say, 3); print $sock "PRIVMSG $mnick :$wee$EOL"; goto say; } elsif ($say =~ /\/sv/i){ print $sock "PRIVMSG $chan :" .chr(2). "SMirc" .chr(2). " - 0.04 for $os - By " .chr(31). "SMAPDI" .chr(31). "$EOL"; goto say; } elsif ($say =~ /\/op/i){ ($foo, $mnick, $wee) = split(/ /, $say); print $sock "MODE $chan +o $mnick$EOL"; goto say; } elsif ($say =~ /\/deop/i){ ($foo, $mnick, $wee) = split(/ /, $say); print $sock "MODE $chan -o $mnick$EOL"; goto say; } elsif ($say =~ /\/mode/i){ ($foo, $modechan, $mode, $nick) = split(/ /, $say); print $sock "MODE $modechan $mode $nick$EOL"; } #cdplay section elsif ($say =~ /\/eject/i){ system(eject); goto say; } elsif ($say =~ /\/cd/i){ ($cd, $data) = split(/ /, $say); if ($data == stop){ system("cdplay stop"); goto say; } else{ system("cdplay play $data"); goto say; } } #mp3 section elsif ($say =~ /\/mp3/i){ ($mp3, $data) = split(/ /, $say, 2); if ($data =~ ls){ system("ls $mdir"); goto say; } elsif ($data =~ kill) { system("kill $mpid"); } else{ die "can't fork: $!" unless defined($mp3pid = fork()); if ($mp3pid){ #getpid($mpid); print "To stop this mp3, hit ctrl-c\n"; system("mpg123 $data"); goto say; } goto say; } } else { print $sock "PRIVMSG $chan :$say$EOL"; goto say; } } print color("RESET"); kill("TERM", $kidpid); die "toodles"; } else { while (defined($line = <$sock>)) { ($ident, $priv, $norc, $msg) = split(/ /, $line, 4); if ($line =~ /PING/i){ print $sock "PONG $server$EOL"; print color("red"), "--->", color("GREEN"), "PONG!\n", color("RESET"); } elsif ($line =~ /$server/i){ ($ser, $poo, $nob, $foo, $motd) = split(/ /, $line, 5); print color("red"), "--->", color("GREEN"), "$motd", color("RESET"); } elsif ($line =~ /354/i) { ($foo, $bar) = split(/=/, $line, 2); ($pewp, $names, $garbage) = split(/:/, $bar); print color("red"), "--->", color("GREEN"), "$names", color("RESET"); } elsif ($line =~ /MODE/i) { ($ident, $m, $arg, $mode, $mnick) = split(/ /, $line); ($null, $rawirc, $arg) = split(/:/, $line, 3); ($modenick, $pewp) = split (/!/, $rawirc); print color("red"), "--->", color("GREEN"), "mode $mode $mnick by $modenick\n", color("RESET"); } elsif ($line =~ /KICK $chan $nick/i){ ($ident, $kick, $kchan, $you, $why) = split(/ /, $line, 5); ($null, $rawirc, $said) = split(/:/, $line, 3); ($snick, $goo) = split(/!/, $rawirc, 2); chomp($why); print color("yellow"), "--->You have been kicked from $kchan by $snick [$why]\n", color("reset"); print $sock "JOIN $chan$EOL"; print $sock "PRIVMSG $chan :damn you $snick!$EOL"; } elsif ($line =~ /ACTION/i) { ($ident, $priv, $cchan, $col, $said) = split(/ /, $line, 5); ($null, $rawirc, $foo) = split(/:/, $line, 3); ($snick, $goo) = split(/!/, $rawirc, 20); print color("magenta"), "*$snick $said", color("reset"); } elsif ($line =~ /NICK/i) { ($ident, $foo, $newnick) = split(/ /, $line); ($null, $rawirc, $foo) = split(/:/, $line, 3); ($snick, $goo) = split(/!/, $rawirc, 2); ($arg, $nnick) = split(/:/, $newnick); print color("red"), "--->", color("green"), "$snick is now known as $nnick", color("reset"); } elsif ($line =~ /JOIN/i) { ($ident, $foo, $col) = split(/ /, $line, 3); ($null, $rawirc, $foo) = split(/:/, $line, 3); ($snick, $goo) = split(/!/, $rawirc, 2); print color("red"), "--->", color("green"), "$snick has joined $chan\n", color("reset"); } elsif ($line =~ /QUIT/i) { ($ident, $foo, $col) = split(/ /, $line, 3); print color("red"), "--->", color("green"), "$ident has left $chan\n", color("reset"); } elsif ($line =~ /VERSION/) { ($ident, $priv, $foo, $version) = split(/ /, $line, 4); ($null, $rawirc, $said) = split(/:/, $line, 3); ($snick, $goo) = split(/!/, $rawirc, 2); print $sock "NOTICE $snick SMirc-0.02$EOL"; } elsif ($line =~ /$bah/){ } elsif ($norc =~ /$nick/){ ($idnet, $priv, $msgn, $msg) = split(/ /, $line, 4); chomp($msg); ($null, $nmsg) = split(/:/, $msg, 2); ($rawirc, $foo, $bar) = split(/!/, $ident); ($null, $msgnick, $arg) = split(/:/, $rawirc); print color("cyan"), "***", color("green"), "[msg] from $msgnick ($nmsg)\n", color("RESET"); } elsif ($line =~ /$nick/){ ($ident, $priv, $cchan, $col, $said) = split(/:/, $line, 5); ($null, $rawirc, $said) = split(/:/, $line, 3); ($snick, $goo) = split(/!/, $rawirc, 20); print color("red"), "<", color("cyan"), "$snick", color("red"),">", color("green"), "$said"; } else { ($ident, $priv, $cchan, $col, $said) = split(/:/, $line, 5); ($null, $rawirc, $said) = split(/:/, $line, 3); ($snick, $goo) = split(/!/, $rawirc, 20); print color("red"), "<", color("green"), "$snick", color("red"),">", color("green"), "$said"; } } } } } print color("RESET"); end: exit(0); die "toodles";