2020-08-03 15:28:59 +08:00
|
|
|
|
from zzcore import StdAns, mysakuya
|
|
|
|
|
import requests
|
|
|
|
|
|
2021-05-06 20:35:46 +08:00
|
|
|
|
from config import LOLIKEY
|
2020-08-03 15:28:59 +08:00
|
|
|
|
|
2020-10-30 10:13:44 +08:00
|
|
|
|
|
2020-08-03 15:28:59 +08:00
|
|
|
|
class Ans(StdAns):
|
2021-05-06 20:35:46 +08:00
|
|
|
|
AllowGroup = [959613860, 973510746, 805197917, 343700338, 125733077, 1084566280,
|
2021-06-14 13:35:00 +08:00
|
|
|
|
920863253, 798595664, 655057127, 196268763, 247022495, 474907856, 940333876,
|
2021-08-08 17:20:28 +08:00
|
|
|
|
204097403,138966354]
|
2020-10-30 10:13:44 +08:00
|
|
|
|
|
2020-08-03 15:28:59 +08:00
|
|
|
|
def GETMSG(self):
|
2021-05-06 20:35:46 +08:00
|
|
|
|
if len(self.parms) == 1:
|
|
|
|
|
code, picurl = getsetu()
|
2020-08-03 15:28:59 +08:00
|
|
|
|
else:
|
|
|
|
|
keyword = self.parms[1]
|
|
|
|
|
if mysakuya(self, keyword) == False:
|
|
|
|
|
return "不许你们看咲夜的涩图!!"
|
2021-05-06 20:38:45 +08:00
|
|
|
|
code, picurl = getsetu(keyword)
|
2021-05-06 20:35:46 +08:00
|
|
|
|
if code == 0:
|
|
|
|
|
return f'[CQ:reply,id={self.mid}][CQ:image,file={picurl},type=flash]'
|
|
|
|
|
else:
|
|
|
|
|
return f'[CQ:reply,id={self.mid}] 什么东西出错了,code:{code}'
|
2020-10-30 10:13:44 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-06 20:35:46 +08:00
|
|
|
|
def getsetu(keyword=''):
|
2020-08-17 10:40:46 +08:00
|
|
|
|
url = 'https://api.lolicon.app/setu/'
|
|
|
|
|
params = {
|
2021-05-06 20:35:46 +08:00
|
|
|
|
'apikey': LOLIKEY,
|
|
|
|
|
'keyword': keyword,
|
2020-08-17 10:40:46 +08:00
|
|
|
|
}
|
2020-10-30 10:13:44 +08:00
|
|
|
|
|
2020-08-17 10:40:46 +08:00
|
|
|
|
try:
|
2021-05-06 20:35:46 +08:00
|
|
|
|
resp = requests.get(url=url, params=params, timeout=5).json()
|
2020-08-17 10:40:46 +08:00
|
|
|
|
except:
|
2021-05-06 20:35:46 +08:00
|
|
|
|
return 500, ''
|
2020-10-30 10:13:44 +08:00
|
|
|
|
|
2021-05-06 20:35:46 +08:00
|
|
|
|
picurl = ''
|
2020-08-17 10:40:46 +08:00
|
|
|
|
if resp['code'] == 0:
|
2021-05-06 20:35:46 +08:00
|
|
|
|
picurl = "https://r.zjuyk.site/" + resp['data'][0]['url']
|
|
|
|
|
|
|
|
|
|
return resp['code'], picurl
|