3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00
This commit is contained in:
reality 2013-01-24 19:11:22 +00:00
parent 9d21b90b34
commit e1c332daef
2 changed files with 35 additions and 0 deletions

30
modules/event/README.md Normal file
View File

@ -0,0 +1,30 @@
## Event
Emit events for whatever you want man idk.
### Description
This is a library module designed for other modules to use to emit various
events at any point, and also to attach functions to said events. These are
similar to command hooks, however their advantage is that they may be called
anywhere in your code; they are particularly useful when you want to attach a
callback to a listener.
### API
#### addHook(eventName, callback)
This function will set a given callback to be executed every time the
emit API function is executed with the given event name. The arguments of your
callback are defined as an array in the emit call.
The best place to add hooks to commands is in the 'onLoad' function of your
module, as this ensures it will be run while all other modules are loaded so
nothing will be missed.
#### emit(eventName, [ arguments ])
This function executes all of the functions associated with the given eventName,
passing your given array of arguments.
For example, to emit an event when you detect a nick change:
dbot.api.event.emit('nick_changed', [ event.server, newNick ]);

View File

@ -46,3 +46,8 @@ Return a list of aliases for a given primary user.
#### isOnline(server, user, channel, useLowerCase)
Return whether a user is online in a given channel on the given server.
### Events
#### nick_changed(server, newNick)
This is executed when a new alias is added for a user.