Embarrassed talking robot

Itchat use API to build a robot and Turing embarrassed talking robot

itchat

itchat is written in python, a library of the micro-channel web client API package.

Use of specific methods can refer to the official tutorial: itchat

The official Github Address:
itchat

itchat installation fool the steps of:
pip3 install itchat

Turing robot

图灵,这位伟大的任务,我们都知道,判断和你对话的是人还是机器人的第一关就是反复问他同一个问题,也就是我们所熟悉的图灵测试.当然,现在为止,还没有能通过图灵测试的机器.

今天我们需要用到的,图灵机器人是一家以语义和对话技术为核心的人工智能公司在人工智能机器人领域拥有数百项核心专利

To use his API, first of all, we have to register an account, called by apikey obtained.

> Turing robot's official website tuling

Interface address api

Most are official guidance on the source code, I added just a few of logic.

My robot is run on the tree plum pie I have 24 * 7, so I will define this function robot in order:

1.机器人的工作时间段为:08:00--22:00
2.只接收文本内容,图片,链接,视频等不做处理,交 由你回复

The second well to achieve, you can only sign up for a TEXT message.

Article:

1. Import time module, determines whether the current time is 22:00. If at the exit program

'''
localtime = time.localtime(time.time())
    if localtime[3] >= 22:
        itchat.logout()
'''

2. 8:00 every day to run the program, use the linux routine work schedule

$crontab -e

Execute the command, add a task

0 8 * * * python3 AI_TL.py

The most important thing is, micro-channel web log on through the end of scan code is done, we passed itchat.auto_login (hotReload = True), but in a very short period of time, do not need to re-login scan code, so we also need to get qrcode

Here, I use python's smtplib, to be generated qrcode by mail, sent to my mailbox, I'll be able to log in through a micro-channel remote way. However, micro-letter code scan can only be scanned by way of the camera is turned on, so you may have to send qrcode to the person next to you, oh.

I put the code on github of the
https://github.com/dmzlingyin/python_project/tree/master/ichat

The source code is AI_TL.py & fj_mail.py

Guess you like

Origin blog.csdn.net/weixin_37731316/article/details/89442119