學習了一下如何用python實現微信消息的防撤回,
主要思路就是:
- 時時監控微信,將對方發送的消息緩存下來
- 如果對方撤回了消息,就將該緩存信息發送給文件傳輸助手
但其實這功能,基本上毫無意義,看到別人錯發的消息除了滿足一下獵奇心,而且還是短暫的獵奇心,真的沒什么卵用,除非你有其他目的。學習這個也基本上是浪費時間。
所以我也只是把最常見的文字類消息實現了一下防撤回,其余的類型基本如法炮制即可。
代碼如下:
1 import itchat 2 from itchat.content import TEXT, NOTE 3 4 5 itchat.auto_login(hotReload=True) 6 7 types = None 8 info = None 9 name = None 10 11 12 @itchat.msg_register([TEXT]) 13 def receive_info(msg): 14 global types 15 global info 16 global name 17 name = msg['FileName'] 18 types = msg["Type"] 19 info = msg["Text"] 20 21 22 @itchat.msg_register(NOTE) 23 def withdraw_info(withdraw_msg): 24 if "撤回了一條消息" in withdraw_msg["Text"]: 25 if types == "Text": 26 itchat.send(msg=withdraw_msg["Text"] + 27 ':' + info, toUserName="filehelper") 28 29 30 itchat.run()