itchat監聽微信撤回訊息

2022-03-16 22:59:43 字數 1117 閱讀 8891

import

itchat

from itchat.content import *

import

remsg_infomation ={}

#監聽傳送訊息

@itchat.msg_register([text])

defhandle_receive_msg(msg):

print

(msg)

msg_from = itchat.search_friends(username=msg["

fromusername

"])["

nickname"]

print

(msg_from)

#獲取元素中需要的資訊

msg_time = msg["

createtime"]

msg_id = msg["

msgid"]

msg_content = msg["

text"]

#把訊息放入全域性字典當中

msg_infomation.update(})

print

(msg_infomation)

#監聽撤回訊息

@itchat.msg_register([note])

definfomation(msg):

print

(msg)

content = msg.get("

content")

print

(content)

if"撤回了一條訊息"in

content:

print(1, content)

old_msg_id = re.search("

(.*?)

", msg["

content

"]).group(1)

print

(old_msg_id)

print

(msg_infomation.get(old_msg_id))

#itchat.auto_login(hotreload=true)

#保證程式一直執行

itchat.run()

#課後作業:把未完成的完成

itchat 監控微信好友撤回訊息

coding utf 8 import itchat from itchat.content import text from itchat.content import import sys import time import re import importlib import os impo...

itchat微信多開

所以在使用itchat的過程中,只能登陸手機,而不能登陸pc版 今天在itchat的 上看到了 使用者多開 的字眼,以為是能夠共存,測試發現不是 如下 import itchat newinstance itchat.new instance newinstance.auto login hotre...

python實現檢視微信訊息撤回

娛樂 windows系統 2.安裝成功之後,進入pip3.exe所在的目錄 安裝itchat pip3.exe install itchat 下圖我的已經安裝過了 注意 使用3以及以上版本執行 3.開啟cmd拖入按回車就好了 建乙個wx.py檔案,以下 匯入 encoding utf 8 impor...