[ejabberd] How to add a custom event?

Xi Liu jason.liuxi at gmail.com
Thu Jan 21 06:13:02 MSK 2010

Hi friends:
I wanna add a module in ejabberd in order to create a sub muc room for every
muc room users create.
I write a module beavioring gen_mod containing start, stop and a function to
create a room everything the same with the original room except the name.And
I also modify the config file to start my module with ejabberd.Since there
is no existing events fit my need, so I try to create a new event and hook
the function to the event in my own modules's start(). and unload it in
I intend to add a event in the do_route function in module mod_muc.erl.and
modify the room name in the Packet,then call do_route1 again after the
original do_route1 call in do_route.
I can achive this simplely add lines of code in mod_muc just call do_route1
again.But I want to use the hook and event facility.Here is my plan: I
register a event and triger this event by calling
ejabberd:hooks:run(event_name, XXX). and this will call the function in my
own module. So I need to pass some arguments like Packet to my function. How
to specify the arguments and where to add a user-defined event?

I checked the source tring to find out where the original events like
set_presence_hook(User, Server, Resource, Packet) -> none is defined,  but
ther are only codes about add, delete and run.

Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20100121/1d588743/attachment.html>

More information about the ejabberd mailing list