From c59379777e80b9d2cfe3cb05f77d0f9ddec806db Mon Sep 17 00:00:00 2001 From: neingeist Date: Sat, 23 Feb 2008 13:53:44 +0000 Subject: [PATCH] puddingbrumsel! *brums* --- puddingbrumsel | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 puddingbrumsel diff --git a/puddingbrumsel b/puddingbrumsel new file mode 100644 index 0000000..13e89c4 --- /dev/null +++ b/puddingbrumsel @@ -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;