Python 实现微信防撤回功能

通过Python实现微信消息防撤回功能,无需手机root,只需登录网页版微信。文章介绍了所需环境、关键代码及运行步骤,帮助读者理解并实现该功能。
摘要由CSDN通过智能技术生成

在微信上突然看到“XXX撤回一条消息”的时候,心里痒不痒?现在就教你如何实现消息防撤回的功能。不限手机型号、手机无需root,只要微信号可以登上网页版就可以了(部分不常用和新申请的账号会登不上网页版)。

环境

Centos7
python2.7
itchat

代码


    # 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
    msg_information = {
   }
    face_bug = None # 针对表情包的内容
    @itchat.msg_register([TEXT, PICTURE, FRIENDS, CARD, MAP, SHARING, RECORDING, ATTACHMENT, VIDEO], isFriendChat=True,
       isMpChat=True)
    def handle_receive_msg(msg):
     global face_bug
     msg_time_rec = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # 接受消息的时间
     msg_from = itchat.search_friends(userName=msg['FromUserName'])['NickName'] # 在好友列表中查询发送信息的好友昵称
     msg_time = msg['CreateTime'] # 信息发送的时间
     msg_id = msg['MsgId'] # 每条信息的id
     msg_content = None # 储存信息的内容
     msg_share_url = None # 储存分享的链接,比如分享的文章和音乐
     print msg['Type']
     print msg['MsgId']
     if msg['Type'] == 'Text' or msg['Type'] == 'Friends': # 如果发送的消息是文本或者好友推荐
     msg_content = msg['Text']
     print msg_content
     # 如果发送的消息是附件、视屏、图片、语音
     elif msg['Type'] == "Attachment" or msg['Type'] == "Video" \
      or msg['Type'] == 'Picture' \
      or msg['Type'] == 'Recording':
     msg_content = msg['FileName'] # 内容就是他们的文件名
     msg['Text'](str(msg_content)) # 下载文件
     # print msg_content
     elif msg['Type'] == 'Card': # 如果消息是推荐的名片
     msg_content = msg['RecommendInfo']['NickName'] + '的名片' # 内容就是推荐人的昵称和性别
     if msg['RecommendInfo']['Sex'] == 1:
      msg_content += '性别为男'
     else:
      msg_content += '性别为女'
     print msg_content
     elif msg['Type'] == 'Map': # 如果消息为分享的位置信息
     x, y, location 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值