Here are the examples of the python api xmpp.protocol.Message taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Example 1
Project: ax25xmpp Source File: ax25xmpp.py
def stdio_message(self, message):
# Filter out control characters to avoid not-well-formed errors
txmessage = filter(lambda x: x >= ' ', message)
m = xmpp.protocol.Message(to=self.remotejid,body=txmessage,typ='chat')
self.jabber.send(m)
pass
3
Example 2
def send_message(self, body, to, quiet=False, html_body=None):
"""Send a message to a single member"""
if to.get('MUTED'):
to['QUEUED_MESSAGES'].append(body)
else:
if not quiet:
logger.info('message on %s to %s: %s' % (self.name, to['JID'], body))
message = xmpp.protocol.Message(to=to['JID'], body=body, typ='chat')
if html_body:
html = xmpp.Node('html', {'xmlns': 'http://jabber.org/protocol/xhtml-im'})
html.addChild(node=xmpp.simplexml.XML2Node("<body xmlns='http://www.w3.org/1999/xhtml'>" + html_body.encode('utf-8') + "</body>"))
message.addChild(node=html)
self.client.send(message)
0
Example 3
@classmethod
def _process_queue_item(cls, jabber_client):
msg = cls.message_queue.get(True) # Blocks until a message is queued
recipient, message = msg
# Apply alias mapping, if any exists
recipient = Settings['aliases'].get(recipient, recipient)
xmpp_message = xmpp.protocol.Message(recipient, message)
try:
jabber_client.send(xmpp_message)
cls._del_retry_message(msg)
except IOError, e:
if cls._retry_message(msg):
logging.warning("Couldn't send the message, will retry... %s" % repr(msg))
cls.message_queue.put(msg)
else:
logging.error("Couldn't send the message %s" % repr(msg))
logging.error(repr(e))
except Exception, e:
logging.error("Couldn't send the message %s" % repr(msg))
logging.error(repr(e))
finally:
cls.message_queue.task_done()
0
Example 4
def send(json_dict):
template = "<message><gcm xmlns='google:mobile:data'>{1}</gcm></message>"
content = template.format(client.Bind.bound[0], json.dumps(json_dict))
client.send(xmpp.protocol.Message(node = content))