XZZ/worker/wolfram.py

21 lines
609 B
Python
Raw Permalink Normal View History

2020-03-02 14:17:30 +08:00
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:
2021-01-27 11:33:32 +08:00
res = wolframsearch(self.raw_msg['raw_message'][9:])
2020-03-02 14:17:30 +08:00
msg = next(res.results).text
except Exception as e:
print(e)
msg = '什么东西坏掉了,大概是Wolfram | Alpha吧...不可能是咱!'
2020-03-02 14:20:28 +08:00
return msg