zzcore add mid && update lsp to support more key
This commit is contained in:
parent
a58e1954b7
commit
76a0548dea
4 changed files with 70 additions and 38 deletions
3
route.py
3
route.py
|
@ -8,6 +8,7 @@ def ZZRouter(data):
|
||||||
uid = data['user_id']
|
uid = data['user_id']
|
||||||
gid = data['group_id']
|
gid = data['group_id']
|
||||||
role = data['sender']['role']
|
role = data['sender']['role']
|
||||||
|
mid = data['message_id']
|
||||||
parms = str.split(data['message'][1:])
|
parms = str.split(data['message'][1:])
|
||||||
print(uid, gid, role, parms)
|
print(uid, gid, role, parms)
|
||||||
if parms == []:
|
if parms == []:
|
||||||
|
@ -20,7 +21,7 @@ def ZZRouter(data):
|
||||||
except:
|
except:
|
||||||
Ans_ = emmm.Ans
|
Ans_ = emmm.Ans
|
||||||
|
|
||||||
Ans = Ans_(parms, uid, gid, role, data)
|
Ans = Ans_(parms, uid, gid, role, mid, data)
|
||||||
Message = Ans.CheckPermission()
|
Message = Ans.CheckPermission()
|
||||||
if Message == 0:
|
if Message == 0:
|
||||||
Message = Ans.GETMSG()
|
Message = Ans.GETMSG()
|
||||||
|
|
4
test.py
4
test.py
|
@ -19,9 +19,9 @@ while(inp):
|
||||||
Ans_ = emmm.Ans
|
Ans_ = emmm.Ans
|
||||||
de(Ans_)
|
de(Ans_)
|
||||||
try:
|
try:
|
||||||
Ans = Ans_(parms,uid=0,gid=0,role='owner',raw_msg={'message':'/' + inp, 'message_id' : '1001'})
|
Ans = Ans_(parms,uid=0,gid=0,role='owner',mid=1001, raw_msg={'message':'/' + inp, 'message_id' : '1001'})
|
||||||
Message = Ans.GETMSG()
|
Message = Ans.GETMSG()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Message = ' Error:\n'+str(e)
|
Message = ' Error:\n'+str(e)
|
||||||
print(Message)
|
print(Message)
|
||||||
inp = input('>')
|
inp = input('>')
|
||||||
|
|
|
@ -1,47 +1,77 @@
|
||||||
from zzcore import StdAns, mysakuya
|
from zzcore import StdAns, mysakuya
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from config import LOLIKEY
|
from config import LOLIKEYS
|
||||||
|
|
||||||
class Ans(StdAns):
|
class Ans(StdAns):
|
||||||
AllowGroup = [973510746, 805197917,343700338,125733077,1084566280,920863253,798595664,655057127,196268763, 204097403, 247022495, 474907856]
|
AllowGroup = [973510746, 805197917,343700338,125733077,1084566280,920863253,798595664,655057127,196268763, 204097403, 247022495, 474907856]
|
||||||
def GETMSG(self):
|
def GETMSG(self):
|
||||||
url = 'https://api.lolicon.app/setu/'
|
|
||||||
params = {
|
|
||||||
'apikey': LOLIKEY,
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(self.parms) < 2:
|
keys = LOLIKEYS
|
||||||
try:
|
|
||||||
resp = requests.get(url=url,params=params).json()
|
try:
|
||||||
quota = str(resp['quota'])
|
nowkey = int(self.DATAGET()['nowkey'])
|
||||||
seconds = resp['quota_min_ttl']
|
except:
|
||||||
m, s = divmod(seconds, 60)
|
nowkey = 0
|
||||||
h, m = divmod(m, 60)
|
|
||||||
quota_min_ttl = f'{h}时{m}分{s}秒'
|
|
||||||
picurl = resp['data'][0]['url']
|
|
||||||
msg = f"[CQ:reply,id={self.raw_msg['message_id']}][CQ:image,file={picurl}]\n剩余次数 {quota}\n距离回复元气 {quota_min_ttl}"
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
msg = '什么东西坏掉了,大概是Pixiv吧...不可能是咱!'
|
|
||||||
return msg
|
|
||||||
|
|
||||||
|
if len(self.parms) < 2:
|
||||||
|
keyword = ''
|
||||||
else:
|
else:
|
||||||
keyword = self.parms[1]
|
keyword = self.parms[1]
|
||||||
if mysakuya(self, keyword) == False:
|
if mysakuya(self, keyword) == False:
|
||||||
return "不许你们看咲夜的涩图!!"
|
return "不许你们看咲夜的涩图!!"
|
||||||
|
|
||||||
params['keyword'] = keyword
|
code, quota, picurl = getsetu(keys[nowkey], keyword)
|
||||||
try:
|
|
||||||
resp = requests.get(url=url,params=params).json()
|
msg = ''
|
||||||
picurl = resp['data'][0]['url']
|
if code == -1 or code == -2:
|
||||||
msg = '[CQ:reply,id=' + str(self.raw_msg['message_id']) + ']' + '咱帮你🔍 ' + keyword + ' 找到了这个\n' + picurl
|
msg += f'>_< 天啦喽,loli 不见了 Code:{code}'
|
||||||
|
elif code == 3:
|
||||||
if len(self.parms) > 2 and self.parms[2] == 'p' :
|
msg += '咱没查到,也有可能是Pixiv坏掉惹'
|
||||||
msg = '[CQ:image,file=' + picurl + ']'
|
elif code == 0:
|
||||||
# .replace('https://i.pixiv.cat', 'https://pximg.sihuan.workers.dev')
|
if len(self.parms) < 2 or (len(self.parms > 2) and self.parms[2] == 'p'):
|
||||||
# msg = picurl.replace('https://i.pixiv.cat', 'https://original.img.cheerfun.dev')
|
msg += f'[CQ:image,file={picurl}]'
|
||||||
except Exception as e:
|
else:
|
||||||
print(e)
|
msg += f'[CQ:reply,id={self.mid}]咱帮你🔍{keyword}找到了这个\n{picurl}'
|
||||||
msg = '[CQ:reply,id=' + str(self.raw_msg['message_id']) + ']咱没查到 ' + keyword + ' 也有可能是Pixiv坏掉了'
|
|
||||||
return msg
|
if quota == 0:
|
||||||
|
nowkey = (nowkey+1)%(len(keys))
|
||||||
|
if code == 429:
|
||||||
|
msg += f'>_< 已经没有 loli 啦,帮你换到了key{nowkey},再试一下吧'
|
||||||
|
else:
|
||||||
|
msg += f'额度用光了,下次将使用 key{nowkey}'
|
||||||
|
self.DATASET({'nowkey':nowkey})
|
||||||
|
return msg
|
||||||
|
|
||||||
|
|
||||||
|
def getsetu(apikey, keyword = ''):
|
||||||
|
url = 'https://api.lolicon.app/setu/'
|
||||||
|
params = {
|
||||||
|
'apikey': apikey,
|
||||||
|
}
|
||||||
|
if keyword != '':
|
||||||
|
params['keyword'] = keyword
|
||||||
|
|
||||||
|
try:
|
||||||
|
resp = requests.get(url=url,params=params).json()
|
||||||
|
except:
|
||||||
|
return -1, -1 ,''
|
||||||
|
|
||||||
|
#quota = str(resp['quota'])
|
||||||
|
#seconds = resp['quota_min_ttl']
|
||||||
|
#m, s = divmod(seconds, 60)
|
||||||
|
#h, m = divmod(m, 60)
|
||||||
|
#quota_min_ttl = f'{h}时{m}分{s}秒'
|
||||||
|
if resp['code'] == 0:
|
||||||
|
quota = resp['quota']
|
||||||
|
try:
|
||||||
|
picurl = resp['data'][0]['url']
|
||||||
|
code = 0
|
||||||
|
except:
|
||||||
|
picurl = ''
|
||||||
|
code = -3
|
||||||
|
return code, quota, picurl
|
||||||
|
elif resp['code'] == 429:
|
||||||
|
return 429, 0, ''
|
||||||
|
else:
|
||||||
|
return -2, -1, ''
|
||||||
|
|
|
@ -12,11 +12,12 @@ class StdAns():
|
||||||
UserNotAllow = '汝不被允许呢.'
|
UserNotAllow = '汝不被允许呢.'
|
||||||
RoleNotAllow = '汝的角色不被允许哦.'
|
RoleNotAllow = '汝的角色不被允许哦.'
|
||||||
|
|
||||||
def __init__(self,parms,uid,gid,role,raw_msg):
|
def __init__(self,parms,uid,gid,role,mid,raw_msg):
|
||||||
self.parms = parms
|
self.parms = parms
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
self.gid = gid
|
self.gid = gid
|
||||||
self.role = role
|
self.role = role
|
||||||
|
self.mid = mid
|
||||||
self.raw_msg = raw_msg
|
self.raw_msg = raw_msg
|
||||||
|
|
||||||
def DATAGET(self):
|
def DATAGET(self):
|
||||||
|
@ -86,4 +87,4 @@ def DM(msgid):
|
||||||
'access_token' : AUTHORIZATION,
|
'access_token' : AUTHORIZATION,
|
||||||
'message_id' : msgid,
|
'message_id' : msgid,
|
||||||
}
|
}
|
||||||
requests.get(url = url, params=data)
|
requests.get(url = url, params=data)
|
||||||
|
|
Loading…
Reference in a new issue