Merge pull request #6 from Si-Huan/master

update
This commit is contained in:
weilinfox 2020-08-20 19:25:19 +08:00 committed by GitHub
commit 1ef5012d52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 354 additions and 42 deletions

6
.gitignore vendored
View file

@ -1,4 +1,8 @@
env
__pycache__
.vscode
config.py
config.py
.idea
test.py
push.cmd
data/pcr/char.list

BIN
data/madoka/quote.db Normal file

Binary file not shown.

8
data/pcr/char.list Normal file
View file

@ -0,0 +1,8 @@
3* 2.5%
镜华 真步 初音 伊绪 璃乃 亚里莎 杏奈 咲恋 伊莉亚 妮侬 莫妮卡 静流 姬塔 秋乃 真琴 望 纯 佩可莉姆(夏日)
2* 18%
雪 千歌 美里 栞 铃奈 茜里 深月 铃 美冬 真阳 忍 美美 惠理子 珠希 绫音 纺希 香织 空花 宫子
1* 79.5%
优衣 碧 美咲 凯露 铃莓 依里 可可萝 由加莉 怜 胡桃 未奏希 日和莉 佩可莉姆 莉玛
up 0.7%
佩可莉姆(夏日)

View file

@ -1,5 +1,5 @@
from flask import Flask, request
from config import PORT
from config import HOST, PORT
from route import ZZRouter
app = Flask(__name__)
@ -9,5 +9,4 @@ def whenmsg():
ZZRouter(request.get_json())
return ''
app.run(host='0.0.0.0',port = PORT, debug=True)
app.run(host= HOST,port = PORT, debug=True)

View file

@ -3,6 +3,8 @@ autopep8==1.5
certifi==2019.11.28
chardet==3.0.4
Click==7.0
entrypoints==0.3
flake8==3.7.9
Flask==1.1.1
idna==2.9
importlib-metadata==1.5.0
@ -16,8 +18,9 @@ MarkupSafe==1.1.1
mccabe==0.6.1
more-itertools==8.2.0
pycodestyle==2.5.0
pyflakes==2.1.1
pylint==2.4.4
redis==3.5.3
redis==3.4.1
requests==2.23.0
six==1.14.0
typed-ast==1.4.1

View file

@ -8,6 +8,7 @@ def ZZRouter(data):
uid = data['user_id']
gid = data['group_id']
role = data['sender']['role']
mid = data['message_id']
parms = str.split(data['message'][1:])
print(uid, gid, role, parms)
if parms == []:
@ -20,7 +21,7 @@ def ZZRouter(data):
except:
Ans_ = emmm.Ans
Ans = Ans_(parms, uid, gid, role, data)
Ans = Ans_(parms, uid, gid, role, mid, data)
Message = Ans.CheckPermission()
if Message == 0:
Message = Ans.GETMSG()

View file

@ -4,6 +4,6 @@ APIURL = 'http://127.0.0.1:5700/'
AUTHORIZATION = ''
PORT = 5580
HOST = '0.0.0.0'
PORT = 5580

View file

@ -19,9 +19,9 @@ while(inp):
Ans_ = emmm.Ans
de(Ans_)
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()
except Exception as e:
Message = ' Error:\n'+str(e)
print(Message)
inp = input('>')
inp = input('>')

26
worker/hhsh.py Normal file
View file

@ -0,0 +1,26 @@
from zzcore import StdAns, mysakuya
import requests
class Ans(StdAns):
def GETMSG(self):
if len(self.parms) < 2:
return '不加参数是坏文明!'
if mysakuya(self, self.raw_msg['message']) == False:
return "不许你们说咲夜!!"
msg = f"[CQ:reply,id={self.raw_msg['message_id']}]"
r = nbnhhsh(self.parms[1])
msg += f'''{(str(r['trans'])[1:-1]).replace("'","").replace(","," ")}'''
return msg
def nbnhhsh(text):
url = 'https://lab.magiconch.com/api/nbnhhsh/guess'
data = {
'text': text,
}
r = requests.post(url=url, data=data).json()
return r[0]

View file

@ -1,42 +1,77 @@
from zzcore import StdAns, mysakuya
import requests
from config import LOLIKEY
from config import LOLIKEYS
class Ans(StdAns):
AllowGroup = [973510746, 805197917,343700338,125733077,1084566280,920863253,798595664,655057127,196268763, 204097403, 247022495, 474907856]
def GETMSG(self):
url = 'https://api.lolicon.app/setu/'
params = {
'apikey': LOLIKEY,
}
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
keys = LOLIKEYS
try:
nowkey = int(self.DATAGET()['nowkey'])
except:
nowkey = 0
if len(self.parms) < 2:
keyword = ''
else:
keyword = self.parms[1]
if mysakuya(self, keyword) == False:
return "不许你们看咲夜的涩图!!"
params['keyword'] = keyword
try:
resp = requests.get(url=url,params=params).json()
picurl = resp['data'][0]['url']
msg = '[CQ:at,qq=' + str(self.uid) + ']' + '咱帮你🔍 ' + keyword + ' 找到了这个\n' + picurl
if len(self.parms) > 2 and self.parms[2] == 'p' :
msg = '[CQ:image,file=' + picurl + ']'
# .replace('https://i.pixiv.cat', 'https://pximg.sihuan.workers.dev')
# msg = picurl.replace('https://i.pixiv.cat', 'https://original.img.cheerfun.dev')
except Exception as e:
print(e)
msg = '[CQ:at,qq=' + str(self.uid) + ']咱没查到 ' + keyword + ' 也有可能是Pixiv坏掉了'
return msg
code, quota, picurl = getsetu(keys[nowkey], keyword)
msg = ''
if code == -1 or code == -2:
msg += f'>_< 天啦喽loli 不见了 Code:{code}'
elif code == 3:
msg += '咱没查到,也有可能是Pixiv坏掉惹'
elif code == 0:
if len(self.parms) < 2 or (len(self.parms > 2) and self.parms[2] == 'p'):
msg += f'[CQ:image,file={picurl}]'
else:
msg += f'[CQ:reply,id={self.mid}]咱帮你🔍{keyword}找到了这个\n{picurl}'
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, ''

45
worker/madoka.py Normal file
View file

@ -0,0 +1,45 @@
from zzcore import StdAns
import sqlite3
from random import randint, choice
n = {'madoka': '鹿目圆', 'homura': '晓美焰', 'sayaka': '美树沙耶香',
'kyoko': '佐仓杏子', 'mami': '巴麻美', 'qb': '丘比'}
def getQuote(name='random'):
conn = sqlite3.connect('./data/madoka/quote.db')
cursor = conn.cursor()
msg = ''
try:
if name == 'random':
id = randint(1, 49)
cursor.execute('SELECT text FROM quote WHERE id=?', (id,))
res = cursor.fetchall()
msg += res[0][0]
else:
cursor.execute('SELECT text FROM quote WHERE name=?', (n[name],))
res = cursor.fetchall()
msg += choice(res)[0]
except Exception:
pass
finally:
cursor.close()
conn.close()
return msg
class Ans(StdAns):
def GETMSG(self):
try:
if len(self.parms) == 1:
return getQuote()
if len(self.parms) == 2:
if self.parms[1].lower() in ['madoka', 'homura', 'sayaka', 'kyoko', 'mami', 'qb']:
return getQuote(self.parms[1].lower())
else:
return '可以使用"/madoka [人物名字]"的方式调用此命令\n可选人物有: Madoka, Homura, Sayaka, Kyoko, Mami, QB'
else:
return '不知道怎么使用的话,就看看"/madoka help"'
except Exception:
return '出现了奇怪的错误呢'

10
worker/oj.py Normal file
View file

@ -0,0 +1,10 @@
from zzcore import StdAns
class Ans(StdAns):
def GETMSG(self):
msg = 'https://openjudge.sakuya.love/'
try:
msg += '?'+ str(self.parms[1])
except:
msg += '\n可以在命令里加上题号直接搜索哦.'
return msg

View file

@ -1,7 +1,8 @@
import json
from zzcore import StdAns
from random import randint, choice
AllowCMD = ['登记','申请出刀','报刀','挂树','查树','进度','查刀','新的一天','血量','boss','初始化','求助','迁移','踢人']
AllowCMD = ['登记','申请出刀','报刀','挂树','查树','进度','查刀','新的一天','血量','boss','初始化','求助','迁移','踢人','单抽','十连','查看卡池','查看池子','新增角色','删除角色','设置up']
status = {
'all_player':{
@ -275,6 +276,154 @@ class Ans(StdAns):
on_tree_players = on_tree_players + nowdata['all_player'][str(p)]['id'] + '\n'
return '救命[CQ:at,qq=3178302597][CQ:at,qq=3430357110]\n' + on_tree_players + '都在🌳上'
path = './data/pcr/char.list'
try:
with open(path, 'r+', encoding='utf-8') as f:
characters = f.readlines()
except:
return '好像角色名单没有加载呢。。。'
star3 = characters[1].replace('\n','').split(' ')
star3 = [each for each in star3 if each]
star2 = characters[3].replace('\n', '').split(' ')
star2 = [each for each in star2 if each]
star1 = characters[5].replace('\n', '').split(' ')
star1 = [each for each in star1 if each]
up = characters[7].replace('\n', '').split(' ')
up = [each for each in up if each]
if cmd == '单抽' or cmd == '十连':
times = 1 if cmd == '单抽' else 9
resultStar = []
resultName = []
for each in range(times):
code = randint(1,1000)
if code <= 18:
resultStar.append(3)
resultName.append(choice(star3))
elif code <= 25:
resultStar.append(3)
resultName.append(choice(up))
elif code <= 205:
resultStar.append(2)
resultName.append(choice(star2))
else:
resultStar.append(1)
resultName.append(choice(star1))
if times == 9:
code = randint(1, 1000)
if code <= 18:
resultStar.append(3)
resultName.append(choice(star3))
elif code <= 25:
resultStar.append(3)
resultName.append(choice(up))
else:
resultStar.append(2)
resultName.append(choice(star2))
stones = 0
colors = '[CQ:at,qq={}]\n'.format(self.uid)
for each in range(len(resultStar)):
if resultStar[each] == 3:
stones = stones + 50
color = ''
elif resultStar[each] == 2:
stones = stones + 10
color = ''
else:
stones = stones + 1
color = ''
if each == 4:colors = colors + color + '\n'
else:colors = colors + color + ' '
name = ''
for each in range(len(resultName)):
if each == 4: name = name + resultName[each] + '\n'
else:name = name + resultName[each] + ' '
name = name + '\n母猪石 +{} [CQ:face,id=108]'.format(stones)
self.sendmsg(colors)
self.sendmsg(name)
if stones == 19:return '非酋在上,请受我一拜[CQ:face,id=0][CQ:face,id=118]'
elif stones > 157:return '欧皇![CQ:face,id=23]啊我酸了'
if cmd == '查看卡池' or cmd == '查看池子':
return '3★\n' + ''.join(star3) + '\n2★\n' + ''.join(star2) + '\n1★\n' + ''.join(
star1) + '\n★UP★\n' + ''.join(up)
if cmd == '新增角色':
if self.role in ['owner','admin']:
if len(self.parms) != 4:
return '请使用句式:/pcr 新增角色 3 镜华'
try:
star = int(self.parms[2])
except:
return '请使用句式:/pcr 新增角色 3 镜华'
name = self.parms[3]
if star == 3:
star3.append(name)
elif star == 2:
star2.append(name)
elif star == 1:
star1.append(name)
else:
return '请输入正确的星级'
char = '3* 2.5%\n{}\n2* 18%\n{}\n1* 79.5%\n{}\nup 0.7%\n{}'.format(' '.join(star3), ' '.join(star2),
' '.join(star1), ' '.join(up))
try:
with open(path, 'w+', encoding='utf-8') as f:
f.write(char)
except:
return '好像角色名单没有加载呢。。。'
return '添加新角色{}{} 成功[CQ:face,id=144][CQ:face,id=144]'.format(star, name)
else:
return '抱歉,您没有使用这条命令的权柄'
if cmd == '删除角色':
if self.role in ['owner','admin']:
if len(self.parms) != 4:
return '请使用句式:/pcr 删除角色 3 镜华'
try:
star = int(self.parms[2])
except:
return '请使用句式:/pcr 删除角色 3 镜华'
name = self.parms[3]
try:
if star == 3:
star3.remove(name)
elif star == 2:
star2.remove(name)
elif star == 1:
star1.remove(name)
else:
return '请输入正确的星级'
except:
return '没有找到对应的角色'
char = '3* 2.5%\n{}\n2* 18%\n{}\n1* 79.5%\n{}\nup 0.7%\n{}'.format(' '.join(star3), ' '.join(star2),
' '.join(star1), ' '.join(up))
try:
with open(path, 'w+', encoding='utf-8') as f:
f.write(char)
except:
return '好像角色名单没有加载呢。。。'
return '删除角色{}{} 成功'.format(star, name)
else:
return '抱歉,您没有使用这条命令的权柄'
if cmd == '设置up':
if self.role in ['owner','admin']:
if len(self.parms) != 3:
return '请使用句式:/pcr 设置up 镜华(多位角色请用中文逗号隔开)'
name = self.parms[2]
up = [each for each in name.split('') if each]
char = '3* 2.5%\n{}\n2* 18%\n{}\n1* 79.5%\n{}\nup 0.7%\n{}'.format(' '.join(star3), ' '.join(star2),
' '.join(star1), ' '.join(up))
try:
with open(path, 'w+', encoding='utf-8') as f:
f.write(char)
except:
return '好像角色名单没有加载呢。。。'
return '已成功将{}设为★UP★角色'.format(name)
else:
return '抱歉,您没有使用这条命令的权柄'
def bossname(num):

View file

@ -6,6 +6,7 @@ import random
class Ans(StdAns):
NotAllowGroup = [973510746]
def GETMSG(self):

6
worker/shzyhxjzg.py Normal file
View file

@ -0,0 +1,6 @@
from zzcore import StdAns
class Ans(StdAns):
def GETMSG(self):
msg = "富强 民主 文明 和谐\n自由 平等 公正 法制\n爱国 敬业 诚信 友善"
return msg

15
worker/wyy.py Normal file
View file

@ -0,0 +1,15 @@
from zzcore import StdAns, mysakuya
import requests
class Ans(StdAns):
def GETMSG(self):
msg = f"[CQ:reply,id={self.raw_msg['message_id']}]"
try:
msg += wyy()
except:
msg += '可能是网抑云坏掉了,可不是咱!'
return msg
def wyy():
r = requests.get(url='http://api.heerdev.top:4995/nemusic/random').json()
return r['text']

View file

@ -12,11 +12,12 @@ class StdAns():
UserNotAllow = '汝不被允许呢.'
RoleNotAllow = '汝的角色不被允许哦.'
def __init__(self,parms,uid,gid,role,raw_msg):
def __init__(self,parms,uid,gid,role,mid,raw_msg):
self.parms = parms
self.uid = uid
self.gid = gid
self.role = role
self.mid = mid
self.raw_msg = raw_msg
def DATAGET(self):
@ -73,8 +74,17 @@ def mysakuya(self, words):
if ('' in words and '' in words) or ('' in words and '' in words) or ('' in words and '' in words and '' in words) or ('1' in words and '6' in words and '' in words):
return False
for sakuya in ['口关夜','十六夜咲夜','十六夜','十六','咲夜','Sakuya','sakuya','Izayoi Sakuya','Izayoi','izayoi','izayoi sakuya']:
for sakuya in ['口关夜','十六夜咲夜','十六夜','十六','咲夜', '夜咲', '六夜','Sakuya','sakuya','Izayoi Sakuya','Izayoi','izayoi','izayoi sakuya']:
if sakuya in words:
return False
return True
return True
def DM(msgid):
url = APIURL + "delete_msg"
data = {
'access_token' : AUTHORIZATION,
'message_id' : msgid,
}
requests.get(url = url, params=data)