All pastes #242844 Raw Edit

Someone

public text v1 · immutable
·published 2006-11-07 19:49 UTC
rendered paste body
#!/usr/bin/perl

use Net::IRC;
use AI::MegaHAL;
use Data::Dumper;

my $hal = new AI::MegaHAL('Path' => './', 'Banner' => 0, 'Prompt' => 0, 'Wrap' => 0, 'AutoSave' => 1);

$irc = new Net::IRC;
$conn = $irc->newconn(Nick => 'hal', Username => 'hal', Server => 'noir.ca.us.trueirc.net', Port => 6667, Ircname => 'MegaHAL');

$conn->add_handler('public', \&on_public);
$conn->add_handler('376', \&on_connect);

sub on_connect {
	my $self = shift;
	print "Connected.\n Joining #hal.n\";
	$self->join("#hal");
	my $greet = $hal->initial_greeting();
	if($greet =~ /^([a-zA-Z]{1})(.*)$/ig) { $greet = uc($1).lc($2); } # MegaHAL uc's the initial_greeting for some reason.
	$self->privmsg("#hal", $greet);
}

sub on_public {
	my ($conn, $event) = @_;
	my $text = $event->{args}[0];
	$conn->privmsg($event->{to}[0], $hal->do_reply($text));
}

$irc->start;