Modules:QuickList:ComplexEvents
From Anope Wiki
Contents |
Complex Events
Complex Events allow you to hook to outgoing messages sent by Anope. More information about events can be found in docs/EVENTS in the Anope directory.
createEventHandler
Creates an event handler for complex events.
EvtMessage *createEventHandler(char *name, int (*func) (char *source, int ac, char **av))
The name specifies to which outgoing message you hook (like NICK or PRIVMSG). The given func will be called when the given message name is sent out.
Returns a pointer to the EvtMessage struct which contains information about the event.
moduleAddEventHandler
Hook an EvtMessage struct to the event list.
int moduleAddEventHandler(EvtMessage *evm)
Inserts the given evm (pointer to EvtMessage struct created with createEventHandler) into the event list. This should be done for any created EvtMessage.
Returns:
- MOD_ERR_OK - Success
- MOD_ERR_PARAMS - A NULL-pointer was passed
- MOD_ERR_UNKNOWN - Anope doesn't know which module called the function
moduleEventDelHandler
Delete a hooked event handler.
int moduleEventDelHandler(char *name)
Deletes the event handler hooked to the outgoing message type name from the event list. This also performs all cleanups required.
Returns:
- MOD_ERR_OK - Success
- MOD_ERR_UNKNOWN - Anope doesn't know which module called the function
- MOD_ERR_NOEXIST - There is no hook for the given name
Example
#include <module.h>
int my_nick(char *source, int ac, char **av);
int AnopeInit(int argc, char **argv)
{
EvtMessage *msg;
msg = createEventHandler("NICK", my_nick);
if (moduleAddEventHandler(msg) != MOD_ERR_OK) {
alog("Can't hook to NICK event");
return MOD_STOP;
}
return MOD_CONT;
}
int my_nick(char *source, int ac, char **av)
{
if (moduleEventDelHandler("NICK") == MOD_ERR_OK)
alog("Complex event for NICK deleted");
else
alog("Complex event for NICK could not be deleted");
return MOD_CONT;
}

