2020-02-28 22:58:14 +08:00
|
|
|
from zzcore import StdAns
|
|
|
|
from config import BINGKEY
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
class Ans(StdAns):
|
|
|
|
def GETMSG(self):
|
|
|
|
if len(self.parms) < 2:
|
|
|
|
return '不加参数是坏文明!'
|
|
|
|
|
|
|
|
url = 'https://api.cognitive.microsoft.com/bing/v7.0/search'
|
|
|
|
params = {
|
2021-01-27 11:33:32 +08:00
|
|
|
'q':self.raw_msg['raw_message'][5:],
|
2020-02-28 22:58:14 +08:00
|
|
|
'count': 1,
|
2020-08-21 11:20:27 +08:00
|
|
|
'mkt': 'zh-CN'
|
2020-02-28 22:58:14 +08:00
|
|
|
}
|
|
|
|
headers = {
|
|
|
|
'Ocp-Apim-Subscription-Key': BINGKEY,
|
|
|
|
}
|
|
|
|
try:
|
|
|
|
resp = requests.get(url=url,params=params,headers=headers).json()
|
|
|
|
result = resp['webPages']['value'][0]
|
2020-03-01 20:48:36 +08:00
|
|
|
msg = '[CQ:at,qq=' + str(self.uid) + ']' + '咱帮你🔍到了这个\n' + result['name']+'\n ' + result['snippet']
|
2020-03-01 20:37:28 +08:00
|
|
|
self.sendmsg(msg)
|
2020-03-01 20:48:36 +08:00
|
|
|
msg = result['url']
|
2020-02-28 22:58:14 +08:00
|
|
|
except:
|
|
|
|
msg = '什么东西坏掉了,大概是bing吧...不可能是咱!'
|
|
|
|
return msg
|