微信收集撤回消息

原理是电脑上运行,挂web版微信,收到撤回消息提示就把之前的消息存本地txt 

import os
from itchat.content import *
import itchat


info = None
friend_id = None
info_type = None
name = None
cot = None
rev_tmp_dir = '微信撤回的消息/'
if not os.path.exists(rev_tmp_dir):
    os.mkdir(rev_tmp_dir)
itchat.login()


@itchat.msg_register([TEXT,RECORDING,PICTURE])
def resever_info(msg):
    global info
    global friend_id
    global info_type
    global name
    name = msg['FileName']
    info_type = msg['Type']
    info = msg['Text']
    friend_id = msg['FromUserName']
    print(msg)
    print(info)


@itchat.msg_register(NOTE)
def chehui_info(chehui_msg):
    global info
    global friend_id
    global name

    print(chehui_msg)
    if '撤回了一条消息' in chehui_msg['Text']:
        if info_type == 'Text':
            with open(rev_tmp_dir+"文本撤回.txt",'a') as f:
                f.write(info+'\n')
            itchat.send(msg=chehui_msg['Text'] + ":" + info, toUserName=friend_id)
        elif info_type == 'Recording':
            info(rev_tmp_dir + name)
            file = '@fil@%s' % (rev_tmp_dir + name)
            itchat.send(msg=chehui_msg['Text']+":", toUserName='friend_id')
            itchat.send(msg=file, toUserName='filehelper')
        elif info_type == 'Picture':
            info(rev_tmp_dir + name)
            file = '@fil@%s' % (rev_tmp_dir + name)
            itchat.send(msg=chehui_msg['Text']+":", toUserName='friend_id')
            itchat.send(msg=file, toUserName='filehelper')


itchat.run()

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值