[ejabberd] Parsing Packet Contents

Badlop badlop at gmail.com
Tue Mar 31 14:25:43 MSD 2009


2009/3/31  <guntanis at gmail.com>:
> This is probably a really basic question and is mostly related to erlang.
> I'm making a module based on the mod_echo that takes the message and send it
> to an external program and returns the output command.
> I have something like this:
> handle_info({route, From, To, Packet}, State) ->
> Cmd = "/sbin/myCommand ",
> Port = os:cmd(Cmd),
> ejabberd_router:route(To, From, Port),
> {noreply, State};
> handle_info(_Info, State) ->
> {noreply, State}.
>
> But I'm not sure on how to:
> 1. get the body of the message from Packet.
> 2. concatenate Cmd with the body of the message, so it's passed as the
> parameter of the external command.
>
> Can someone help me with some pointers on this one?

Check mod_shcommands, it may give you some ideas.
http://www.ejabberd.im/mod_shcommands

---
Badlop,
ProcessOne


More information about the ejabberd mailing list