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

Hi,

I'd like to write a plugin for an IRC bot (which is based on POE::Component::IRC) using POE::Component::IRC::Plugin. I want it to do the following (this is a simplified version of what I actually would like it to do):

When the nick 'foo' sends to a channel

<foo> !greet 20

the bot must reply

<bot> Hi foo!

after 20 seconds. How could I do that? I don't know how to trigger an event after a specified amount of time.

Thanks in advance for any suggestions.

Pablo.

Replies are listed 'Best First'.
Re: Write a plugin for an IRC bot
by neilwatson (Priest) on Mar 17, 2016 at 20:50 UTC
      Thanks @neilwatson. It's always useful to look at someone else's code.
Re: Write a plugin for an IRC bot
by Anonymous Monk on Mar 17, 2016 at 17:39 UTC
    I don't know how to trigger an event after a specified amount of time.

    From http://poe.perl.org/?POE_Cookbook/Waiting:

    # beforehand $kernel->state('event_part_two', \&task_part_two); sub task_part_one { # Do some work. ...; # Ask POE::Kernel to give this session an "event_part_two" # event after five seconds have passed. $kernel->delay(event_part_two => 5); } sub task_part_two { # Do some more work. ...; }
      Thank you very much @Anonymous Monk. That's exactly what I was looking for.
Re: Write a plugin for an IRC bot
by MidLifeXis (Monsignor) on Mar 17, 2016 at 17:45 UTC

    Sounds like this would be an interesting project for an undergrad assignment. Network communication + async + timeout, oh my!

    --MidLifeXis