Joke Collection Website - Cold jokes - How to make your WeChat automatically reply jokes to friends?
How to make your WeChat automatically reply jokes to friends?
actually, the implementation is very simple, and it can be realized in more than 3 lines of code. The following are the implementation steps:
Step 1: Install itchat. There are many installation methods, and I choose pip installation:
$ pip install itchat
Step 2: load the paragraph content crawled by the crawler a few days ago into a list. My file for saving paragraphs is like this:
Remove the information such as author fun through string functions such as python's split, and only save the content in the list. The code implementation is very simple:
Step 3, make an interface that returns a paragraph randomly:
Step 4, register the function that handles WeChat text reply. All messages sent by friends will be processed by the following text_reply function:
Step 5, realize keyword reply. If your friend sends a message with a "joke" keyword, randomly reply a paragraph:
Step 6, realize the main function: initialize the paragraph list, realize WeChat login and detect WeChat events:
After the above steps are completed, run funRobots.py A QR code will pop up, scan the QR code with your WeChat, and then when a friend sends you a message with the keyword "joke", your WeChat will automatically reply to the other party with a joke. Is it interesting?
The following is the result of automatic reply from WeChat after I sent a message to myself after the above operation:
Isn't it interesting? The crawler I learned some time ago finally came in handy. Python is very powerful and interesting.
Finally, paste the complete source code:
The above is just a small example, and it is also possible to use other languages after mastering the principle. Throw a brick to attract jade here, and everyone can cooperate with reptiles to expand more functions at will.
- Previous article:How hostile do you think the world is to fat girls?
- Next article:Enlightenment from three cases of college students' efforts to succeed
- Related articles
- What should I do if there is a booing among primary school students? You can't hit them again, hey
- I want to commit suicide, but I'm afraid I'm sorry for my parents and children, and I'm afraid I'll make others laugh. What should I do?
- A metaphor for a dream that cannot be realized at all
- Billions of dollars were lost due to power failure. What are the major impacts of the blackout in Taiwan Province Province?
- What does the crow mean by laughing at pig black?
- Voice control, changan CS35 PLUS turns into your personal assistant and bosom friend.
- Sob is an asshole. Does anyone have this strategy?
- Help find riddles and jokes about hard work.
- What kind of plant is Buddha snail bodhi?
- Who is this person who makes others cry, or makes others feel that they are low, but they feel high?