[ejabberd] Exmpp bot jabber client autorization

kael ka-el at laposte.net
Fri May 20 20:26:46 MSD 2011


On 05/20/2011 09:09 AM, Alexander Kuleshov wrote:
> Hello,

Hello,

> I run echo client
> (https://github.com/processone/exmpp/blob/master/examples/echo_client.erl)
> It works. But when i add it to roster it's offline. Why?

In echo_client:loop/1, the second clause handles only <message/>, and 
the third one handles other packets which are just print in the console.

> How can i make online status for it?

You need to add, in echo_client:loop/1, a clause to handle presence 
packets :

Record = #received_packet{packet_type = presence},

And to send a presence back to the contact.


I've attached a modified version of echo_client.erl which handles 
presence and presence subscription, and maintains a list of online contacts.

See this tutorial 
<https://support.process-one.net/doc/display/EXMPP/Scalable+XMPP+bots+with+erlang+and+exmpp>.

And the "sub2text" bot which is a great example of an exmpp bot using 
gen_server <https://github.com/astro/sub2text> and specially 
<https://github.com/astro/sub2text/blob/68ae223756532315108c826888618003c6ea25b0/src/client.erl>.

-- 
kael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: echo_client.erl
Type: text/x-erlang
Size: 6557 bytes
Desc: not available
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20110520/58e7ea21/attachment.bin>


More information about the ejabberd mailing list