diff options
| -rw-r--r-- | bot.pl | 26 |
1 files changed, 7 insertions, 19 deletions
| @@ -1,22 +1,4 @@ | |||
| 1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl |
| 2 | # | ||
| 3 | # ircbot.pl written by detour@metalshell.com | ||
| 4 | # | ||
| 5 | # This irc bot will handle and print the motd, users on a channel | ||
| 6 | # joins, parts, quits, nick changes, and public msgs's. | ||
| 7 | # | ||
| 8 | # You can bind a sub to any numeric reply by using irc_<num>. | ||
| 9 | # For example 376 is the RPL_ENDOFMOTD, so to catch this response | ||
| 10 | # you add irc_376 => \&your_sub to your session. | ||
| 11 | # | ||
| 12 | # This requires that you have POE and POE::Component::IRC | ||
| 13 | # installed. A simple way to do this is using the cpan module. | ||
| 14 | # perl -MCPAN -eshell | ||
| 15 | # cpan> install POE | ||
| 16 | # cpan> install POE::Component::IRC | ||
| 17 | # | ||
| 18 | # http://www.metalshell.com | ||
| 19 | |||
| 20 | 2 | ||
| 21 | use strict; | 3 | use strict; |
| 22 | 4 | ||
| @@ -33,7 +15,9 @@ POE::Session->new ( _start => \&irc_start, | |||
| 33 | irc_376 => \&irc_connect, #end of motd | 15 | irc_376 => \&irc_connect, #end of motd |
| 34 | irc_372 => \&irc_motd, | 16 | irc_372 => \&irc_motd, |
| 35 | irc_353 => \&irc_names, | 17 | irc_353 => \&irc_names, |
| 36 | irc_public => \&irc_pub_msg, ); | 18 | irc_public => \&irc_pub_msg, |
| 19 | irc_msg => \&irc_priv_msg, | ||
| 20 | ); | ||
| 37 | 21 | ||
| 38 | sub irc_start { | 22 | sub irc_start { |
| 39 | # KERNEL, HEAP, and SESSION are constants exported by POE | 23 | # KERNEL, HEAP, and SESSION are constants exported by POE |
| @@ -115,5 +99,9 @@ sub irc_pub_msg{ | |||
| 115 | print "$channel: <$nick> $msg\n"; | 99 | print "$channel: <$nick> $msg\n"; |
| 116 | } | 100 | } |
| 117 | 101 | ||
| 102 | sub irc_priv_msg{ | ||
| 103 | print "Got a PM\n"; | ||
| 104 | } | ||
| 105 | |||
| 118 | #start everything | 106 | #start everything |
| 119 | $poe_kernel->run(); | 107 | $poe_kernel->run(); |
