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

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

by stephan48 (Novice)
on Feb 23, 2009 at 19:32 UTC ( #745812=perlquestion: print w/replies, xml ) Need Help??

stephan48 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i want to run a cmd all 5 mins in a POE::Component::IRC::Plugin i already search about this since 2 days but i didnt found a solution till now any idea how i could solve it?
  • Comment on POE::Component::IRC::Plugin Run a CMD All 5mins

Replies are listed 'Best First'.
Re: POE::Component::IRC::Plugin Run a CMD All 5mins
by rcaputo (Chaplain) on Feb 23, 2009 at 20:57 UTC
Re: POE::Component::IRC::Plugin Run a CMD All 5mins
by bingos (Vicar) on Feb 23, 2009 at 21:31 UTC

    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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://745812]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2022-05-21 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?