当前位置: 首页>>代码示例>>Python>>正文


Python Notifier.newMessage方法代码示例

本文整理汇总了Python中notifier.Notifier.newMessage方法的典型用法代码示例。如果您正苦于以下问题:Python Notifier.newMessage方法的具体用法?Python Notifier.newMessage怎么用?Python Notifier.newMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在notifier.Notifier的用法示例。


在下文中一共展示了Notifier.newMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WAEventHandler

# 需要导入模块: from notifier import Notifier [as 别名]
# 或者: from notifier.Notifier import newMessage [as 别名]

#.........这里部分代码省略.........
		
		
		fmsg.setData({"status":0,"content":msg_text.encode('utf-8'),"type":1})
		WAXMPP.message_store.pushMessage(to_id,fmsg)
		
		self.conn.sendMessageWithBody(fmsg);
	
	def notificationClicked(self,jid):
		self._d("SHOW UI for "+jid)
		self.showUI.emit(jid);

	def message_received(self,fmsg,duplicate = False):
		msg_type = "duplicate" if duplicate else "new";

		if fmsg.content is not None:
			#self.new_message.emit({"data":fmsg.content,"user_id":fmsg.getContact().jid})
			msg_contact = fmsg.getContact();
			try:
				msg_contact = WAXMPP.message_store.store.getCachedContacts()[msg_contact.number];
			except:
				msg_contact.name= fmsg.getContact().number
				msg_contact.picture = WAConstants.DEFAULT_GROUP_PICTURE
			
			
			#if fmsg.Media is not None:
			#	fmsg.content = QtCore.QCoreApplication.translate("WAEventHandler", fmsg.content)
				
				#if fmsg.Media.mediatype_id == WAConstants.MEDIA_TYPE_VCARD:
				#	self.fetchVCard(fmsg.id)
			

				
			if fmsg.Conversation.type == "single":
				self.notifier.newMessage(msg_contact.jid, msg_contact.name, fmsg.content,None if type(msg_contact.picture) == str else msg_contact.picture.encode('utf-8'),callback = self.notificationClicked);
			else:
				conversation = fmsg.getConversation();
				self.notifier.newMessage(conversation.jid, "%s in %s"%(msg_contact.name,conversation.subject), fmsg.content,None if type(msg_contact.picture) == str else msg_contact.picture.encode('utf-8'),callback = self.notificationClicked);
			
			self._d("A {msg_type} message was received: {data}".format(msg_type=msg_type, data=fmsg.content));
		else:
			self._d("A {msg_type} message was received".format(msg_type=msg_type));

		if(fmsg.wantsReceipt):
			self.conn.sendMessageReceived(fmsg);

	
		
	
	def subjectReceiptRequested(self,to,idx):
		self.conn.sendSubjectReceived(to,idx);
		
		
			
	def presence_available_received(self,fromm):
		if(fromm == self.conn.jid):
			return
		self.available.emit(fromm)
		self._d("{Friend} is now available".format(Friend = fromm));
	
	def presence_unavailable_received(self,fromm):
		if(fromm == self.conn.jid):
			return
		self.unavailable.emit(fromm)
		self._d("{Friend} is now unavailable".format(Friend = fromm));
	
	def typing_received(self,fromm):
开发者ID:airlanggacahya,项目名称:wazapp,代码行数:70,代码来源:waxmpp.py

示例2: WAEventHandler

# 需要导入模块: from notifier import Notifier [as 别名]
# 或者: from notifier.Notifier import newMessage [as 别名]

#.........这里部分代码省略.........
		
	def networkDisconnected(self):
		self.sleeping.emit();
		self.conn.changeState(0);
		#thread.start_new_thread(self.conn.changeState, (0,))
		#self.conn.disconnect();
		print "NET SLEEPING"
		
	def networkUnavailable(self):
		self.disconnected.emit();
		print "NET UNAVAILABLE";
		
		
	def onUnavailable(self):
		print "SEND UNAVAILABLE"
		self.conn.sendUnavailable();
	
	
	def conversationOpened(self,jid):
		self.notifier.hideNotification(jid);
	
	def onAvailable(self):
		self.conn.sendAvailable();
	
	def send_message(self,to_id,msg_text):
		
		fmsg = WAXMPP.message_store.store.Message.create();
		conversation = WAXMPP.message_store.getOrCreateConversationByJid(to_id);
		fmsg.setData({"status":0,"content":msg_text.encode('utf-8'),"conversation_id":conversation.id,"type":1})
		WAXMPP.message_store.pushMessage(fmsg)
		
		self.conn.sendMessageWithBody(fmsg);
	
	def notificationClicked(self,jid):
		print "SHOW UI for "+jid
		self.showUI.emit(jid);

	def message_received(self,fmsg,duplicate = False):
		msg_type = "duplicate" if duplicate else "new";

		if fmsg.content is not None:
			#self.new_message.emit({"data":fmsg.content,"user_id":fmsg.getContact().jid})
			try:
				msg_contact = WAXMPP.message_store.store.getCachedContacts()[fmsg.getContact().number];
			except:
				msg_contact = WAXMPP.message_store.store.Contact.create()
				msg_contact.name= fmsg.getContact().number
				msg_contact.picture = WAConstants.DEFAULT_CONTACT_PICTURE
				msg_contact.jid = eval(fmsg.key.toString()).remote_jid
				
			
			self.notifier.newMessage(msg_contact.jid, msg_contact.name, fmsg.content,None if type(msg_contact.picture) == str else str(msg_contact.picture.path()),callback = self.notificationClicked);
			
			Utilities.debug("A {msg_type} message was received: {data}".format(msg_type=msg_type, data=fmsg.content));
		else:
			Utilities.debug("A {msg_type} message was received".format(msg_type=msg_type));

		if(fmsg.wantsReceipt):
			self.conn.sendMessageReceived(fmsg);

	
	def subjectReceiptRequested(self,to,idx):
		self.conn.sendSubjectReceived(to,idx);
		
		
			
	def presence_available_received(self,fromm):
		if(fromm == self.conn.jid):
			return
		self.available.emit(fromm)
		Utilities.debug("{Friend} is now available".format(Friend = fromm));
	
	def presence_unavailable_received(self,fromm):
		if(fromm == self.conn.jid):
			return
		self.unavailable.emit(fromm)
		Utilities.debug("{Friend} is now unavailable".format(Friend = fromm));
	
	def typing_received(self,fromm):
		Utilities.debug("{Friend} is typing ".format(Friend = fromm))
		self.typing.emit(fromm);

	def paused_received(self,fromm):
		Utilities.debug("{Friend} has stopped typing ".format(Friend = fromm))
		self.paused.emit(fromm);

	

	def message_error(self,fmsg,errorCode):
		Utilities.debug("Message Error {0}\n Error Code: {1}".format(fmsg,str(errorCode)));

	def message_status_update(self,fmsg):
		Utilities.debug("Message status updated {0}".format(fmsg.status));
		contact = fmsg.getContact();
		modelData = fmsg.getModelData();
		modelData["Contact"] = contact.getModelData();
		if fmsg.status == WAXMPP.message_store.store.Message.STATUS_SENT:
			self.messageSent.emit(modelData);
		elif fmsg.status == WAXMPP.message_store.store.Message.STATUS_DELIVERED:
			self.messageDelivered.emit(modelData); 
开发者ID:MichaelShaka,项目名称:wazapp,代码行数:104,代码来源:waxmpp.py


注:本文中的notifier.Notifier.newMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。