Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: POE::Component::IRC::Plugin Run a CMD All 5mins

by bingos (Vicar)
on Feb 23, 2009 at 21:31 UTC ( #745839=note: print w/replies, xml ) Need Help??

in reply to POE::Component::IRC::Plugin Run a CMD All 5mins

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:

  • You can setup your own POE session within your plugin. There is an example of this in the POE cookbook, then setup up your delays/alarms.
  • Alternatively, you can get creative and register an object state handler from your plugin with the PoCo-IRC session:
    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;

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://745839]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-01-29 13:04 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (74 votes). Check out past polls.