From 64cd37d01e23afa2a31aa9f2e19c441888d5b05d Mon Sep 17 00:00:00 2001 From: xmengnet <51263043+xmengnet@users.noreply.github.com> Date: Thu, 22 Apr 2021 10:13:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=80=E5=8D=95=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worker/hello.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 worker/hello.py diff --git a/worker/hello.py b/worker/hello.py new file mode 100644 index 0000000..6bf61c8 --- /dev/null +++ b/worker/hello.py @@ -0,0 +1,20 @@ +from zzcore import StdAns +import requests + +class Ans(StdAns): + def GETMSG(self): + if len(self.parms) < 2: + return '你好啊!我是小智障机器人,你现在可以使用/hello 你想说的话 跟我聊天!' + question=self.raw_msg['raw_message'][6:] + # print(question) + quest=self.raw_msg['sender']['nickname'] + # print(quest) + key='9c0f6f69aa395bad36a0e797ed44189f' + url=f'http://api.tianapi.com/txapi/robot/index?key={key}&question={question}&uniqueid={quest}&mode=1' + reply=requests.get(url).json() + msg='' + if(reply['code']==200): + msg+=reply['newslist'][0]['reply'] + else: + msg+='不想和你说话!' + return msg