1POE::Component::IRC::PlUusgeirn:C:oCnotnrniebcuttoerdP(O3PE)e:r:lCoDmopcounmeenntt:a:tIiRoCn::Plugin::Connector(3)
2
3
4
6 use POE qw(Component::IRC Component::IRC::Plugin::Connector);
7
8 my ($irc) = POE::Component::IRC->spawn();
9
10 POE::Session->create(
11 package_states => [
12 'main' => [ qw(_start lag_o_meter) ],
13 ],
14 );
15
16 $poe_kernel->run();
17 exit 0;
18
19 sub _start {
20 my ($kernel,$heap) = @_[KERNEL,HEAP];
21 $irc->yield( register => 'all' );
22
23 $heap->{connector} = POE::Component::IRC::Plugin::Connector->new();
24
25 $irc->plugin_add( 'Connector' => $heap->{connector} );
26
27 $irc->yield ( connect => { Nick => 'testbot', Server => 'someserver.com' } );
28
29 $kernel->delay( 'lag_o_meter' => 60 );
30 undef;
31 }
32
33 sub lag_o_meter {
34 my ($kernel,$heap) = @_[KERNEL,HEAP];
35 print STDOUT "Time: " . time() . " Lag: " . $heap->{connector}->lag() . "\n";
36 $kernel->delay( 'lag_o_meter' => 60 );
37 undef;
38 }
39
41 POE::Component::IRC::Plugin::Connector is a POE::Component::IRC plugin
42 that deals with making sure that your IRC bot stays connected to the
43 IRC network of your choice. It implements the general algorithm as
44 demonstrated at <http://poe.perl.org/?POE_Cookbook/IRC_Bot_Reconnect‐
45 ing>.
46
48 new Takes one argument, 'delay', which the frequency that the plugin
49 will ping it's server. Returns a plugin object suitable for use in
50 POE::Component::IRC's 'plugin_add'.
51
52 $irc->plugin_add( 'Connector' => POE::Component::IRC::Plugin::Con‐
53 nector->new( delay => 120 ) );
54
55 lag Returns the current 'lag' in seconds between sending PINGs to the
56 IRC server and getting PONG responses. Probably not likely to be
57 wholely accurate.
58
60 Chris "BinGOs" Williams <chris@bingosnet.co.uk>
61
63 POE::Component::IRC POE::Component::IRC::Plugin
64
65
66
67perl v5.8.8 2005P-O1E0:-:2C5omponent::IRC::Plugin::Connector(3)