Skip to content

Instantly share code, notes, and snippets.

@iamcal
Created October 31, 2012 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamcal/3983984 to your computer and use it in GitHub Desktop.
Save iamcal/3983984 to your computer and use it in GitHub Desktop.
Minimal perl oldbot using POE
#!/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