#!/usr/bin/perl
use CGI qw(param);
#####################################################
$host = param(host);
$port = param(port);
$room = param(room);
$nick = param(nick);
#####################################################
if ($host eq "") { $host = "DEFAULT SERVER"; }
if ($port eq "") { $port = "DEFAULT PORT"; }
if ($room eq "") { $room = "DEFAULT CHANNEL"; }
if ($nick eq "") { $nick = "DEFAULT BOT NICK"; }
#####################################################
$owner = "YOUR NAME";
$whoisme = "/whois name";
$whoisme =~ tr/ / /;
$pass = "PASS";
$sendp = '/usr/sbin/sendmail';
#####################################################
@lines = ();
@ai = ();
@log = ();
@clone = ();
#####################################################
$greete = "off";
$quite = "on";
$modee = "on";
$sendowner = "off";
$sendhost = "off";
$sendnote = "off";
$parte = "off";
$kicked = "on";
$logit = "off";
#####################################################
$addgreet = 0;
$addquit = 0;
$addmode = 0;
$addpart = 0;
$addkick = 0;
$addnick = 0;
$settime = `date`;
@settime = split(/ /, $settime);
#####################################################
$pingmsg = "Smart Bot v3.0";
$pingmsg =~ tr/ / /;
#####################################################
use IO::Socket;
$remote = IO::Socket::INET->new(PeerAddr => $host,
PeerPort => $port,
Proto => "tcp");
smartbot("USER $whoisme $whoisme $host :$whoisme");
smartbot("NICK", "$nick");
smartbot("PRIVMSG", "NickServ", ":IDENTIFY $pass");
smartbot("JOIN", "#$room");
smartbot("PRIVMSG", "#$room", ":Smart Bot v3.0 (#$room)");
#####################################################
$stayalive = 1;
while($stayalive == 1) {
&readIN;
#####################################################
if ($from eq $host) {
if ($msg =~ "No such nickname nor channel") {
smartbot("PRIVMSG", "$fudge", ":*** No such user found."); }
elsif ($msg =~ "That's not a server") {
smartbot("PRIVMSG", "$fudge", ":*** No such user found."); }
elsif ($msg =~ /353/) {
$h1 = $names;
$numberp = 0;
$totop = 0;
@whochan = split(/:/, $h1);
@whotota = split(/ /, $h1);
@totalopz = split(/@/, $h1);
foreach $i (@whotota) {
++$numberp;
}
$totalppl = $numberp - 10;
foreach $i (@totalopz) {
++$totop;
}
$totops = $totop -1;
smartbot("PRIVMSG", "$nmk", ":««« Start of ~who query »»»"); smartbot("PRIVMSG", "$nmk", ":Channel: #$whothru"); smartbot("PRIVMSG", "$nmk", ":Users ($totalppl)"); smartbot("PRIVMSG", "$nmk", ":OPs ($totops)"); smartbot("PRIVMSG", "$nmk", ":User Names: $whochan[1]");
smartbot("PRIVMSG", "$nmk", ":««« End of ~who query »»»"); }
elsif ($msg =~ /319/) {
$totchans = 0;
$totalope = 0;
($nename, $nemask) = split(/ /, $addy);
($nehost, $nehostm) = split(/:/, $nhost);
@newname = split(/:/, $addy);
@newchan = split(/:/, $chan);
@totalchan = split(/#/, $chan);
@tochanop = split(/@/, $chan);
foreach $i (@totalchan) {
++$totchans;
}
$totchanz = $totchans - 1;
foreach $i (@tochanop) {
++$totalope;
}
$totaloped = $totalope -1;
smartbot("PRIVMSG", "$fudge", ":««« Start of ~whois query »»»"); smartbot("PRIVMSG", "$fudge", ":Screen Name: $wthru"); smartbot("PRIVMSG", "$fudge", ":Real Name: $newname[1]"); smartbot("PRIVMSG", "$fudge", ":Mask: $nename\@$nemask"); smartbot("PRIVMSG", "$fudge", ":Host: $nehost »» $nehostm");
smartbot("PRIVMSG", "$fudge", ":Channels ($totchanz) Channels OPed ($totaloped)"); smartbot("PRIVMSG", "$fudge", ":Channels: $newchan[0]");
smartbot("PRIVMSG", "$fudge", ":««« End of ~whois query »»»"); }
}
if ($from eq $owner) {
if ($msg =~ /~die/) {
smartbot("PRIVMSG", "$from", ":$from, Your mask was logged..."); open(DEATH, ">>death.log");
print DEATH "$mask\n";
close(DEATH);
smartbot("QUIT", ":$leavemsg");
}
elsif ($msg =~ /~clone/) {
push(@clone, "$clone");
smartbot("PRIVMSG", "#$room", ":Added $clone.");
}
elsif ($msg =~ /~dclone/) {
@clone = ();
smartbot("PRIVMSG", "#$room", ":Deleted Clones.");
}
elsif ($msg =~ /~con/) {
$clnem = "on";
smartbot("PRIVMSG", "#$room", ":Clone On.");
}
elsif ($msg =~ /~coff/) {
$clnem = "off";
smartbot("PRIVMSG", "#$room", ":Clone Off.");
}
elsif ($msg =~ /~mail/) {
($mto, $msub, $mmsg) = split(/&:/, $mail);
if ($mto !~ /@/) {
smartbot("PRIVMSG", "#$room", ":No E-mail Address.");
}
if ($msub eq "") {
smartbot("PRIVMSG", "#$room", ":No Subject.");
}
if ($mmsg eq "") {
smartbot("PRIVMSG", "#$room", ":No Message.");
}
else {
open(MAIL,"|$sendp -t");
print MAIL "Sender: $from\@$host\n";
print MAIL "To: $mto\n";
print MAIL "From: Smart_Bot\@$host\n";
print MAIL "Subject: $msub\n\n";
print MAIL "$mmsg";
print MAIL "
Smart Bot v3.0 Creator"; close(MAIL); smartbot("PRIVMSG", "#$room", ":Sent E-mail."); } } elsif ($msg =~ /~raw/) { $rawct = 0;
smartbot("PRIVMSG", "#$room", ":Running...");
@rawc = eval($rawc);
foreach $i (@rawc) {
$rawct++;
smartbot("PRIVMSG", "#$room", ":($rawct) $i");
}
}
elsif ($msg =~ /~telnet/) {
$telnett = 0;
smartbot("PRIVMSG", "#$room", ":Running...");
@telnet = `$telnet`;
smartbot("PRIVMSG", "#$room", ":Resolution...");
foreach $i (@telnet) {
$telnett++;
smartbot("PRIVMSG", "#$room", ":($telnett) $i");
}
}
elsif ($msg =~ /~me/) {
chop($me);
me("$me");
}
elsif ($msg =~ /~math/) {
smartbot("PRIVMSG", "#$room", ":Calculating...");
$matha = eval($mathq);
smartbot("PRIVMSG", "#$room", ":Answer: $matha");
}
elsif ($msg =~ /~ng/) {
smartbot("PRIVMSG", "#$room", ":alt.discuss.programming.smartscript"); }
elsif ($msg =~ /~gon/) {
smartbot("PRIVMSG", "#$room", ":Auto-Greet: on");
$greete = "on";
}
elsif ($msg =~ /~goff/) {
smartbot("PRIVMSG", "#$room", ":Auto-Greet: off");
$greete = "off";
}
elsif ($msg =~ /~qon/) {
smartbot("PRIVMSG", "#$room", ":Show Quit Message: on"); $quite = "on";
}
elsif ($msg =~ /~qoff/) {
smartbot("PRIVMSG", "#$room", ":Show Quit Message: off"); $quite = "off";
}
elsif ($msg =~ /~mon/) {
smartbot("PRIVMSG", "#$room", ":Show Mode Message: on"); $modee = "on";
}
elsif ($msg =~ /~moff/) {
smartbot("PRIVMSG", "#$room", ":Show Mode Message: off"); $modee = "off";
}
elsif ($msg =~ /~son/) {
smartbot("PRIVMSG", "#$room", ":Send Owner Bot Messages: on"); $sendowner = "on";
$sendnote = "on";
}
elsif ($msg =~ /~soff/) {
smartbot("PRIVMSG", "#$room", ":Send Owner Bot Messages: off"); $sendowner = "off";
}
elsif ($msg =~ /~shon/) {
smartbot("PRIVMSG", "#$room", ":Send Owner Host Messages: on"); $sendhost = "on";
}
elsif ($msg =~ /~shoff/) {
smartbot("PRIVMSG", "#$room", ":Send Owner Host Messages: off"); $sendhost = "off";
}
elsif ($msg =~ /~pon/) {
smartbot("PRIVMSG", "#$room", ":Show Part Message: on"); $parte = "on";
}
elsif ($msg =~ /~poff/) {
smartbot("PRIVMSG", "#$room", ":Show Part Message: off"); $parte = "off";
}
elsif ($msg =~ /~kon/) {
smartbot("PRIVMSG", "#$room", ":Show Kick Message: on"); $kicked = "on";
}
elsif ($msg =~ /~koff/) {
smartbot("PRIVMSG", "#$room", ":Show Kick Message: off"); $kicked = "off";
}
elsif ($msg =~ /~logon/) {
if ($logtp =~ /array/) {
push(@log, "Log Started: $date");
$logt = 0;
$logit = "on";
smartbot("PRIVMSG", "#$room", ":Log Started...");
}
elsif ($logtp =~ /file/) {
$logt = 1;
open(LOGIT, ">>Chat_Log.log");
print LOGIT "Log Started: $date\n\n";
close(LOGIT);
$logit = "on";
smartbot("PRIVMSG", "#$room", ":Log Started...");
} else {
smartbot("PRIVMSG", "#$room", ":No log type specified. file or array."); }
}
elsif ($msg =~ /~logoff/) {
if ($logt eq 0) {
push(@log, "Log Ended: $date");
$logit = "off";
smartbot("PRIVMSG", "#$room", ":Log Stopped...");
}
elsif ($logt eq 1) {
$logit = "off";
open(LOGIT, ">>Chat_Log.log");
print LOGIT "Log Ended: $date\n\n";
close(LOGIT);
smartbot("PRIVMSG", "#$room", ":Log Stopped...");
}
}
elsif ($msg =~ /~dlog/) {
if ($dlogt =~ /array/) {
@log = ();
smartbot("PRIVMSG", "#$room", ":Log Erased...");
}
elsif ($dlogt =~ /file/) {
$delog = `rm Chat_Log.log`;
smartbot("PRIVMSG", "$owner", ":$delog");
smartbot("PRIVMSG", "#$room", ":Log Erased...");
}
else {
smartbot("PRIVMSG", "#$room", ":No log type was specified. array or file."); }
}
elsif ($msg =~ /~vlog/) {
($vlgt, $vlgn) = split(/ /, $vlog);
if ($vlog =~ /array/) {
smartbot("PRIVMSG", "#$room", ":Log...");
foreach $i (@log) {
smartbot("PRIVMSG", "#$room", ":$i");
}
}
if ($vlgt =~ /file/) {
smartbot("PRIVMSG", "#$room", ":Getting Log...");
open(VLOG,"$vlgn");
@vlog = ;
close(VLOG);
$tvlog = join(" ", @vlog);
$logl = length $tvlog;
smartbot("PRIVMSG", "#$room", ":Here is the Log ($logl bytes)..."); foreach $i (@vlog) {
smartbot("PRIVMSG", "#$room", ":$i");
}
}
else {
smartbot("PRIVMSG", "#$room", ":No log type was specified. array or file [file name]"); }
}
elsif ($msg =~ /~search/) {
$totalrs = 0;
($stype, $search, $keyword) = split(/&:/, $dsearch);
if ($stype =~ /array/) {
if ($search !~ /@/) {
smartbot("PRIVMSG", "#$room", ":No Array name was provided."); }
if ($keyword eq "") {
smartbot("PRIVMSG", "#$room", ":No Keyword(s) were provided."); }
if ($keyword ne "" && $search ne "") {
smartbot("PRIVMSG", "#$room", ":Searching...");
@search = $search;
smartbot("PRIVMSG", "#$room", ":Results...");
foreach $i ($search) {
if ($i =~ /$keyword/) {
$totalrs++;
smartbot("PRIVMSG", "#$room", ":($totalrs) $i");
}
}
}
}
elsif ($stype =~ /file/) {
if ($search !~ /./) {
smartbot("PRIVMSG", "#$room", ":No File name was provided."); }
if ($keyword eq "") {
smartbot("PRIVMSG", "#$room", ":No Keyword(s) were provided."); }
if ($keyword ne "" && $search ne "") {
smartbot("PRIVMSG", "#$room", ":Searching...");
open(SEAR, "$search");
@search = ;
close(SEAR);
chop($keyword);
chop($keyword);
smartbot("PRIVMSG", "#$room", ":Results...");
foreach $i (@search) {
if ($i =~ /$keyword/) {
$totalrs++;
smartbot("PRIVMSG", "#$room", ":($totalrs) $i");
}
}
}
}
else {
smartbot("PRIVMSG", "#$room", ":No search type was specified. array or file are the types."); }
}
elsif ($msg =~ /~setname/) {
smartbot("PRIVMSG", "IRC", ":SETNAME $newwhoisme");
smartbot("PRIVMSG", "#$room", ":Changed.");
}
elsif ($msg =~ /~ping/) {
smartbot("PRIVMSG", "#$room", ":Running...");
@theping = `/sbin/ping -c $newping`;
smartbot("PRIVMSG", "#$room", ":Results...");
foreach $i (@theping) {
smartbot("PRIVMSG", "#$room", ":$i");
}
}
elsif ($msg =~ /~finger/) {
smartbot("PRIVMSG", "#$room", ":Checking...");
@thefinger = `finger $finger`;
smartbot("PRIVMSG", "#$room", ":Results...");
foreach $i (@thefinger) {
smartbot("PRIVMSG", "#$room", ":$i");
}
}
elsif ($msg =~ /~notice/) {
smartbot("NOTICE", "#$room", ":$notmsg");
}
elsif ($msg =~ /~ident/) {
smartbot("PRIVMSG", "ChanServ", ":IDENTIFY #$room $idents"); smartbot("PRIVMSG", "#$room", ":Identified."); }
elsif ($msg =~ /~topic/) {
smartbot("TOPIC", "#$room", "$topic");
}
elsif ($msg =~ /~say/) {
smartbot("PRIVMSG", "#$room", ":$say");
}
elsif ($msg =~ /~pm/) {
@pmsg = split(/ /,$allmsg);
$tto = $pmsg[0];
$pmsg[0] = "";
smartbot("PRIVMSG", "$tto", ": @pmsg");
smartbot("PRIVMSG", "$from", ":Sent Message...");
}
elsif ($msg =~ /~ban/) {
smartbot("MODE", "#$room", "+b", "$ban!*@*");
smartbot("KICK", "#$room", "$ban");
}
elsif ($msg =~ /~unban/) {
smartbot("MODE", "#$room", "-b", "$unban!*@*");
}
if ($msg =~ /~nick/) {
smartbot("NICK", "$newnikk");
smartbot("PRIVMSG", "#$room", ":New Nick: $newnikk");
$nick = $newnikk;
}
elsif ($msg =~ /~kick/) {
smartbot("KICK", "#$room", "$knick MOOB!");
}
elsif ($msg =~ /~mode/) {
smartbot("MODE", "#$room", "$mode");
}
elsif ($msg =~ /~stealth/) {
me("- Steath Mode Activated -");
sleep $stopp;
me("- Steath Mode Deactivated -");
}
elsif ($msg =~ /~join/) {
smartbot("PRIVMSG", "#$room", ":Joining: #$join");
smartbot("JOIN", "#$join");
smartbot("PRIVMSG", "$owner", ":Joined: #$join");
}
elsif ($msg =~ /~part/) {
smartbot("PRIVMSG", "#$room", ":Leaving: #$part");
smartbot("PART", "#$part");
smartbot("PRIVMSG", "$owner", ":Left: #$part");
}
elsif ($msg =~ /~op/) {
smartbot("MODE", "#$room", "+o", "$op");
}
elsif ($msg =~ /~deop/) {
smartbot("MODE", "#$room", "-o", "$deop");
}
elsif ($msg =~ /~read/) {
smartbot("PRIVMSG", "#$room", ":Getting Messages..."); if (!@lines) {
smartbot("PRIVMSG", "#$room", ":You have no messages."); } else {
$Readm = 0;
foreach $i (@lines) {
++$Readm;
@msgforop = split(/&:/,$i);
smartbot("PRIVMSG", "$owner", ":($Readm) $msgforop[0] »» $msgforop[1]"); }
}
}
elsif ($msg =~ /~del/) {
@lines = ();
smartbot("PRIVMSG", "#$room", ":Messages Deleted..."); }
elsif ($msg =~ /~total/) {
if (!@lines) {
smartbot("PRIVMSG", "#$room", ":You have no messages."); } else {
$ReadT = 0;
foreach $i (@lines) {
++$ReadT;
}
if ($ReadT eq "1") {
$totmsg = "message";
} else {
$totmsg = "messages";
}
smartbot("PRIVMSG", "#$room", ":You have $ReadT $totmsg"); }
}
elsif ($msg =~ /~cai/) {
$cai = 0;
foreach $i (@ai) {
$cai++;
}
smartbot("PRIVMSG", "#$room", ":I have $cai A.I. phrases"); }
elsif ($msg =~ /~dai/) {
@ai = ();
smartbot("PRIVMSG", "#$room", ":All A.I. Phrases Deleted"); }
elsif ($msg =~ /~ai/) {
($at, $as) = split(/&:/, $ai);
smartbot("PRIVMSG", "$from", ":$at => $as");
push(@ai,"$ai");
}
}
if ($msg =~ /~cmds/) {
smartbot("PRIVMSG", "$from", ":Commands come in 4 forms..."); smartbot("PRIVMSG", "$from", ":~basic [Basic Bot Commands]"); smartbot("PRIVMSG", "$from", ":~opc [Only Work if Bot is OPed]"); smartbot("PRIVMSG", "$from", ":~chanc [For Switching Channel Commands on/off]");
smartbot("PRIVMSG", "$from", ":~anyc [Commands for anyone to use]"); }
elsif ($msg =~ /~basic/) {
smartbot("PRIVMSG", "$from", ":Basic Commands:"); smartbot("PRIVMSG", "$from", ":~join [channel], ~part [channel], ~say [Text], ~me [text], ~actm [Nick] [Msg], ~pm [Nick] [Msg], ~notice [Text], ~setname [/whois name], ~clone [Nick], ~dclone, ~con, ~coff, ~search [File&:Keyword(s)]"); smartbot("PRIVMSG", "$from", ":~ident [Pass], ~die [Text], ~ping [www.addy.com, .net, .org, etc.], ~finger [Name] ~stealth [#], ~ai [Phrase&:Text], ~dai, ~cai, ~math [Math Question], ~raw [Raw Perl], ~telnet [Telnet cmd], ~logon [aray or file], ~logoff, ~dlog [array or file], ~vlog [array or file (filename)], ~mail [To&:Subjec&:Message]"); } elsif ($msg =~ /~opc/) { smartbot("PRIVMSG", "$from", ":OPed Commands:"); smartbot("PRIVMSG", "$from", ":~kick [Nick], ~ban [nick], ~unban [nick], ~op [nick], ~deop [nick], ~mode [mode/nick]"); } elsif ($msg =~ /~chanc/) { smartbot("PRIVMSG", "$from", ":Channel Commands:"); smartbot("PRIVMSG", "$from", ":~read, ~del, ~total");
smartbot("PRIVMSG", "$from", ":~gon, ~goff, ~mon, ~moff, ~qon ~qoff, ~kon, ~koff, ~son, ~soff, ~shon, ~shoff, ~pon, ~poff"); } elsif ($msg =~ /~anyc/) {
smartbot("PRIVMSG", "$from", ":Commands for Anyone: ~cmds, ~date, ~memo [Message for $owner], ~mask, ~info, ~8ball [Question], ~stats, ~whois [Nick], ~who [Channel], ~version [Nick]"); } elsif ($msg =~ /~version/) { chop($version); version("$version");
$versp = $version;
}
elsif ($msg =~ /~whois/) {
$wthru = $whois;
smartbot("WHOIS", "$whois");
$fudge = $from;
}
elsif ($msg =~ /~who/) {
$whothru = $name1;
smartbot("NAMES", "#$name1");
$nmk = $from;
}
elsif ($msg =~ /~stats/) {
smartbot("PRIVMSG", "$from", ":««« Stats for #$room »»»"); smartbot("PRIVMSG", "$from", ":«« Joins ($addgreet) »»"); smartbot("PRIVMSG", "$from", ":«« Parts ($addpart) »»"); smartbot("PRIVMSG", "$from", ":«« Nick Changes ($addnick) »»"); smartbot("PRIVMSG", "$from", ":«« Modes ($addmode) »»");
smartbot("PRIVMSG", "$from", ":«« Quits ($addquit) »»"); smartbot("PRIVMSG", "$from", ":«« Kicks ($addkick) »»");
smartbot("PRIVMSG", "$from", ":««« Started \@ $settime[3] »»»"); }
elsif ($msg =~ /~memo/) {
push(@lines,"$from&:$msgfo");
smartbot("PRIVMSG","#$room",":Memo saved for $owner."); smartbot("PRIVMSG","$from",":The Memo was Saved for $owner, Thank you $from.");
smartbot("PRIVMSG","$owner",":$from just left you a Message."); }
elsif ($msg =~ /~date/) {
smartbot("PRIVMSG", "#$room", ":$date");
}
elsif ($msg =~ /~mask/) {
smartbot("PRIVMSG", "#$room", ":$from »» $mask");
}
elsif ($msg =~ /~8ball/) {
@ball = ("Yes", "No", "Maybe", "Who knows?", "Never"); if ($quez =~ /Are you gay?/) {
$answer = "No, I'm not Gay! FAG!";
}
elsif ($quez =~ /are you gay?/) {
$answer = "No, I'm not Gay! FAG!";
}
elsif ($quez =~ /Are you a homo?/) {
$answer = "No, I'm not a Homo! SniperScript is a Homo!"; }
elsif ($quez =~ /are you a homo?/) {
$answer = "No, I'm not a Homo! SniperScript is a Homo!"; }
else {
$answ = int(rand(@ball));
$answer = $ball[$answ];
}
smartbot("PRIVMSG", "#$room", ":$answer");
}
elsif ($msg =~ /~info/) {
@stat = stat($ENV{'SCRIPT_FILENAME'});
smartbot("PRIVMSG", "$from", ":Smart Bot v3.0 ($stat[7] bytes)"); smartbot("PRIVMSG", "$from", ":Created by SmartScript"); smartbot("PRIVMSG", "$from", ":Helped by Chris_311 (Thanx man)"); }
#####################################################
foreach $i (@ai) {
($ab, $ac) = split(/&:/, $i);
unless ($from =~ /$ab/) {
if ($msg =~ /$ab/ && $from ne $nick) {
smartbot("PRIVMSG", "#$room", ":$ac");
}
}
}
#####################################################
if ($to =~ /$nick/ && $from eq $host) {
@sayHO = split(/:/, $msg,2);
if ($sendhost eq "on") {
smartbot("PRIVMSG", "$owner", ":Host »» $sayHO[1]");
}
}
elsif ($to =~ /$nick/ && $from ne $owner && $from ne $nick) { @sayM = split(/:/, $msg,2);
if ($sendowner eq "on") {
smartbot("PRIVMSG", "$owner", ":$from »» $sayM[1]");
}
}
#####################################################
if ($to) {
if ($clnem eq "on") {
foreach $i (@clone) {
if ($i =~ /$from/) {
($thecln, $theclnmsg) = split(/:/, $msg,2);
smartbot("PRIVMSG", "$to", ":$theclnmsg");
}
}
}
}
#####################################################
if ($type =~ /KICK/) {
$addkick++;
@bkicked = split(/ /, $msg);
($kickmsg1, $kickmsg2) = split(/:/, $msg,2);
$kickmsg =~ tr/ / /;
if($kicked eq "on") {
smartbot("PRIVMSG", "#$room", ":*** $bkicked[3] was kicked by $from »» $kickmsg2"); }
}
elsif ($type =~ /NICK/) {
$addnick++;
@newnick = split(/:/, $msg);
smartbot("PRIVMSG", "#$room", ":*** $from is now known as $newnick[1]"); }
elsif ($type =~ /PRIVMSG/) {
@thm = split(/:/, $msg,2);
if ($logit eq "on") {
if ($logt eq 0) {
push(@log, "$from: $thm[1]");
}
elsif ($logt eq 1) {
open(LOGIT, ">>Chat_Log.log");
print LOGIT "$from: $thm[1]\n";
close(LOGIT);
}
}
}
elsif ($type =~ /PART/) {
$addpart++;
($named, $masked) = split(/ /, $from);
if($parte eq "on") {
smartbot("PRIVMSG", "#$room", ":*** $named has parted #$room"); }
}
elsif ($type =~ /JOIN/) {
$addgreet++;
if ($from eq $owner) {
$Tmsgs = 0;
foreach $i (@lines) { ++$Tmsgs; }
if ($Tmsgs eq "1") { $showmsg = "message"; }
else { $showmsg = "messages"; }
smartbot("PRIVMSG", "$owner", ":You have $Tmsgs $showmsg, $owner"); }
elsif ($from ne $owner) {
if($greete eq "on") {
smartbot("PRIVMSG", "#$room", ":*** $from has joined #$room"); }
}
}
elsif ($type =~ /QUIT/) {
$addquit++;
@quit = split(/:/, $from);
@qmsg = split(/:/, $msg);
if($quite eq "on") {
smartbot("PRIVMSG", "#$room", ":*** $quit[0] has quit IRC »» $qmsg[1]: $qmsg[2]"); }
}
elsif ($type =~ /MODE/) {
$addmode++;
@mode = split(/ /, $msg);
if($modee eq "on") {
smartbot("PRIVMSG", "#$room", ":*** Mode: $from »» $mode[3] $mode[4]"); }
}
elsif ($type =~ /NOTICE/) {
($noticea, $noticeb) = split(/:/, $msg,2);
if ($noticeb =~ /^\001VERSION/) {
($versa, $versb) = split(/VERSION/, $msg);
smartbot("PRIVMSG", "#$room", ":[VERSION Reply $from] »» $versb"); } else {
if ($sendnote eq "on") {
smartbot("PRIVMSG", "#$room", ":*** Notice: $from »» $noticeb"); }
}
}
#####################################################
sub readIN {
recv($remote, $smartscript, 10000, 0);
if(substr($smartscript, 0, index($smartscript,":")) =~ /^PING/) { $srv = substr($smartscript, index($smartscript, ":")+1, length($smartscript));
smartbot("PONG", "$srv");
me("$pingmsg");
}
#####################################################
@smartscript = split(/:/, $smartscript);
@info = split(/ /, $smartscript[1]);
@usermask = split(/!/, $info[0]);
@shit = split(/PING/, $smartscript[1]);
$from = $usermask[0];
$mask = $usermask[1];
$ping = $shit[0];
$png = $shit[1];
$type = $info[1];
$to = $info[2];
$yo = length $whois;
$fr = length $nick;
$fr1 = length $name1;
$msg = substr($smartscript, index($smartscript, ":")+1); $addy = substr($smartscript, index($smartscript, "311")+$fr+$yo+3+2); $chan = substr($smartscript, index($smartscript, "319")+$fr+$yo+5); $nhost = substr($smartscript, index($smartscript, "312")+$fr+$yo+4); $stime = substr($smartscript, index($smartscript, "317")+$fr+$yo+4); $whois = substr($smartscript, index($smartscript, "~whois")+7); $names = substr($smartscript, index($smartscript, "= ")+1); $name1 = substr($smartscript, index($smartscript, "~who")+5); $ai = substr($smartscript, index($smartscript, "~ai")+4);
$leavemsg = substr($smartscript, index($smartscript, "~die")+5); $newwhoisme = substr($smartscript, index($smartscript, "~setname")+9); $newping = substr($smartscript, index($smartscript, "~ping")+6); $notmsg = substr($smartscript, index($smartscript, "~notice")+8); $idents = substr($smartscript, index($smartscript, "~ident")+7); $topic = substr($smartscript, index($smartscript, "~topic")+7); $say = substr($smartscript, index($smartscript, "~say")+5); $allmsg = substr($smartscript, index($smartscript, "~pm")+4); $ban = substr($smartscript, index($smartscript, "~ban")+5);
$unban = substr($smartscript, index($smartscript, "~unban")+7); $newnikk = substr($smartscript, index($smartscript, "~nick")+6); $knick = substr($smartscript, index($smartscript, "~kick")+6); $mode = substr($smartscript, index($smartscript, "~mode")+6); $stopp = substr($smartscript, index($smartscript, "~stealth")+9); $join = substr($smartscript, index($smartscript, "~join")+6); $part = substr($smartscript, index($smartscript, "~part")+6); $op = substr($smartscript, index($smartscript, "~op")+4); $deop = substr($smartscript, index($smartscript, "~deop")+6); $msgfo = substr($smartscript, index($smartscript, "~memo")+6); $mathq = substr($smartscript, index($smartscript, "~math")+6); $rawc = substr($smartscript, index($smartscript, "~raw")+5); $telnet = substr($smartscript, index($smartscript, "~telnet")+8); $finger = substr($smartscript, index($smartscript, "~finger")+8);
$version = substr($smartscript, index($smartscript, "~version")+9); $vlog = substr($smartscript, index($smartscript, "~vlog")+6); $dlogt = substr($smartscript, index($smartscript, "~dlog")+6); $logtp = substr($smartscript, index($smartscript, "~logon")+7); $mail = substr($smartscript, index($smartscript, "~mail")+6); $me = substr($smartscript, index($smartscript, "~me")+4); $quez = substr($smartscript, index($smartscript, "~8ball")+7); $clone = substr($smartscript, index($smartscript, "~clone")+7);
$dsearch = substr($smartscript, index($smartscript, "~search")+8); $date = `date`;
@date = split(/ /, $date);
}
}
#####################################################
sub me {
$action = $_[0];
chop($action);
smartbot("PRIVMSG", "#$room", ":\001ACTION", "$action\001"); }
#####################################################
sub version {
$version = $_[0];
chop($version);
smartbot("PRIVMSG", "$version", ":\001VERSION\001");
}
#####################################################
sub smartbot {
$line = join(" ", @_);
send($remote, "$line\015\012", 0);
}
1;