Skip to content
Browse files

make XOmBot tell jokes!

(ugly implementation)
  • Loading branch information...
1 parent 554b2df commit d9ced1e7e1b8a87213939743b6aeb5dddbce44dd @jackiekircher jackiekircher committed Jan 24, 2012
Showing with 34 additions and 1 deletion.
  1. +34 −1 XOmBot.pl
View
35 XOmBot.pl
@@ -20,6 +20,7 @@ package Bot;
use URI::Title qw( title );
use URI::Find::Simple qw( list_uris );
use LWP 5.64;
+use HTTP::Cookies;
my($businessChannel) = '#xomb';
my($pleasureChannel) = '##l2l';
@@ -31,10 +32,14 @@ package Bot;
my $good = 0;
my $bad = 0;
+# store jokes so we can get answers!
+my $joke = "";
+my $answer = "";
+
my ($bot) = Bot->new(
server => "irc.freenode.net",
port => "8001",
- channels => [ "#XOmBot" ], #[ $businessChannel, $pleasureChannel , "##IwantAkitty", "#rstatus"],
+ channels => [ $businessChannel, $pleasureChannel , "##IwantAkitty", "#rstatus"],
nick => $mynick,
charset => 'utf-8',
);
@@ -129,6 +134,34 @@ sub said {
}
}
+ # jokes!
+ if($body =~ m/^\!joke/){
+ my $joke_domain = "http://www.abdn.ac.uk/jokingcomputer/webversion/";
+ my %joke_actions = ( start => "startFUN.php",
+ new => "getjokeFUN.php?class=any&subject=any",
+ joke => "fulldisplay.php" );
+
+ # setup cookies for these requests to use the joking computer
+ my $joke_cookie_jar = HTTP::Cookies->new;
+ $browser->cookie_jar($joke_cookie_jar);
+
+ my $response = $browser->get("$joke_domain$joke_actions{start}");
+
+ $browser->get("$joke_domain$joke_actions{new}");
+ $response = $browser->get("$joke_domain$joke_actions{joke}");
+
+ $response->content =~ m/jokermediumtext">(.*?)<br><br>(.*?)<\/div/;
+ $joke = $1;
+ $answer = $2;
+ chop($answer); #we want to make our jokes more dramatic, see !answer
+
+ $bot->say(channel => $channel, body => $joke);
+ }
+
+ if($body =~ m/^\!answer/){
+ $bot->say(channel => $channel, body => "$answer! Oh ho ho ho... brains.");
+ }
+
# --- miscellaneous behaviors ---
# annoy duck

0 comments on commit d9ced1e

Please sign in to comment.
Something went wrong with that request. Please try again.