Bot::Cobalt::Timer - Cobalt timer objects


  my $timer = Bot::Cobalt::Timer->new(
    event  => 'my_timed_event',
    args   => [ $one, $two ],
  ## Add this instance to Core's TimerPool, for example:
  $core->timer_set( $timer );


A Bot::Cobalt::Timer instance represents a single timed event.

These are usually constructed for use by the Bot::Cobalt::Core TimerPool; also see "timer_set" in Bot::Cobalt::Core::Role::Timers.

By default, timers that are executed will fire against the Bot::Cobalt::Core singleton. You can pass in a different 'core =>' object; it simply needs to provide a send_event method that is passed the "event" and "args" when the timer fires (see "Execution").


Timer settings


The absolute time that this timer is supposed to fire (epoch seconds).

This is normally set automatically when "delay" is called.

(If it is tweaked manually, "delay" is irrelevant information.)


The time this timer is supposed to fire expressed in seconds from the time it was set.

(Sets "at" to time() + delay)


The name of the event that should be fired via send_event when this timer is executed.


A List::Objects::WithUtils::Array containing any arguments attached to the "event".


This timer's unique identifier, used as a key in timer pools.

Note that a unique random ID is added when the Timer object is passed to "timer_set" in Bot::Cobalt::Core::Role::Timers if no id is explicitly specified.


The alias tag attached to this timer. Defaults to caller()


The type of event.

Valid types as of this writing are msg, action, and event.

msg and action types require "context", "text", and "target" attributes be specified.

If no type has been specified for this timer, type() returns our best guess; for timed events carrying a "context" and "target" the default is msg.

This is used to set up proper event names for special timer types.


msg and action timer types only

The server context for an outgoing msg or action.

See "type"


msg and action timer types only

The text string to send with an outgoing msg or action.

See "type"


msg and action timer types only

The target channel or nickname for an outgoing msg or action.

See "type"


A timer object can be instructed to execute as long as it was provided a proper core object at construction time (normally Bot::Cobalt::Core).


Returns boolean true if the timer is ready to execute; in other words, if the specified "at" is reached.


"execute" the timer if "is_ready" is true.


Execute the timer; if our core object can send_event, the timer's event is broadcast. Otherwise the timer will warn and return.


Jon Portnoy <>