<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">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 &lt;wjm@feenix.metronet.com&gt;); Mon, 21 Jun 1993 16:29:41 -0500
Return-Path: &lt;noord@ucs.orst.edu&gt;
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: &lt;9306212129.AA27771@ucs.orst.edu&gt;
Subject: Re: A C bot.
To: wjm@feenix.metronet.com (Bill Middleton)
Date: Mon, 21 Jun 93 14:29:38 PDT
In-Reply-To: &lt;199306212128.AA19088@feenix.metronet.com&gt;; 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(&lt;&gt;) {
	warn("$_");
	if (/End of \/MOTD command\./) {
		last;
	}
	if (/Henson/) {
		exit(-1);
	}
}
warn("Motd finished.\n");
print( "/join #test\n" );
warn("Join issued.\n");
while(&lt;&gt;) {
	if ( /has joined/ ) {
		last;
	}
}
warn("Join complete. Now monitoring traffic...");
$regs="false";
$master="";
$pubs="true";
$noop="false";
while(&lt;&gt;) {
	chop;
	if ( /&lt;(.+)&gt; (.*)/ ) {
		$nick=$1;
		$text=$2;
		$type="public";
		&amp;pubhandl($nick,$text);
	}
	if ( /\*(.+)\* (.*)/ ) {
		$nick=$1;
		$text=$2;
		$type="private";
		&amp;privhandl($nick,$text);
	}
	if ( /\*\*\* (.+) (.+) has joined channel (.+)/ ) {
		$nick=$1;
		$login=$2;
		$channel=$3;
		&amp;joinhandl($nick,$login,$channel);
	}
	if ( /\*\*\* Mode change "(.+) (.+)" on channel (.+) by (.+)/ ) {
		$typ=$1;
		$nick=$2;
		$channel=$3;
		&amp;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");
			&amp;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") &amp;&amp; ($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=&amp;rst(19,"adjects");
	$n=&amp;rst(19,"nouns");
	$v=&amp;rst(19,"verbs");
	print("/notice $nick $a $n $v\n");
	$a=&amp;rst(19,"adjects");
	$n=&amp;rst(19,"nouns");
	$v=&amp;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=&lt;fhandl&gt;;
		chop $stng;
	}
	close(fhandl);
	return $stng;
}
---
David Noor
noord@ucs.orst.edu

</pre></body></html>