From 33bd31113565fcc087e504bd98a6248775b8e1c9 Mon Sep 17 00:00:00 2001 From: Amber-Keter <1761089294@qq.com> Date: Mon, 29 Aug 2022 09:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A5=BD=E6=84=9F=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E9=80=BB=E8=BE=91=E8=B0=AC=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DreamWorld/Favor/main.py | 40 ++++++++++++++--- DreamWorld/Level/__init__.py | 1 + DreamWorld/Level/app.json | 16 +++++++ DreamWorld/Level/main.py | 87 ++++++++++++++++++++++++++++++++++++ DreamWorld/User/app.json | 4 ++ 5 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 DreamWorld/Level/__init__.py create mode 100644 DreamWorld/Level/app.json create mode 100644 DreamWorld/Level/main.py diff --git a/DreamWorld/Favor/main.py b/DreamWorld/Favor/main.py index 6652fa9..1684f9a 100644 --- a/DreamWorld/Favor/main.py +++ b/DreamWorld/Favor/main.py @@ -226,6 +226,12 @@ def reply(self,string): res = Rand(r_common) else: res = r_common + if type(res) is dict: + cd = res.get('cd',cd_default) + max = res.get('max',max_default) + change = res.get('change',0) + success = res.get('success',True) + res = res.get('reply',None) r_class = 'common' if r_favor: if type(r_favor) is not list: @@ -236,6 +242,10 @@ def reply(self,string): i:dict interval = i.get('interval',[None,None]) if interval is int and favor == interval: + cd = i.get('cd',cd_default) + max = i.get('max',max_default) + change = i.get('change',0) + success = i.get('success',True) res = i.get('reply',None) r_class = 'favor' break @@ -247,6 +257,10 @@ def reply(self,string): if interval[1] and favor > interval[1]: right = False if left and right: + cd = i.get('cd',cd_default) + max = i.get('max',max_default) + change = i.get('change',0) + success = i.get('success',True) res = i.get('reply',None) r_class = 'favor' break @@ -259,6 +273,10 @@ def reply(self,string): i:dict interval = i.get('interval',[None,None]) if interval is int and level == interval: + cd = i.get('cd',cd_default) + max = i.get('max',max_default) + change = i.get('change',0) + success = i.get('success',True) res = i.get('reply',None) r_class = 'level' break @@ -270,6 +288,10 @@ def reply(self,string): if interval[1] and level > interval[1]: right = False if left and right: + cd = i.get('cd',cd_default) + max = i.get('max',max_default) + change = i.get('change',0) + success = i.get('success',True) res = i.get('reply',None) r_class = 'level' break @@ -281,24 +303,32 @@ def reply(self,string): for i in r_special: uid_list = i.get('uid',[]) if uid_list is str and self.uid == uid_list: + cd = i.get('cd',cd_default) + max = i.get('max',max_default) + change = i.get('change',0) + success = i.get('success',True) res = i.get('reply',None) r_class = 'special' break elif type(uid_list) is list: if self.uid in uid_list: + cd = i.get('cd',cd_default) + max = i.get('max',max_default) + change = i.get('change',0) + success = i.get('success',True) res = i.get('reply',None) r_class = 'special' break if type(res) is dict: cd = res.get('cd',cd_default) max = res.get('max',max_default) - change = res.get('change',0) - success = res.get('success',True) + change = res.get('change',change) + success = res.get('success',success) else: cd = cd_default max = max_default - change = 0 - success = True + change = change + success = success all_interval = ['special','level','favor','common'] if type(cd) is list: cd:list @@ -388,8 +418,6 @@ def reply(self,string): return max_reply else: today_frequency = 0 - if type(res) is dict: - res = res.get('reply',None) res = Rand(res) if type(res) is dict: res:dict diff --git a/DreamWorld/Level/__init__.py b/DreamWorld/Level/__init__.py new file mode 100644 index 0000000..b75dee8 --- /dev/null +++ b/DreamWorld/Level/__init__.py @@ -0,0 +1 @@ +import Level.main \ No newline at end of file diff --git a/DreamWorld/Level/app.json b/DreamWorld/Level/app.json new file mode 100644 index 0000000..c085039 --- /dev/null +++ b/DreamWorld/Level/app.json @@ -0,0 +1,16 @@ +{ + "name" : "DW权限系统", + "author" : "Dr.Amber", + "namespace" : "DW_Level", + "priority" : 30000, + "svn" : 3, + "compatible_svn" : 95, + "message_mode" : "olivos_string", + "support" : [ + { + "sdk" : "all", + "platform" : "all", + "model" : "all" + } + ] +} \ No newline at end of file diff --git a/DreamWorld/Level/main.py b/DreamWorld/Level/main.py new file mode 100644 index 0000000..9cc3acd --- /dev/null +++ b/DreamWorld/Level/main.py @@ -0,0 +1,87 @@ + #模块导入区 +import json #json序列化与反序列化模块 +import re #正则表达式库,用于匹配指令 +import time +import os +import sys +import Basic +import User + +''' + _ _ __ _ + /\ | | | |/ / | | + / \ _ __ ___ | |__ ___ _ __| ' / ___| |_ ___ _ __ + / /\ \ | '_ ` _ \| '_ \ / _ \ '__| < / _ \ __/ _ \ '__| + / ____ \| | | | | | |_) | __/ | | . \ __/ || __/ | + /_/ \_\_| |_| |_|_.__/ \___|_| |_|\_\___|\__\___|_| + DW用户系统 by Dr.Amber + 问题反馈请加QQ:1761089294 + Email:amberketer@outlook.com + +''' + + +#事件区 +class Event(object): + def init(plugin_event, Proc): + if not os.path.exists("plugin/data/DreamWorld"): + os.mkdir("plugin/data/DreamWorld") + if not os.path.exists("plugin/data/DreamWorld/Level"): + os.mkdir("plugin/data/DreamWorld/Level") + if not os.path.exists("plugin/lib"): + os.mkdir("plugin/lib") + if not os.path.exists("plugin/lib/DreamWorldLib"): + os.mkdir("plugin/lib/DreamWorldLib") + if 'plugin/lib/DreamWorldLib' not in sys.path: + sys.path.insert(1,'plugin/lib/DreamWorldLib') + try: + Basic.ReadJson(Basic.path('Data')) + except: + data={ + "User":{}, + 'Link':{}, + 'Guest':{}, + 'Help':{ + 'all':"【DreamWord】用户系统指令简介\n*user help [entry] #获取[entry]的详细信息。如:*user help link\n*user info #获取账号信息\n*user nn [NewName] #变更账户昵称为[NewName]\n*user link [Target] #申请与[Target]关联\n*user accept [Token] #接受关联申请\n*user close #断开当前关联", + 'link':"*user link [Target]:\n申请与[Target]关联,骰娘将返回[Token],用于被关联账号验证。\n需注意,当已有关联账户时关联其他账户将断开先前的关联\n[Target]格式:@格式、uuid格式、[platform]-[id]、[id]\n其中,[platform]代表目标账户的平台,[id]代表目标的账户,若使用第四种格式,则[platform]默认为当前平台。", + 'close':"*user close:\n断开当前关联。", + 'accept':"*user accept [Token]:\n接受关联申请\n[Token]在申请关联时骰娘的回执内容中,格式为[uuid]#[uuid]", + 'nn':"*user nn [NewName]:\n将你的账号的昵称更改为[NewName]\n需注意,本指令只更改本用户,但更改后的昵称将被所有关联者使用。", + 'info':"*user info:\n获取你的账号信息。" + } + } + with open("plugin/data/DreamWorld/User/Data.json","w",encoding="utf-8") as file: + json.dump(data, file,indent=4,ensure_ascii=False) + try: + Basic.ReadJson(Basic.path('Token')) + except: + data={} + with open("plugin/data/DreamWorld/User/Token.json","w",encoding="utf-8") as file: + json.dump(data, file,indent=4,ensure_ascii=False) + def private_message(plugin_event, Proc): + ReplyFunction(plugin_event,Proc) + #私聊 + def group_message(plugin_event, Proc): + ReplyFunction(plugin_event,Proc) + #群聊 + def save(plugin_event,Proc): + pass + +class Level: + def __init__(self,plugin_event): + self.p = plugin_event + self.User = User.User(self.p) + self.all = Basic.ReadJson(Basic.path('Data')) + self.conf = Basic.ReadJson(Basic.path('Config')) + self.default = self.conf.get('Default',0) + self.level = self.all.get(self.User.uid,self.default) + + def info(self): + n = self.conf.get('Level',{}).get(str(self.level),{}) + res = "{nick}在{self}这的权限为{level}".format(nick=self.User.name,self=self.p.bot_info.name,level = self.level) + + + + +def ReplyFunction(plugin_event, Proc): + pass \ No newline at end of file diff --git a/DreamWorld/User/app.json b/DreamWorld/User/app.json index fc75d5f..ce7ad39 100644 --- a/DreamWorld/User/app.json +++ b/DreamWorld/User/app.json @@ -1,7 +1,11 @@ { "name" : "DW用户系统", + "author" : "Dr.Amber", "namespace" : "DW_User", "priority" : 30000, + "svn" : 3, + "compatible_svn" : 95, + "message_mode" : "olivos_string", "support" : [ { "sdk" : "all",