1
0
Fork 0

puddingbrumsel! *brums*

master
neingeist 17 years ago
commit c59379777e

@ -0,0 +1,75 @@
#!/usr/bin/perl
use Net::IRC;
use Data::Dumper;
use strict;
my $irc = new Net::IRC;
my $conn = $irc->newconn(Nick => 'puddingbrumsel',
Server => 'irc.belwue.de');
$conn->{channel} = "!6Y9HIabcde";
$conn->{lastpudding} = time();
$conn->{specialwday} = 0;
# hmm, pudding!
sub pudding {
my $pudding;
if (rand(4) > 3) {
$pudding = "hmm, ",
} elsif (rand(4) > 3) {
$pudding = "ah, ",
}
my (undef, undef, undef, undef, undef, undef, $wday) = localtime(time());
if ($wday == $conn->{specialwday}) {
my @foo = ( "spinat", "wirsing", "eisbein", "sauerkraut", "tomaten", "hafer" );
$pudding .= $foo[int(rand($#foo))];
}
$pudding .= "pudding";
if (rand(4) > 3) {
$pudding .= "!";
} else {
$pudding .= ".";
}
my $brums = "*brums*";
if (rand(4) > 3) {
$brums .= " *brums*";
}
if ($wday == $conn->{specialwday}) {
$brums .= " *brums*";
}
return "$pudding $brums";
}
# What to do when the bot successfully connects.
sub on_connect {
my $conn = shift;
print "Joining $conn->{channel}...\n";
$conn->join($conn->{channel});
$conn->privmsg($conn->{channel}, pudding);
}
$conn->add_handler('376', \&on_connect);
sub on_msg {
my ($conn, $event) = @_;
if ($event->{to}[0] eq $conn->{channel}) {
my $wait = 24 * 3600 * (rand()+0.5);
my (undef, undef, undef, undef, undef, undef, $wday) = localtime(time());
if ($wday == $conn->{specialwday}) {
$wait = 6 * 3600 * (rand()+0.5);
}
if (time() > $conn->{lastpudding} + $wait) {
print "=> $conn->{channel}\n";
$conn->privmsg($conn->{channel}, pudding);
$conn->{lastpudding} = time();
}
} else {
print "=> $event->{nick}\n";
$conn->privmsg($event->{nick}, pudding);
}
}
$conn->add_handler('msg', \&on_msg);
$irc->start;