Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this gets called when the plugin is loaded
- sub start {
- my ($kernel, $heap) = @_[KERNEL, HEAP];
- $kernel->alias_set(PLUGIN_NAME);
- }
- # this gets called when the plugin is unloaded
- sub stop {
- my ($kernel, $heap) = @_[KERNEL, HEAP];
- }
- # got a request
- sub got_request {
- my ($kernel, $heap, $user, $location, $replyto, $extra, $keyword, $message) = @_[KERNEL, HEAP, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5];
- # reply($kernel, $replyto, $extra, "message here");
- }
- # got a notice
- sub got_notice {
- my ($kernel, $heap, $target, $extra, $keyword, $message) = @_[KERNEL, HEAP, ARG0, ARG1, ARG2, ARG3];
- }
- # got a reply to a request
- sub got_reply {
- my ($kernel, $heap, $extra, $keyword, $message) = @_[KERNEL, HEAP, ARG0, ARG1, ARG2];
- }
- # don't touch anything beyond this point unless you know what you're doing
- # load plugin
- sub load {
- my (undef, $config) = @_;
- my $session = POE::Session->create(
- inline_states => {
- _start => \&start,
- stop => \&stop,
- unload => \&unload,
- got_notice => \&got_notice,
- got_request => \&got_request,
- got_reply => \&got_reply,
- },
- heap => { name => PLUGIN_NAME },
- );
- register_notice_keywords(PLUGIN_NAME, lc(PLUGIN_NAME), NOTICE_KEYWORDS);
- register_request_keywords(PLUGIN_NAME, REQUEST_KEYWORDS);
- register_reply_keywords(PLUGIN_NAME, lc(PLUGIN_NAME), REPLY_KEYWORDS);
- }
- # unload plugin
- sub unload {
- my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
- $kernel->call($session, 'stop');
- $kernel->alias_remove(PLUGIN_NAME);
- $kernel->signal($session, 'KILL');
- }
- #1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement