preface

Do you remember when teaching parents to use wechat? After parents learn, our life has undergone “quality” change, parents may ridicule your wechat profile picture is not good, want you to change a profile picture.

Recently PK brother was teased by his mother, the reason is that relatives in the wechat group some relatives birthday, in the group did not say happy birthday, teased me impolite. This group of perennial small programs, so naturally is set to do not disturb the state, who is staring at this group every day ah, elders talk about the topic we can not interrupt the words. I’m going to be forced to develop a gadget again, just do it, 10 lines of code to make a keyword auto-reply or a reminder.

The premise

The premise that this small tool can be used is that your wechat can log in to wechat web version, because the WXpy library used this time will call wechat web version interface.

I also used wXPY library to make wechat automatic chat robot before

Reply to fixed messages based on keywords

First of all, we make a key word that can identify the chat of group members in a certain group to reply to the corresponding blessing message. For example, when the keyword related to “birthday” appears in the group message, it will automatically reply to the blessing words like “happy birthday”.

Show you code directly:

If you have more than one group to reply to, you can put the group names in the list like I did above, and do a for loop.

After the code runs, the assistant will automatically reply to the group chat if the keyword you defined appears.

Reply random messages based on keywords

Every time the reply is fixed message is easy to be detected, we can do several sets of words, and then choose a random reply.

I simply wrote 3 sets of words, you can write more according to their literary talent, so that the probability of repetition is low, ha ha.

Send pictures of blessings

In addition to sending text blessings, of course, you can send some “sand sculpture” blessing pictures. Just don’t name the pictures in Chinese and put them in the same directory as the code.

In this way, the picture and text can be sent out.

Send a reminder message to the File Transfer assistant

You can also remind yourself if you feel that the auto-reply above is not sincere. When a keyword appears in a group chat message, an alert message is sent to the file Transfer assistant.

When a keyword appears in a group, your file Transfer assistant will be alerted.

Keywords to other you need, you can make other reminder of the small assistant, not afraid of missing any information, great.

Finally, put the code in, run the code, automatic reply to a small assistant 24 hours online service, not flattered.

I put the code of the four versions of this article on GitHub, in my public account background input box reply “small assistant” to obtain the source code.