PoCo-IRC plugins effectively are executed within the component's POE session
This means that if you want to make use of POE::Kernel's alarms/delays you have a number of different approaches:
package PluginDelay; use strict; use warnings; use POE; # import POE stuff use POE::Component::IRC::Plugin qw( :ALL ); # Plugin object constructor sub new { my ($package) = shift; return bless {}, $package; } sub PCI_register { my ( $self, $irc ) = splice @_, 0, 2; $irc->plugin_register( $self, 'SERVER', qw(public) ); # Register an object state handler # Try not to use something poco-irc already uses # using the name of your plugin is a good practise $poe_kernel->state( 'PluginDelay_alarm', $self ); # Set our initial alarm $kernel->delay( 'PluginDelay_alarm', 5 * 60 ); return 1; } # This is method is mandatory but we don't actually have anything to d +o. sub PCI_unregister { return 1; } sub PluginDelay_alarm { my ($kernel,$self,$irc) = @_[KERNEL,OBJECT,HEAP]; # Do something funky. # Set the next alarm up $kernel->delay( 'PluginDelay_alarm', 5 * 60 ); return; } 1;
In reply to Re: POE::Component::IRC::Plugin Run a CMD All 5mins
by bingos
in thread POE::Component::IRC::Plugin Run a CMD All 5mins
by stephan48
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |