From noord@ucs.orst.edu Mon Jun 21 07:29:38 1993 Received: from UCS.ORST.EDU by feenix.metronet.com with SMTP id AA19111 (5.65c/feenix for ); Mon, 21 Jun 1993 16:29:41 -0500 Return-Path: Received: by ucs.orst.edu (5.57/fma-120691); id AA27771; Mon, 21 Jun 93 14:29:38 -0700 From: noord@ucs.orst.edu (its MR. DAVO to you...) Message-Id: <9306212129.AA27771@ucs.orst.edu> Subject: Re: A C bot. To: wjm@feenix.metronet.com (Bill Middleton) Date: Mon, 21 Jun 93 14:29:38 PDT In-Reply-To: <199306212128.AA19088@feenix.metronet.com>; from "Bill Middleton" at Jun 21, 93 4:28 pm X-Mailer: ELM [version 2.3 PL11] Status: OR Okeydokey, here it is. Any questions, just ask :) --- $| = 1; warn("Dbot2---nicknamed scary"); while(<>) { warn("$_"); if (/End of \/MOTD command\./) { last; } if (/Henson/) { exit(-1); } } warn("Motd finished.\n"); print( "/join #test\n" ); warn("Join issued.\n"); while(<>) { if ( /has joined/ ) { last; } } warn("Join complete. Now monitoring traffic..."); $regs="false"; $master=""; $pubs="true"; $noop="false"; while(<>) { chop; if ( /<(.+)> (.*)/ ) { $nick=$1; $text=$2; $type="public"; &pubhandl($nick,$text); } if ( /\*(.+)\* (.*)/ ) { $nick=$1; $text=$2; $type="private"; &privhandl($nick,$text); } if ( /\*\*\* (.+) (.+) has joined channel (.+)/ ) { $nick=$1; $login=$2; $channel=$3; &joinhandl($nick,$login,$channel); } if ( /\*\*\* Mode change "(.+) (.+)" on channel (.+) by (.+)/ ) { $typ=$1; $nick=$2; $channel=$3; &modehandl($typ,$nick,$channel); } } sub privhandl { local($nick,$text)=@_; if ($nick eq $master) { if ($regs eq "true") { if ($text =~ /join (.+)/ ) { print("/join $1\n"); } if ($text =~ /gone/ ) { print("/quit\n"); } if ($text =~ /akick (.+) (.+)/) { $anik=$1; $akik=$2; print("/notice $master Autokick on $anik!$akik...\n"); } if ($text =~ /pubon/) { $pubs="true"; print("/notice $master Public messages on.\n"); } if ($text =~ /ops/) { $noop="false"; print("/notice $master Ops Allowed.\n"); } if ($text =~ /noop/) { $noop="true"; print("/notice $master No ops allowed.\n"); } if($text =~ /leave (.+)/) { print("/leave $1\n"); } if ($text =~ /dereg/) { print("/notice $master De registering...\n"); $master=""; $regs="false"; } } } else { if ($text =~ /pass (.+)/) { if ($1 eq "k7uyx") { print("/notice $master Access gone:$nick\n"); $master=$nick; $regs="true"; print("/notice $nick You have full access.\n"); } else { print("/notice $master Access try:$nick\n"); print("/notice $nick Access denied.\n"); } } if ($text =~ /nopubs/) { $pubs="false"; print("/notice $nick Now not talking to channel.\n"); print("/notice $master Nopubs turned on by $nick.\n"); } if ($text =~ /help/) { print("/notice $nick --- Welcome to DbotII (Dbot2).\n"); print("/notice $nick --- There is no current help facility.\n"); } if ($text =~ /poem (.+)/ ) { print("/notice $nick Sending poem to $1...\n"); print("/notice $1 $nick sends you the following poem:\n"); &poem($1); } } } sub joinhandl { local($nick,$login,$channel)=@_; if ($nick eq "davo" ) { if ($login eq "(noord@UCS.ORST.EDU)" ) { print("/mode $channel +o $nick\n"); } else { print("/notice $channel The person nicknamed ``davo'' who is\n"); print("/notice $channel on this channel is not the real davo\n"); print("/notice $channel Please beware that any actions the davo\n"); print("/notice $channel on this channel takes, the real davo\n"); print("/notice $channel is not responsible for.\n"); } } if ($login eq "(sukhiac@UCS.ORST.EDU)") { print("/mode $channel +o $nick\n"); } if (($login eq $akik) || ($nick eq $anik)) { print("/kick $channel $nick\n"); } } sub modehandl { local($typ,$nick,$channel)=@_; if (($typ eq "+o") && ($noop eq "true")) { printf("/mode $channel -o $nick\n"); } } sub pubhandl { local($nick,$text)=@_; if ($pubs eq "true") { if ($text =~ /scary/) { if ($text =~ /hello/) { print("Hi there, $nick!\n"); } if (($text =~ /master/) || ($text =~ /owns/) || ($text =~/owner/)) { print("Davo owns me!\n"); } if (($text =~ /shut up/) || ($text =~ /die/)) { print("My public responses my be stopped by typing /msg scary nopubs\n"); } if (($text =~ /who/) || ($text =~ /what/)) { print("/notice $channel This is Dbot II, currently nicknamed scary.\n"); print("/notice $channel I am owned by David Noor, noord@ucs.orst.edu,\n"); print("/notice $channel IRC nickname ``davo''.\n"); } } } } sub poem { local($nick)=@_; $a=&rst(19,"adjects"); $n=&rst(19,"nouns"); $v=&rst(19,"verbs"); print("/notice $nick $a $n $v\n"); $a=&rst(19,"adjects"); $n=&rst(19,"nouns"); $v=&rst(19,"verbs"); print("/notice $nick as $a $n $v.\n"); } sub rst { local($times,$fname)=@_; open(fhandl,$fname); $tot=int(rand($times))+1; $ctr=1; while($ctr!=$tot) { $ctr++; $stng=; chop $stng; } close(fhandl); return $stng; } --- David Noor noord@ucs.orst.edu