Posted in Python onAugust 22, 2019
本文实例讲述了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程序设计有所帮助。
Python实现的微信红包提醒功能示例
- Author -
zhizunyu2009声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@