XZZ/worker/pixiv.py

34 lines
1.1 KiB
Python
Raw Normal View History

2020-03-16 16:47:54 +08:00
from zzcore import StdAns
import requests
2020-03-17 14:20:21 +08:00
from config import LOLIKEY
2020-03-16 16:47:54 +08:00
class Ans(StdAns):
2020-05-08 18:08:37 +08:00
AllowGroup = [805197917,959613860,343700338,125733077,1084566280,920863253]
2020-03-16 16:47:54 +08:00
def GETMSG(self):
url = 'https://api.lolicon.app/setu/'
params = {
2020-03-17 14:20:21 +08:00
'apikey': LOLIKEY,
2020-03-16 16:47:54 +08:00
}
if len(self.parms) < 2:
try:
resp = requests.get(url=url,params=params).json()
picurl = resp['data'][0]['url']
msg = picurl
except Exception as e:
print(e)
msg = '什么东西坏掉了,大概是Pixiv吧...不可能是咱!'
return msg
else:
keyword = self.raw_msg['message'][7:]
params['keyword'] = keyword
try:
resp = requests.get(url=url,params=params).json()
picurl = resp['data'][0]['url']
msg = picurl
except Exception as e:
print(e)
msg = '咱没查到也有可能是Pixiv坏掉了'
return msg