Current location - Quotes Website - Collection of slogans - Wechat message was withdrawn, invisible? Teach you a trick to prevent abstinence
Wechat message was withdrawn, invisible? Teach you a trick to prevent abstinence
Wechat is a social software launched by Tencent on 20 1,1and 2 1. In eight years, WeChat has achieved 1 100 million daily activities and 45 billion daily news. During this period, WeChat also launched many functions such as "shake", "drift bottle", "circle of friends", "people nearby", "public platform" and "applet", covering all aspects of our lives. Wechat is slowly practicing their slogan: Wechat is a way of life.

The iteration of product update is bound to be accompanied by the online and offline functions. What I want to talk about today is a small new function launched by WeChat on 20 14: withdrawing messages makes users feel refreshed, but users may scratch their heads and know what you have withdrawn. This is the so-called curiosity kills the cat. Today, we will use Python.

We hope that when friends or people in the group withdraw the message, they can forward the original message and sender information to the file assistant as soon as possible (of course, you can also send the message back to him, haha) for our convenience.

Let me show you the functions implemented.

Let's first understand the principle of WeChat withdrawing messages:

Brother pig will show you the difference between the normal message and the content of the withdrawn message: normal message: content =' hello Sao', please pay attention to MsgId='8784390488772995470'

Recall message: The content is a content string in xml format.

Let's format it.

Analyzing the content fields extracted above, we find that

According to the content of the normal message and the recall message, we found that the recall message will contain the msgid of the previously recalled message, so we only need to find the previous message, and the wxpy module caches the latest 200 messages for us by default, so we only need to traverse these historical messages and compare the msgid to find the recalled message!

If your WeChat messages are too frequent, and the number of messages exceeds 200 in 2 minutes, you can set the max_history higher.

I also understand the principle, and the news of being withdrawn has been found. I just need to forward the message in the last step. If you have played wxpy before, you will. You only need one line of code to forward the mail:

After the principle and process are finished, the code is posted for everyone to see, and the comments are still relatively detailed. You can ask me in the study group if you don't understand.

Wechat message anti-fallback function is simple to implement, but it is very practical. At present, the only drawback of this project is poor usability. Simply put, we haven't deployed the project to the server yet, and we have to turn on the computer every time we use it. In the future, we can consider deploying the project to a cloud server or packaging it as apk, which will be very convenient to use, and we can also send apk to our friends to let them experience this function!

Engineering documents can be obtained by private letter.