1

I have set up a chat setting using Pidgin and Ejabberd. I have written a custom module in ejabberd using the user_send_packet hook:

ejabberd_hooks:add(user_send_packet, _Host, ?MODULE,
           myMessage, 95),

The function myMessage is as follows:

myMessage({Packet, C2SState})->

  PacketType=xmpp:get_name(Packet),
  case PacketType of
    <<"iq">>->
      ok;
    <<"presence">>->
      ok;
    <<"message">>->
      Sum=2+2,
      ?INFO_MSG("Sum is ~p~n",[Sum])
  end,

  {Packet,C2SState}.

Basically what this function does is that whenever someone sends a chat message say "hello there", the value of Sum gets calculated and printed on the server and its logs and the message "hello there" is sent to the second user.

But now I want send the value of Sum along with the message "hello there" to the second user for example:

"hello there Sum is 4"

Can anyone help me out with this?

Dunedan
  • 7,848
  • 6
  • 42
  • 52
abhishek ranjan
  • 612
  • 7
  • 23
  • it has been already answered at this [link](https://stackoverflow.com/questions/45455387/how-do-i-append-custom-data-in-the-body-of-a-xmpp-message-in-ejabberd). – abhishek ranjan Aug 17 '17 at 09:50
  • Possible duplicate of [How do I append custom data in the body of a xmpp message in ejabberd](https://stackoverflow.com/questions/45455387/how-do-i-append-custom-data-in-the-body-of-a-xmpp-message-in-ejabberd) – Dunedan Sep 17 '17 at 13:43

0 Answers0