Python实现的微信红包提醒功能示例
人气:0本文实例讲述了Python实现的微信红包提醒功能。分享给大家供大家参考,具体如下:
#coding=utf-8 import itchat from itchat.content import TEXT from itchat.content import * import sys import time import re reload(sys) sys.setdefaultencoding('utf8') import os @itchat.msg_register(NOTE,isGroupChat=True)#监听群内红包消息 def receive_red_packet(msg): if u"收到红包" in msg['Content']: groups = itchat.get_chatrooms(update=True) users = itchat.search_chatrooms(name=u'Happy一家人')#把红包消息通知给这个群 userName = users[0]['UserName']#获取这个群的唯一标示 for g in groups: if msg['FromUserName'] == g['UserName']:#根据群消息的FromUserName匹配是哪个群 group_name = g['NickName'] msgbody = u'有人在群"%s"发了红包,请立即打电话给我,让我去抢'%group_name itchat.send(msgbody,toUserName=userName) #告诉指定的好友群内有红包 itchat.auto_login(hotReload=True) itchat.run()
希望本文所述对大家Python程序设计有所帮助。
您可能感兴趣的文章:
加载全部内容