Hooks

class wsirc.hooks.Hooks(wsirc)

A system to register callback functions into channels

All callbacks are synchronous in the run_hooks call.

wsirc

The WS_IRC object to pass to the callbacks.

registered_hooks

A dictionary of channel name and list of function pairs.

create_hook_channel(name)

Creates a hook channel with a new name, or clears an existing one.

Parameters:name – The name to use.
make_hook_cb(channel)

Create a single function to run a specific channel.

Parameters:channel – The name of the channel to run.
Returns:A function that runs a specific channel’s hooks and accepts a Message object as an argument.
register_hook(fn, channel)

Insert a function into the specified channel.

Parameters:
  • fn – The function to insert into the channel. It must accept three arguments: a WS_IRC object, a Message object, and a Hooks object.
  • channel – The channel to insert the function into. The channel must have been created first using create_hook_channel.
Returns:

True if the function was sucessfully inserted into the channel.

run_hooks(channel, msg)

Run all functions in the specified channel.

Parameters:
  • channel – The name of the channel to run.
  • msg – The Message object to pass to the callbacks.