Revocation message to collect micro-channel

The principle is to run on a computer, linked to the micro-letter web version, you receive a message before the message prompt withdrawal'll keep local 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()

 

Published 109 original articles · won praise 23 · Views 300,000 +

Guess you like

Origin blog.csdn.net/qq_32394351/article/details/103747723