前言
曾经有一份很大的红包,摆在我的面前,我没有好好珍惜,如果上天再给我一次机会,我会对发红包的人说三个字:再来个!
今天小编就教大家一个小小的Python黑科技,这样再也不用担心,抢不到红包啦~~~
1、微信红包自动提醒
2、可实现模拟点击自动抢红包
3、查看撤回消息
版本:Python3.6
系统:Windows
相关模块:itchat
查看撤回消息
红包提醒
import os
import re
import shutil
import time
import itchat
from itchat.content import *
'''
想要学习Python?Python学习交流群:683380553满足你的需求,资料都已经上传群文件流,可以自行下载!
'''
msg_dict = {}
rev_tmp_dir = "E:\文章\新建文件夹"
if not os.path.exists(rev_tmp_dir): os.mkdir(rev_tmp_dir)
face_bug = None
@itchat.msg_register([TEXT, PICTURE, MAP, CARD, SHARING, RECORDING, ATTACHMENT, VIDEO])
def handler_receive_msg(msg):
global face_bug
msg_time_rec = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
msg_id = msg['MsgId']
msg_time = msg['CreateTime']
msg_from = (itchat.search_friends(userName=msg['FromUserName']))["NickName"]
msg_content = None
msg_share_url = None
if msg['Type'] == 'Text' \
or msg['Type'] == 'Friends':
msg_content = msg['Text']
elif msg['Type'] == 'Recording' \
or msg['Type'] == 'Attachment' \
or msg['Type'] == 'Video' \
or msg['Type'] == 'Picture':
msg_content = r"" + msg['FileName']
msg['Text'](rev_tmp_dir + msg['FileName'])
elif msg['Type'] == 'Card':
msg_content = msg['RecommendInfo']['NickName'] + r" 的名片"
elif msg['Type'] == 'Map':
x, y, location = re.search(
", msg['OriContent']).group(1, 2, 3)
if location is None:
msg_content = r"纬度->" + x.__str__() + " 经度->" + y.__str__()
else:
msg_content = r"" + location
elif msg['Type'] == 'Sharing':
msg_content = msg['Text']
msg_share_url = msg['Url']
face_bug = msg_content
msg_dict.update(
{
msg_id: {
"msg_from": msg_from, "msg_time": msg_time, "msg_time_rec": msg_time_rec,
"msg_type": msg["Type"],
"msg_content": msg_content, "msg_share_url": msg_share_url
}
}
)
@itchat.msg_register([NOTE])
def send_msg_helper(msg):
global face_bug
if re.search(r"\", msg['Content']) is not None:
old_msg_id = re.search("\(.*?)\", msg['Content']).group(1)
old_msg = msg_dict.get(old_msg_id, {})
if