1POE::Component::IRC::PlUusgeirn:C:oCnotnrsiobluet(e3d)PPeOrEl::DCoocmupmoennetnatt:i:oInRC::Plugin::Console(3)
2
3
4
6 POE::Component::IRC::Plugin::Console - A PoCo-IRC plugin that provides
7 a lightweight debugging and control console for your bot
8
10 use POE qw(Component::IRC Component::IRC::Plugin::Console);
11
12 my $nickname = 'Flibble' . $$;
13 my $ircname = 'Flibble the Sailor Bot';
14 my $ircserver = 'irc.blahblahblah.irc';
15 my $port = 6667;
16 my $bindport = 6969;
17
18 my @channels = ( '#Blah', '#Foo', '#Bar' );
19
20 my $irc = POE::Component::IRC->spawn(
21 nick => $nickname,
22 server => $ircserver,
23 port => $port,
24 ircname => $ircname,
25 ) or die "Oh noooo! $!";
26
27 POE::Session->create(
28 package_states => [
29 main => [ qw(_start irc_001 irc_console_service irc_console_connect
30 irc_console_authed irc_console_close irc_console_rw_fail) ],
31 ],
32 );
33
34 $poe_kernel->run();
35
36 sub _start {
37 $irc->plugin_add( 'Console' => POE::Component::IRC::Plugin::Console->new(
38 bindport => $bindport,
39 password => 'opensesame'
40 );
41 $irc->yield( register => 'all' );
42 $irc->yield( connect => { } );
43 return;
44 }
45
46 sub irc_001 {
47 $irc->yield( join => $_ ) for @channels;
48 return;
49 }
50
51 sub irc_console_service {
52 my $getsockname = $_[ARG0];
53 return;
54 }
55
56 sub irc_console_connect {
57 my ($peeradr, $peerport, $wheel_id) = @_[ARG0 .. ARG2];
58 return;
59 }
60
61 sub irc_console_authed {
62 my $wheel_id = $_[ARG0];
63 return;
64 }
65
66 sub irc_console_close {
67 my $wheel_id = $_[ARG0];
68 return;
69 }
70
71 sub irc_console_rw_fail {
72 my ($peeradr, $peerport) = @_[ARG0, ARG1];
73 return;
74 }
75
77 POE::Component::IRC::Plugin::Console is a POE::Component::IRC plugin
78 that provides an interactive console running over the loopback network.
79 One connects to the listening socket using a telnet client (or
80 equivalent), authenticate using the applicable password. Once authed
81 one will receive all events that are processed through the component.
82 One may also issue all the documented component commands.
83
85 "new"
86 Takes two arguments:
87
88 'password', the password to set for *all* console connections;
89
90 'bindport', specify a particular port to bind to, defaults to 0, ie.
91 randomly allocated;
92
93 Returns a plugin object suitable for feeding to POE::Component::IRC's
94 "plugin_add" method.
95
96 "getsockname"
97 Gives access to the underlying listener's "getsockname" method. See
98 POE::Wheel::SocketFactory for details.
99
101 The plugin generates the following additional POE::Component::IRC
102 events:
103
104 "irc_console_service"
105 Emitted when a listener is successfully spawned. "ARG0" is the result
106 of "getsockname", see above for details.
107
108 "irc_console_connect"
109 Emitted when a client connects to the console. "ARG0" is the peeradr,
110 "ARG1" is the peer port and "ARG2" is the wheel id of the connection.
111
112 "irc_console_authed"
113 Emitted when a client has successfully provided a valid password.
114 "ARG0" is the wheel id of the connection.
115
116 "irc_console_close"
117 Emitted when a client terminates a connection. "ARG0" is the wheel id
118 of the connection.
119
120 "irc_console_rw_fail"
121 Emitted when a POE::Wheel::ReadWrite could not be created on a socket.
122 "ARG0" is the peer's address, "ARG1" is the peer's port.
123
125 Chris 'BinGOs' Williams
126
128 POE::Component::IRC
129
130 POE::Wheel::SocketFactory
131
132
133
134perl v5.36.0 2023-0P1O-E2:0:Component::IRC::Plugin::Console(3)