Created
October 31, 2012 00:10
-
-
Save iamcal/3983984 to your computer and use it in GitHub Desktop.
Minimal perl oldbot using POE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use POE; | |
use POE::Component::IRC::Common; | |
use POE::Component::IRC::State; | |
use POE::Component::IRC::Plugin::AutoJoin; | |
$| = 1; | |
our $irc; | |
POE::Session->create( | |
package_states => [ | |
main => [ qw( | |
_start | |
irc_public | |
) ] | |
] | |
); | |
$poe_kernel->run(); | |
sub _start { | |
$irc = POE::Component::IRC::State->spawn( | |
Nick => 'oldbot', | |
Server => 'localhost', | |
Raw => 1, | |
Password=> 'xxxx', | |
); | |
$irc->plugin_add('AutoJoin', POE::Component::IRC::Plugin::AutoJoin->new( | |
Channels => qw( | |
#random | |
) | |
)); | |
$irc->yield(register => qw( | |
public | |
)); | |
$irc->yield('connect'); | |
} | |
sub irc_public { | |
my $chan = $_[ARG1]->[0]; | |
my $text = $_[ARG2]; | |
if ($text =~ m/https?:\/\//){ | |
my $x = 'o' x int(rand(8)); | |
$irc->yield(privmsg => $chan, "O".$x."ld"); | |
} | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment