01-27-2017 11:49 AM
We are trying to automate some tasks by scripting message post to IM&P server (ver 11.0.1), we are able to send to individual users, and it pops up ok in their Jabber GUI, but when we try to do the same for persistent chat room JID, the message does not show up in Jabber client, however we can verify that the message was posted in the archive database ok.
Script details:
Python version and xmpppy version.
Python 2.7.3 -- EPD 7.3-2 (64-bit)
xmpppy 0.5.0rc1-1 opt/epd/epd-7.3-2
#!/opt/epd/current/bin/python
import argparse
import re
import base64
import datetime
import os
import xmpp
import time
import sys
from util import mylogger
from util.ssh import SSH
import site
import paramiko
import smtplib
-------------------------------------------------------------------------------------------------------
Send to single client:
------------------------------------------------------------------------------------------------------
Below codes would send to single id, example: ‘someid@global.com’, the destination client sees message on the gui client.
def SendJabber(JabberDest,JabberMsg, jidparams, jabber_server):
for mandatory in ['jid','password']:
if mandatory not in jidparams.keys():
print 'ERROR: valid JID is needed for sending messages.'
jid=xmpp.protocol.JID(jidparams['jid'])
cl=xmpp.Client(jid.getDomain(),debug=[])
con=cl.connect(server=(str(jabber_server),'5222'))
if not con:
print 'ERROR: could not connect to jabber server!'
else:
auth=cl.auth(jid.getNode(),jidparams['password'],resource=jid.getResource())
if not auth:
print 'ERROR: could not authenticate to jabber server!'
else:
print "connected"
id=cl.send(xmpp.protocol.Message(JabberDest,JabberMsg))
time.sleep(1)
cl.disconnect()
--------------------------------------------------------------------------
send to chatroom:
Below codes would send to chat room, example: ‘chatgroup278691918619186@us-primary-chat-server.global.com’, the chat room do not see the message on the gui.
-------------------------------------------------------------------------
def SendJabber(JabberDest,JabberMsg, jidparams, jabber_server):
for mandatory in ['jid','password']:
if mandatory not in jidparams.keys():
print 'ERROR: Please populate ~/.xsend config file with valid JID for sending messages.'
jid=xmpp.protocol.JID(jidparams['jid'])
cl=xmpp.Client(jid.getDomain(),debug=[])
con=cl.connect(server=(str(jabber_server),'5222'))
if not con:
print 'ERROR: could not connect to jabber server!'
else:
auth=cl.auth(jid.getNode(),jidparams['password'],resource=jid.getResource())
if not auth:
print 'ERROR: could not authenticate to jabber server!'
else:
print "connected"
room='chatgroup278691918619186@us-primary-chat-server.global.com'
nickname='testgroupchat'
cl.send(xmpp.Presence(to="%s/%s" % (room, nickname)))
msg= xmpp.protocol.Message(body=JabberMsg)
msg.setTo(room)
msg.setType('groupchat')
cl.send(msg)
time.sleep(1)
cl.disconnect()
04-18-2017 06:05 AM
Hello,
I have exactly the same issue.
Did you figure out how to solve this or do you know if it's a Cisco Jabber limitation?
Best regards,
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide