WeChat （WeChat） It's Tencent 2011 year 1 month 21 A social software launched on July ,8 Year time wechat to achieve daily life 10 Billion , Daily News 450 Billion . During this period, wechat also launched many functions such as ：“ shake ”、“ Drift bottle ”、“ Circle of friends ”、“ The man near the ”、“ Public platform ”、“ Applet ” wait , It covers all aspects of our lives , Wechat is slowly practicing their slogan ： WeChat , It's a way of life
The product update iteration is bound to be accompanied by the function launch and offline , Today we are going to talk about wechat in 2014 A small new feature introduced in ：
Withdraw message , Use this function to refresh your mind 、 Refreshed , But the person being applied may scratch his ears and face 、 Gnash your teeth to know what you've withdrawn , That's what's called Curiosity Kills cats （Curiosity kills the cat）, We'll use it today Python Realize the withdrawal of anti wechat messages , Satisfy your curiosity ！
We hope that when a friend or group member withdraws a message , The first time I can get the original news 、 The sender information is forwarded to the file assistant ( Of course, you can send the news back to him , ha-ha ), This is convenient for us to check .
Let's demonstrate the function of the implementation .
Let's first understand the principle of wechat message withdrawal ：
In fact, the principle of wechat withdrawal message is that when the operator clicks to withdraw , The client will automatically send a system message ：“xxx Recalled a message ”, And then the other side app After receiving the message, parse , Replace the original message , Change the display style
Brother pig will show you
Normal news and
Withdraw message What is the difference between the contents of ：
Normal news ：
Content=' You are sexy! ', Pay attention to
Withdraw message ：Content It's a bunch of xml Content of format
Let's format it below
<sysmsg type="revokemsg"> <revokemsg> <session>xxx</session> <oldmsgid>1090336364</oldmsgid> <msgid>8784390488772995470</msgid> <replacemsg><![CDATA[" Pig brother " Recalled a message ]]></replacemsg> </revokemsg> </sysmsg>
Analyze the... Withdrawn above
Content Field we found
<msgid>8784390488772995470</msgid> Of id With the message we sent before id It's consistent , and
<replacemsg> This label also confirms my conjecture , It's really replacing the original message with the new one .
According to the grab
Normal news and
Withdraw message We found the rules ： The recall message will contain the previously recalled message
msgid, Then we just need to find the news before , and
wxpy By default, the module caches the latest 200 Bar message , So all we have to do is go through the historical messages and compare
msgid You can find the message that was withdrawn ！
If you have too many wechat messages ,2 The number of messages exceeds in minutes 200, Then you can put
max_history Set it up bigger .
The principle is understood , The news of the withdrawal was also found , Just one last step to forward the message , If you've played before
wxpy Certainly , Just one line of code can forward messages ：
The principle and process are finished , Post the code for you to see , The notes are more detailed , If you don't know something, you can ask me .
Simple implementation of wechat message anti withdrawal function , But it 's very practical , The only drawback of the current project is its poor usability , In short, we haven't deployed the project server yet , Every time you use it, you have to turn on the computer and run it all the time , Brother pig considers to deploy the project on the cloud server or package it into apk, It's very convenient to use , And you can put apk Send it to a friend , Let friends experience this function ！
Learn this , Don't be curious about what the other party has withdrawn , Try downloading the project ！ After downloading the project, you can run it directly without modifying the code ！
Like to pay attention to brother pig ~