add wolfram

This commit is contained in:
SiHuan 2020-03-02 14:17:30 +08:00
parent 95fcae5d5a
commit 663f3f4576
4 changed files with 33 additions and 1 deletions

View file

@ -1,19 +1,28 @@
astroid==2.3.3 astroid==2.3.3
autopep8==1.5
certifi==2019.11.28 certifi==2019.11.28
chardet==3.0.4 chardet==3.0.4
Click==7.0 Click==7.0
Flask==1.1.1 Flask==1.1.1
idna==2.9 idna==2.9
importlib-metadata==1.5.0
inflect==4.1.0
isort==4.3.21 isort==4.3.21
itsdangerous==1.1.0 itsdangerous==1.1.0
jaraco.itertools==5.0.0
Jinja2==2.11.1 Jinja2==2.11.1
lazy-object-proxy==1.4.3 lazy-object-proxy==1.4.3
MarkupSafe==1.1.1 MarkupSafe==1.1.1
mccabe==0.6.1 mccabe==0.6.1
more-itertools==8.2.0
pycodestyle==2.5.0
pylint==2.4.4 pylint==2.4.4
requests==2.23.0 requests==2.23.0
six==1.14.0 six==1.14.0
typed-ast==1.4.1 typed-ast==1.4.1
urllib3==1.25.8 urllib3==1.25.8
Werkzeug==1.0.0 Werkzeug==1.0.0
wolframalpha==4.0.0
wrapt==1.11.2 wrapt==1.11.2
xmltodict==0.12.0
zipp==3.0.0

View file

@ -5,6 +5,8 @@ def ZZRouter(data):
gid = data['group_id'] gid = data['group_id']
role = data['sender']['role'] role = data['sender']['role']
parms = str.split(data['message'][1:]) parms = str.split(data['message'][1:])
if not parms:
parms[0] = 'help'
worker = parms[0] worker = parms[0]
try: try:

View file

@ -1,5 +1,5 @@
from worker import emmm from worker import emmm
debug = False debug = True
def de(e): def de(e):
if debug: if debug:

21
worker/wolfram.py Normal file
View file

@ -0,0 +1,21 @@
from zzcore import StdAns
from config import WOLFRAMALPHAAPPID
import wolframalpha
def wolframsearch(query):
client = wolframalpha.Client(WOLFRAMALPHAAPPID)
res = client.query(query)
return res
class Ans(StdAns):
def GETMSG(self):
if len(self.parms) < 2:
return '不加参数是坏文明!'
try:
res = wolframsearch(self.raw_msg['message'][9:])
msg = next(res.results).text
except Exception as e:
print(e)
msg = '什么东西坏掉了,大概是Wolfram | Alpha吧...不可能是咱!'
return