line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tanker::RequestGenerator::IRC; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
5
|
use Tanker::Request; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
434
|
use Tanker::RequestGenerator; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
7
|
1
|
|
|
1
|
|
3
|
use vars qw(@ISA $me $running); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
4
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
9
|
1
|
|
|
1
|
|
2251
|
use POE; |
|
1
|
|
|
|
|
61594
|
|
|
1
|
|
|
|
|
16
|
|
10
|
1
|
|
|
1
|
|
121032
|
use POE::Component::IRC; |
|
1
|
|
|
|
|
196279
|
|
|
1
|
|
|
|
|
519
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@ISA = qw (Tanker::RequestGenerator); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $NAME = "tanker" . $$ % 1000; |
15
|
|
|
|
|
|
|
my $NICK = $NAME; |
16
|
|
|
|
|
|
|
my $CHANNEL = "#tanker"; |
17
|
|
|
|
|
|
|
my $SERVER = "london.rhizomatic.net"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# this isn't very good and needs to be more flexible but |
21
|
|
|
|
|
|
|
# it's a start and shows that the pipeline works concurrently |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new |
24
|
|
|
|
|
|
|
{ |
25
|
1
|
|
|
1
|
0
|
3
|
my $proto = shift; |
26
|
1
|
|
33
|
|
|
5
|
my $class = ref($proto) || $proto; |
27
|
1
|
|
|
|
|
2
|
my $pipeline = shift; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
10
|
my $self = $class->SUPER::new($pipeline); |
30
|
|
|
|
|
|
|
|
31
|
1
|
50
|
|
|
|
12
|
POE::Component::IRC->new($NAME) or die "Oh noooo! $!"; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
5514
|
POE::Session->new |
34
|
|
|
|
|
|
|
( _start => \&bot_start, |
35
|
|
|
|
|
|
|
irc_376 => \&on_connect, |
36
|
|
|
|
|
|
|
irc_public => \&on_message, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$me = $self; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $self; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub bot_start |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
0
|
0
|
|
print STDERR "Attempting to connect\n"; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $kernel = $_[KERNEL]; |
54
|
0
|
|
|
|
|
|
my $heap = $_[HEAP]; |
55
|
0
|
|
|
|
|
|
my $session = $_[SESSION]; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$kernel->refcount_increment( $session->ID(), "irc bot" ); |
58
|
0
|
|
|
|
|
|
$kernel->post( $NAME => register => "all" ); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$kernel->post($NAME, 'connect', |
62
|
|
|
|
|
|
|
{ Nick => $NICK, |
63
|
|
|
|
|
|
|
Server => $SERVER, |
64
|
|
|
|
|
|
|
Port => 6667, |
65
|
|
|
|
|
|
|
Username => $NICK, |
66
|
|
|
|
|
|
|
Ircname => $NICK, } ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub on_connect |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
0
|
0
|
|
print STDERR "Joining\n"; |
72
|
0
|
|
|
|
|
|
$_[KERNEL]->post( $NAME => join => $CHANNEL ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub on_message |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
0
|
|
my ($kernel, $who, $where, $msg) = @_[KERNEL, ARG0, ARG1, ARG2]; |
78
|
0
|
|
|
|
|
|
my $nick = (split /!/, $who)[0]; |
79
|
0
|
|
|
|
|
|
my $channel = $where->[0]; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $ts = scalar(localtime); |
82
|
0
|
|
|
|
|
|
print STDERR " [$ts] <$nick:$channel> $msg\n"; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $r = { |
85
|
|
|
|
|
|
|
ts => $ts, |
86
|
|
|
|
|
|
|
nick => $nick, |
87
|
|
|
|
|
|
|
channel => $channel, |
88
|
|
|
|
|
|
|
msg => $msg, |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $req = new Tanker::Request($r); |
92
|
0
|
|
|
|
|
|
$me->{pipeline}->inject($req); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub run ($) |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
102
|
0
|
|
|
|
|
|
$poe_kernel->run(); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
__END__ |