Class Autumn::ChannelLeaf
In: lib/autumn/channel_leaf.rb
Parent: Leaf

A special kind of leaf that only responds to messages sent to certain channels. Leaves that subclass ChannelLeaf can, in their config, specify a channels option that narrows down which channels the leaf listens to. The leaf will not invoke the hook methods nor the *_command methods for IRC events that are not associated with those channels. It will respond to global, non-channel-specific events as well.

You can combine multiple ChannelLeaf subclasses in one Stem to allow you to run two leaves off of one nick, but have the nick running different leaves in different channels.

The channels option should be a list of stems, and for each stem, a valid channel. For example, if you ran your leaf on two servers, your stems.yml file might look like:

 GamingServer:
   channels: fishinggames, games, drivinggames
   [...]
 FishingServer:
   channels: fishinggames, flyfishing
   [...]

Now let‘s say you had a trivia leaf that asked questions about fishing games. You‘d want to run that leaf on the "fishinggames" channel of each server, and the "games" channel of the GamingServer, but not the other channels. (Perhaps your Stem was also running other leaves relevant to those channels.) You‘d set up your leaves.yml file like so:

 FishingGamesTrivia:
   channels:
     GamingServer:
       - fishinggames
       - games
     FishingServer: fishinggames
   [...]

Now your leaf will only respond to messages relevant to the specified server channels (as well as global messages).

Interception and filtering of messages is done at the leaf level, not the stem level. Therefore, for instance, if you override someone_did_join_channel, it will only be called for the appropriate channels; however, if you implement irc_join_event, it will still be called for all channels the stem is in.

Methods

Attributes

channels  [R]  The IRC channels that this leaf is responding to, mapped to server names.

Public Instance methods

Creates a new instance. (See the Leaf class for more information.)

[Validate]