In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to achieve an anti-withdrawal function of Wechat in Python. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Without saying much, let's take a look at it with the editor.
1. The implementation principle of Wechat withdrawing message
Let's first take a look at how Wechat withdraws messages:
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 withdrew a message". Then the append of the other side receives the message and parses it, replacing the original message and changing the display style.
Let me show you the difference between the contents of a normal message and a withdrawn message:
Normal news: Content=', you are so slutty. 'everybody pay attention to MsgId='8784390488772995470'.
Recall message: Content is a string of content in xml format
Let's format it below.
Xxxsession >
1090336364oldmsgid >
8784390488772995470msgid >
Replacemsg >
Revokemsg > sysmsg >
By analyzing the Content field recalled above, we find that the id of 8784390488772995470 is the same as the id we sent before, and this tag verifies our conjecture that the original message is indeed replaced with a new message.
two。 Find the recalled message
According to the contents of crawling normal messages and withdrawing messages, we find the rule: the recall message will contain the msgid of the previously recalled message, then we just need to find the previous message, while the wxpy module defaults to that we have cached the last 200 messages, so we just need to traverse these historical messages and compare msgid to find the recalled message!
If your Wechat messages are too frequent and the number of messages exceeds 200 within 2 minutes, you can set the max_history to be larger.
3. Forward recalled messages
The principle is understood, and the withdrawn message is also found. The last step is to forward the message. If you have played wxpy before, you will surely do it. You can forward the message with just one line of code:
Msg.forward (bot.file_helper) 4. Code
When the principle and process are finished, the code will be posted to show you. The comments are still more detailed. If you don't know what to say, you can ask me in the study group.
The above is how to achieve a Wechat anti-withdrawal function in Python. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.