1POE::Component::IRC::PlUusgeirn:C:oPnlturgiMbaunt(e3d)PPeOrEl::DCoocmupmoennetnatt:i:oInRC::Plugin::PlugMan(3)
2
3
4
6 POE::Component::IRC::Plugin::PlugMan - A PoCo-IRC plugin that provides
7 plugin management services.
8
10 use strict;
11 use warnings;
12 use POE qw(Component::IRC::State);
13 use POE::Component::IRC::Plugin::PlugMan;
14
15 my $botowner = 'somebody!*@somehost.com';
16 my $irc = POE::Component::IRC::State->spawn();
17
18 POE::Session->create(
19 package_states => [
20 main => [ qw(_start irc_plugin_add) ],
21 ],
22 );
23
24 sub _start {
25 $irc->yield( register => 'all' );
26 $irc->plugin_add( 'PlugMan' => POE::Component::IRC::Plugin::PlugMan->new( botowner => $botowner ) );
27 return;
28 }
29
30 sub irc_plugin_add {
31 my ($desc, $plugin) = @_[ARG0, ARG1];
32
33 if ($desc eq 'PlugMan') {
34 $plugin->load( 'Connector', 'POE::Component::IRC::Plugin::Connector' );
35 }
36 return;
37 }
38
40 POE::Component::IRC::Plugin::PlugMan is a POE::Component::IRC plugin
41 management plugin. It provides support for 'on-the-fly' loading,
42 reloading and unloading of plugin modules, via object methods that you
43 can incorporate into your own code and a handy IRC interface.
44
46 "new"
47 Takes two optional arguments:
48
49 'botowner', an IRC mask to match against for people issuing commands
50 via the IRC interface;
51
52 'auth_sub', a sub reference which will be called to determine if a user
53 may issue commands via the IRC interface. Overrides 'botowner'. It will
54 be called with three arguments: the IRC component object, the
55 nick!user@host and the channel name as arguments. It should return a
56 true value if the user is authorized, a false one otherwise.
57
58 'debug', set to a true value to see when stuff goes wrong;
59
60 Not setting 'botowner' or 'auth_sub' effectively disables the IRC
61 interface.
62
63 If 'botowner' is specified the plugin checks that it is being loaded
64 into a POE::Component::IRC::State or sub-class and will fail to load
65 otherwise.
66
67 Returns a plugin object suitable for feeding to POE::Component::IRC's
68 "plugin_add" method.
69
70 "load"
71 Loads a managed plugin.
72
73 Takes two mandatory arguments, a plugin descriptor and a plugin package
74 name. Any other arguments are used as options to the loaded plugin
75 constructor.
76
77 $plugin->load( 'Connector', 'POE::Component::IRC::Plugin::Connector', delay, 120 );
78
79 Returns true or false depending on whether the load was successfully or
80 not.
81
82 "unload"
83 Unloads a managed plugin.
84
85 Takes one mandatory argument, a plugin descriptor.
86
87 $plugin->unload( 'Connector' );
88
89 Returns true or false depending on whether the unload was successfully
90 or not.
91
92 "reload"
93 Unloads and loads a managed plugin, with applicable plugin options.
94
95 Takes one mandatory argument, a plugin descriptor.
96
97 $plugin->reload( 'Connector' );
98
99 "loaded"
100 Takes no arguments.
101
102 $plugin->loaded();
103
104 Returns a list of descriptors of managed plugins.
105
107 An IRC interface is enabled by specifying a "botowner" mask to "new".
108 Commands may be either invoked via a PRIVMSG directly to your bot or in
109 a channel by prefixing the command with the nickname of your bot. One
110 caveat, the parsing of the irc command is very rudimentary (it merely
111 splits the line on spaces).
112
113 "plugin_add"
114 Takes the same arguments as "load".
115
116 "plugin_del"
117 Takes the same arguments as "unload".
118
119 "plugin_reload"
120 Takes the same arguments as "reload".
121
122 "plugin_loaded"
123 Returns a list of descriptors of managed plugins.
124
125 "plugin_list"
126 Returns a list of descriptors of *all* plugins loaded into the current
127 PoCo-IRC component.
128
130 Chris 'BinGOs' Williams
131
133 POE::Component::IRC::State
134
135 POE::Component::IRC::Plugin
136
137
138
139perl v5.34.0 2021-0P7O-E2:2:Component::IRC::Plugin::PlugMan(3)