cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
3863
Views
0
Helpful
3
Replies

python xmpp jabber groupchat

Hi all,

I started to play with python xmpp library and it's working to send a message from one user to an other user.

However I can't make it works to send a message in a group chat.

I used this post to build my code: http://blogs.cisco.com/getyourbuildon/xmpp-a-power-tool-in-your-tool-box

I get the room from "Room link" in Cisco Jabber and 10.80.13.44 is our im server (I don't manage it).

When I run my code, I don't even see my bot joining the room in the chat.

import xmpp

cmd='Hello'

jid="bot"

pwd="123"

room=testalex419371652216522@conference-2-standalonecluster058dd.mydomain.com
jid=xmpp.protocol.JID(jid)

cl=xmpp.Client(jid.getDomain())

cl.connect(server=('10.80.13.44',5222))
cl.auth(jid.getNode(), pwd)

cl.sendInitPresence(requestRoster=0)

cl.send(xmpp.Presence(to='{0}/{1}'.format(room, jid)))

message=xmpp.Message(room, cmd)
message.setAttr('type', 'groupchat')
cl.send(message)

3 REPLIES 3
npetrele
Cisco Employee

Cisco doesn't have a Python library for Jabber/XMPP.  I suggest you ask this question of the people who made your XMPP library.

Sorry about the confusion.

I didn't meant that the python library was a Cisco library.

My question is more about about how to use this library with Cisco Jabber (as it stated in the Cisco blog : XMPP: A Power Tool in Your Tool Box).

The point is with my code I can't get the "bot" to login in a chatroom/groupchat to send a message and I don't understand why.

So if someone have any idea about the issue, I'll be very interested.

Regards,

cupdike
Beginner

Try using the slixmpp python lib.  You can get their Multi User Chatroom code from here:  Mulit-User Chat (MUC) Bot — slixmpp

In my case, I had to change this one line near the bottom:

    xmpp.connect()

To:

    xmpp.connect(address=('<your IMP server>', 5222))


And then the example pretty much worked.  Add a -d to enable debug logging if it's not working. 


I had trouble identifying the service reference for my chatroom.  I installed Adium (an alternative XMPP client) and hooked it up to our IMP and was able to find the correct reference that way using it's Discovery Browser.  With the chatroom service reference, my command line looked like this:


python muc.py -j <my jid> -r <chatroom name><long number>@<chatroom conference server>

e.g.

python muc.py -j myjid@mydomain.com -r mychatroom392857292379050@confserv-1-mydomain.com

That number is assigned by IMP (not part of the name I entered).  The script will prompt you for your password and nickname (or can specify on command line).

Then go to the chat room and use the nickname in a message and it should respond back with:

"I heard that, <jid that commented>"

Once it's working, rip out the bot parts and you've got your MUC client...

Note, I have no association with slixmpp--just found it easiest to work with so far.

Create
Recognize Your Peers
Content for Community-Ad