Get the App
SLTechnology News&Howtos  ›  Development  › 

How to grab the red packet and remind the assistant by Python

Shulou Source: shulou.com Published: 2022-06-02 12:48:06 10月02日 Update

This article mainly explains "Python how to grab red packets to remind assistants", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Python how to grab red packets to remind assistants" bar!

1. Install the library

Pip install wxpy

2. Start the group monitoring robot

Start a simple wxpy robot, which is only about 10 lines short. It is very simple. After we have installed wxpy, we can type the following code

After running, a QR code scanning window will pop up, and you can log in with a scan of Wechat (note, it must be a certified WeChat account), and then you will see the interface below, indicating that the login is successful.

3. Explain several key parameters

For students who are not familiar with wxpy, you can search the wxpy usage documentation. We will use the class msg in the process of writing code. For example, msg.chat returns the name of the group chat group, msg.member returns the group member, and msg.type returns text.

Here is a brief description of several parameters of type

We pay more attention to the text and prompts, because the red packet is the prompt message, and the text is our ordinary chat content.

4. How to send a reminder of grabbing red packets

There are mainly several different implementation methods in Python

To make a sound, you need to call the system interface. Windows and Mac have different implementation methods. If you want to make a fuss, you can also play MP3 through pygame.

Of course, to make the project interesting, you can add a pop-up reminder:

Import tkinter.messagebox tkinter.messagebox.showinfo ('important reminder', 'someone has given out red packets!')

5. Monitoring individuals and monitoring groups are very similar.

Take monitoring individuals as an example, the code is as follows:

6. Result display

Thank you for your reading, the above is the content of "Python how to grab red packets to remind assistants". After the study of this article, I believe you have a deeper understanding of how to grab red packets to remind assistants of Python, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Red packet assistant monitoring code content that is learning different personal parameter text method machine robot face prompt ordinary gaudy important successful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Information Huawei MariaDB Shulou Tech Info