-
Notifications
You must be signed in to change notification settings - Fork 0
/
irc.pl
58 lines (47 loc) · 1.31 KB
/
irc.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl
# This is a simple IRC bot that just rot13 encrypts public messages.
# It responds to "rot13 <text to encrypt>".
use warnings;
use strict;
use POE;
use POE::Component::IRC;
# Create the component that will represent an IRC network.
my $irc1 = POE::Component::IRC->spawn();
my $irc2 = POE::Component::IRC->spawn();
require 'hooks.pl';
# Create the bot session. The new() call specifies the events the bot
# knows about and the functions that will handle those events.
POE::Session->create(
inline_states => {
_start => \&bot_start,
register_events => sub { goto &{'Repo::Hooks::register'} },
},
heap => {
IRC => $irc1,
SERVER => 'irc.uwcs.co.uk',
CHANNELS => '#compsoc,#goatse,#anime',
},
);
POE::Session->create(
inline_states => {
_start => \&bot_start,
register_events => sub { goto &{'Repo::Hooks::register'} },
},
heap => {
IRC => $irc2,
SERVER => 'irc.rizon.net',
CHANNELS => '#clone-army',
},
);
# The bot session has started. Register this bot with the "magnet"
# IRC component. Select a nickname. Connect to a server.
sub bot_start {
my $kernel = $_[KERNEL];
my $heap = $_[HEAP];
my $session = $_[SESSION];
$heap->{IRC}->yield( register => "all" );
$kernel->post($session, 'register_events', 1);
}
# Run the bot until it is done.
$poe_kernel->run();
exit 0;