From e1c332daefb9b5ca36800938fea767209357f5d3 Mon Sep 17 00:00:00 2001 From: reality Date: Thu, 24 Jan 2013 19:11:22 +0000 Subject: [PATCH] dox --- modules/event/README.md | 30 ++++++++++++++++++++++++++++++ modules/users/README.md | 5 +++++ 2 files changed, 35 insertions(+) create mode 100644 modules/event/README.md diff --git a/modules/event/README.md b/modules/event/README.md new file mode 100644 index 0000000..7474288 --- /dev/null +++ b/modules/event/README.md @@ -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 ]); diff --git a/modules/users/README.md b/modules/users/README.md index 5bc713e..34195c4 100644 --- a/modules/users/README.md +++ b/modules/users/README.md @@ -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.