Contraclass › Event system

From Botdom Documentation

Jump to: navigation, search

Contra's events system is contained completely within the class Event_system, which is this class! It's quite simplistic, and to make things easier, the extension class acts as an interface between modules and the Events system class.

Contents

Location

~/core/Events_class.php

Properties

protected $core; 		// Instance of the Bot class.
protected $events = array(); // Stores all event and command information.

Methods

__construct

This is called when the class is instantiated. All it really does is take down a copy of an instance of the Bot class.

load_mods

This simply loads all of the modules into the bot.

trigger

Triggers a module event.

Parameters:
 $event - string. The name of the event to trigger.
 $arg1 .. $arg9 - mixed. Arguments provided by the event.

trigger_mod

Triggers a module event for a specific module.

Parameters:
 $module - string. Name of the module to trigger an event for.
 $event - string. Name of the event to trigger.
 $arg1 .. $arg9 - mixed. Arguments provided by the event.

command

Handles messages which are thought to be commands. If a command is received, this method triggers it.

Parameters:
 $command - string. First word in $message.
 $namespace - string. The namespace of the channel the message came from.
 $from - string. The username of the person who sent the message.
 $message - string. The message sent.

hook

Hooks a module's method to an event.

Parameters:
 $module - string. Name of the module to hook $event for.
 $method - string. Name of the method to hook onto $event.
 $event - string. Name of the event to hook $method onto.

unhook

Unhooks a module's method from an event.

Parameters:
 $module - string. Name of the module to unhook $event for.
 $method - string. Name of the method to unhook from $event.
 $event - string. Name of the event to unhook $method from.

new_event

This creates a new event!

Parameters:
 $event - string. Name for the new event.

add_command

Hooks a command into the bot.

Parameters:
 $module - string. Name of the module to add the command for.
 $command - mixed. Name(s) of the command to add.
 $method - string. Name of the method to hook the command to.
 $privs - integer. Access level required to access the command. Defaults to 25(Guests).
 $switch - bool(true/false). Whether the command is on or off at startup. Defaults to true(on).

cmdHelp

Adds some helpful information about a command.

Parameters:
 $module - string. Name of the module the command belongs to.
 $command - mixed. Name(s) of the command to add information for.
 $help - string. Brief, helpful information about $command.

delCmd

Removes a command from the bot.

Parameters:
 $module - string. Name of the module the command belongs to.
 $command - string. Name of the command to remove.

switchCmd

Switches a command on or off.

Parameters:
 $command - string. The name of the command to switch on or off.
 $switch - bool(true/false). Whether to turn the command on or off. Defaults to true(on).
Personal tools