Skip to content

Commit

Permalink
修复好感变化逻辑谬误
Browse files Browse the repository at this point in the history
  • Loading branch information
Amber-Keter committed Aug 29, 2022
1 parent 6126e84 commit 33bd311
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 6 deletions.
40 changes: 34 additions & 6 deletions DreamWorld/Favor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions DreamWorld/Level/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Level.main
16 changes: 16 additions & 0 deletions DreamWorld/Level/app.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
87 changes: 87 additions & 0 deletions DreamWorld/Level/main.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions DreamWorld/User/app.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 33bd311

Please sign in to comment.