From ee9adff99b59103521f12ce32c1f156d2416d803 Mon Sep 17 00:00:00 2001 From: "2920233418@qq.com" <2920233418@qq.com> Date: Wed, 19 Aug 2020 14:39:38 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=8D=A1=E6=B1=A0,=E6=96=B0=E5=A2=9E=E8=A7=92=E8=89=B2,?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=A7=92=E8=89=B2,=E8=AE=BE=E7=BD=AEup?= =?UTF-8?q?=E5=9B=9B=E6=9D=A1=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- data/pcr/char | 4 +- worker/pcr.py | 109 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 100 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 2e3c5c9..d0d0d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ __pycache__ .vscode config.py .idea -test.py \ No newline at end of file +test.py +push.cmd +data \ No newline at end of file diff --git a/data/pcr/char b/data/pcr/char index fc30e6a..02112e6 100644 --- a/data/pcr/char +++ b/data/pcr/char @@ -1,8 +1,8 @@ 3* 2.5% -镜华 真步 初音 伊绪 璃乃 亚里莎 杏奈 咲恋 伊莉亚 妮侬 莫妮卡 静流 姬塔 秋乃 真琴 望 纯 +镜华 真步 初音 伊绪 璃乃 亚里莎 杏奈 咲恋 伊莉亚 妮侬 莫妮卡 静流 姬塔 秋乃 真琴 望 纯 佩可莉姆(夏日) 2* 18% 雪 千歌 美里 栞 铃奈 茜里 深月 铃 美冬 真阳 忍 美美 惠理子 珠希 绫音 纺希 香织 空花 宫子 1* 79.5% -优衣 碧 美咲 凯露 铃莓 依里 可可萝 由加莉 怜 胡桃 未奏希 日和莉 佩可莉姆 莉玛 +优衣 碧 美咲 凯露 铃莓 依里 可可萝 由加莉 怜 胡桃 未奏希 日和莉 佩可莉姆 莉玛 up 0.7% 佩可莉姆(夏日) \ No newline at end of file diff --git a/worker/pcr.py b/worker/pcr.py index c7d97a6..13f714d 100644 --- a/worker/pcr.py +++ b/worker/pcr.py @@ -2,7 +2,7 @@ import json from zzcore import StdAns from random import randint, choice -AllowCMD = ['登记','申请出刀','报刀','挂树','查树','进度','查刀','新的一天','血量','boss','初始化','求助','迁移','踢人','单抽','十连'] +AllowCMD = ['登记','申请出刀','报刀','挂树','查树','进度','查刀','新的一天','血量','boss','初始化','求助','迁移','踢人','单抽','十连','查看卡池','查看池子','新增角色','删除角色','设置up'] status = { 'all_player':{ @@ -276,22 +276,24 @@ 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' + 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 - try: - with open('./data/pcr/char', '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] resultStar = [] resultName = [] for each in range(times): @@ -343,6 +345,85 @@ class Ans(StdAns): 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.uid == 2920233418 or self.uid == 1318000868: + 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.uid == 2920233418 or self.uid == 1318000868: + 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.uid == 2920233418 or self.uid == 1318000868: + 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): From 84940b5bfd4e3e26960bd97c62c41274b206b836 Mon Sep 17 00:00:00 2001 From: "2920233418@qq.com" <2920233418@qq.com> Date: Wed, 19 Aug 2020 14:47:49 +0800 Subject: [PATCH 2/4] char -> char.list --- .gitignore | 3 +-- data/pcr/{char => char.list} | 0 worker/pcr.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) rename data/pcr/{char => char.list} (100%) diff --git a/.gitignore b/.gitignore index d0d0d2b..1ce7f3e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ __pycache__ config.py .idea test.py -push.cmd -data \ No newline at end of file +push.cmd \ No newline at end of file diff --git a/data/pcr/char b/data/pcr/char.list similarity index 100% rename from data/pcr/char rename to data/pcr/char.list diff --git a/worker/pcr.py b/worker/pcr.py index 13f714d..4816ab3 100644 --- a/worker/pcr.py +++ b/worker/pcr.py @@ -276,7 +276,7 @@ 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' + path = './data/pcr/char.list' try: with open(path, 'r+', encoding='utf-8') as f: characters = f.readlines() From 641f4741717c89346fa3e90e1d626e1574bf9093 Mon Sep 17 00:00:00 2001 From: "2920233418@qq.com" <2920233418@qq.com> Date: Wed, 19 Aug 2020 14:48:49 +0800 Subject: [PATCH 3/4] .ignore add char.list --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1ce7f3e..320616b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ __pycache__ config.py .idea test.py -push.cmd \ No newline at end of file +push.cmd +data/pcr/char.list \ No newline at end of file From 5dbce1adb85960f98ffab433cc924ab1c53a9a1d Mon Sep 17 00:00:00 2001 From: "2920233418@qq.com" <2920233418@qq.com> Date: Wed, 19 Aug 2020 15:03:04 +0800 Subject: [PATCH 4/4] change the allowans --- worker/pcr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worker/pcr.py b/worker/pcr.py index 4816ab3..d9a9d4d 100644 --- a/worker/pcr.py +++ b/worker/pcr.py @@ -350,7 +350,7 @@ class Ans(StdAns): star1) + '\n★UP★\n' + '、'.join(up) if cmd == '新增角色': - if self.uid == 2920233418 or self.uid == 1318000868: + if self.role in ['owner','admin']: if len(self.parms) != 4: return '请使用句式:/pcr 新增角色 3 镜华' try: @@ -378,7 +378,7 @@ class Ans(StdAns): return '抱歉,您没有使用这条命令的权柄' if cmd == '删除角色': - if self.uid == 2920233418 or self.uid == 1318000868: + if self.role in ['owner','admin']: if len(self.parms) != 4: return '请使用句式:/pcr 删除角色 3 镜华' try: @@ -409,7 +409,7 @@ class Ans(StdAns): return '抱歉,您没有使用这条命令的权柄' if cmd == '设置up': - if self.uid == 2920233418 or self.uid == 1318000868: + if self.role in ['owner','admin']: if len(self.parms) != 3: return '请使用句式:/pcr 设置up 镜华(多位角色请用中文逗号隔开)' name = self.parms[2]