mirror of
https://github.com/reality/dbot.git
synced 2024-11-30 16:09:27 +01:00
dox
This commit is contained in:
parent
9d21b90b34
commit
e1c332daef
30
modules/event/README.md
Normal file
30
modules/event/README.md
Normal 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 ]);
|
@ -46,3 +46,8 @@ Return a list of aliases for a given primary user.
|
|||||||
|
|
||||||
#### isOnline(server, user, channel, useLowerCase)
|
#### isOnline(server, user, channel, useLowerCase)
|
||||||
Return whether a user is online in a given channel on the given server.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user