本文整理汇总了Python中notifier.Notifier.newSingleMessage方法的典型用法代码示例。如果您正苦于以下问题:Python Notifier.newSingleMessage方法的具体用法?Python Notifier.newSingleMessage怎么用?Python Notifier.newSingleMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notifier.Notifier
的用法示例。
在下文中一共展示了Notifier.newSingleMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WAEventHandler
# 需要导入模块: from notifier import Notifier [as 别名]
# 或者: from notifier.Notifier import newSingleMessage [as 别名]
#.........这里部分代码省略.........
if isGroup:
author = args[2]
msgContact = WAXMPP.message_store.store.Contact.getOrCreateContactByJid(author)
msg.Contact = msgContact
msg.setData({"status":0,"key":key.toString(),"type":WAXMPP.message_store.store.Message.TYPE_RECEIVED});
msg.contact_id = msgContact.id
return fn(self,msg, *args[2:]) if author == jid else fn(self,msg, *args[3:]) #omits author as well if group
return wrapped
def postMessageReceived(fn):
def wrapped(self, *args):
message = fn(self, *args)
contact = message.getContact()
conversation = message.getConversation()
try:
contact = WAXMPP.message_store.store.getCachedContacts()[contact.number];
except:
pass
msgPicture = self.getDisplayPicture(conversation.getJid())
WAXMPP.message_store.pushMessage(conversation.getJid(), message)
conversation.incrementNew()
if conversation.isGroup():
self.notifier.newGroupMessage(conversation.getJid(), "%s - %s"%(contact.name or contact.number,conversation.subject.decode("utf8") if conversation.subject else ""), message.content, msgPicture.encode('utf-8'),callback = self.notificationClicked);
else:
self.notifier.newSingleMessage(contact.jid, contact.name or contact.number, message.content, msgPicture.encode('utf-8'),callback = self.notificationClicked);
if message.wantsReceipt:
self.interfaceHandler.call("message_ack", (conversation.getJid(), eval(message.key).id))
return wrapped
@preMessageReceived
def onMessageError(self,message,errorCode):
self._d("Message Error {0}\n Error Code: {1}".format(message,str(errorCode)));
@preMessageReceived
@postMessageReceived
def onMessageReceived(self, message, content, timestamp, wantsReceipt, pushName=""):
if content is not None:
content = content#.encode('utf-8')
message.timestamp = timestamp
message.content = content
message.wantsReceipt = wantsReceipt
return message
@preMessageReceived
@postMessageReceived
def onImageReceived(self, message, preview, url, size, wantsReceipt = True):
self._d("MEDIA SIZE IS "+str(size))
mediaItem = WAXMPP.message_store.store.Media.create()
mediaItem.remote_url = url
mediaItem.preview = preview
mediaItem.mediatype_id = WAConstants.MEDIA_TYPE_IMAGE