0

I'm making a Perl IRC bot and I want to send a message periodically to a channel. I'm using POE::Component::IRC, but as far as I can see, there is no method or event handling this.

Is there a way to accomplish this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lasse A Karlsen
  • 801
  • 5
  • 14
  • 23
  • Isn't that what the `privmsg` command (http://search.cpan.org/dist/POE-Component-IRC/lib/POE/Component/IRC.pm#privmsg) does? (Despite the "priv" in its name, it's documented as sending "a public or private message".) – ruakh Feb 12 '12 at 01:13
  • Yes, but it needs to be called within one of the event handlers.. like irc_public (which loads when creating a POE session). – Lasse A Karlsen Feb 12 '12 at 01:21
  • Are you saying you can't find a POE method of creating a timer? – ikegami Feb 12 '12 at 05:26
  • Lasse, I have created a powerful solution but it's too much to put here. Would you like me to put it on pastie or something? – gdanko Dec 17 '13 at 16:13

1 Answers1

1

You can use POE::Kernel's delay routine to act like a one-time timer calling itself over and over.

Basically, you have an event handler named my_event. Within my_event, you send the PRIVMSG to the channel. You then call this same event handler my_event using the delay routine inherited through POE.

See: POE: Cookbook - Recurring Alarms

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ardnew
  • 2,028
  • 20
  • 29