From ca717162e599944a0bf09ed9014be0f7ed256b4d Mon Sep 17 00:00:00 2001 From: lunzhipenxil Date: Fri, 10 Dec 2021 18:33:14 +0800 Subject: [PATCH] =?UTF-8?q?QQ=E9=A2=91=E9=81=93=E7=9B=B8=E5=85=B3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivaDiceCore/data.py | 2 +- OlivaDiceCore/helpDocData.py | 7 +++- OlivaDiceCore/msgCustom.py | 4 ++ OlivaDiceCore/msgReply.py | 73 +++++++++++++++++++++++++++++++++++- OlivaDiceCore/userConfig.py | 1 + 5 files changed, 84 insertions(+), 3 deletions(-) diff --git a/OlivaDiceCore/data.py b/OlivaDiceCore/data.py index 572ca9d..e58cd18 100644 --- a/OlivaDiceCore/data.py +++ b/OlivaDiceCore/data.py @@ -19,7 +19,7 @@ import os import uuid -OlivaDiceCore_ver = '3.0.7' +OlivaDiceCore_ver = '3.0.8' exce_path = os.getcwd() diff --git a/OlivaDiceCore/helpDocData.py b/OlivaDiceCore/helpDocData.py index 8cf7623..4cb733b 100644 --- a/OlivaDiceCore/helpDocData.py +++ b/OlivaDiceCore/helpDocData.py @@ -33,6 +33,7 @@ 青果核心用户群:661366095''', '更新': '''[OlivaDiceCore] +3.0.8: 对接官方频道 3.0.7: 属性增量 3.0.6: 心跳系统 3.0.5: 固化版本 @@ -156,6 +157,8 @@ .name (cn/jp/en/enzh) 后接cn/jp/en/enzh则限定生成中文/日文/英文/英文中译名''', + 'random': '''OlivaDice默认随机数生成器一概采用由random.org提供的真随机数,基于量子源于大气噪声,如对随机数结果有异议请向random.org发起质疑''', + 'rc': '&ra', 'ti': '&疯狂症状', @@ -167,5 +170,7 @@ '理智检定': '&sc', '命名': '&nn', '人物卡': '&st', - '车卡coc': '&coc' + '车卡coc': '&coc', + '随机数': '&random', + '随机数算法': '&random' } diff --git a/OlivaDiceCore/msgCustom.py b/OlivaDiceCore/msgCustom.py index b7db202..1402999 100644 --- a/OlivaDiceCore/msgCustom.py +++ b/OlivaDiceCore/msgCustom.py @@ -47,6 +47,10 @@ 'strBotOff' : '关闭成功', 'strBotAlreadyOff' : '已经处于关闭状态', 'strBotNotUnderHost' : '无所属主频道', + 'strBotHostLocalOn' : '本主频道开启成功', + 'strBotAlreadyHostLocalOn' : '本主频道已经处于开启状态', + 'strBotHostLocalOff' : '本主频道关闭成功', + 'strBotAlreadyHostLocalOff' : '本主频道已经处于关闭状态', 'strBotHostOn' : '本主频道进入默认开启模式', 'strBotAlreadyHostOn' : '本主频道已经处于默认开启模式', 'strBotHostOff' : '本主频道进入默认关闭模式', diff --git a/OlivaDiceCore/msgReply.py b/OlivaDiceCore/msgReply.py index ef823d9..3323155 100644 --- a/OlivaDiceCore/msgReply.py +++ b/OlivaDiceCore/msgReply.py @@ -183,6 +183,15 @@ def unity_reply(plugin_event, Proc): userConfigKey = 'hostEnable', botHash = plugin_event.bot_info.hash ) + flag_hostLocalEnable = True + if flag_is_from_host: + flag_hostLocalEnable = OlivaDiceCore.userConfig.getUserConfigByKey( + userId = plugin_event.data.host_id, + userType = 'host', + platform = plugin_event.platform['platform'], + userConfigKey = 'hostLocalEnable', + botHash = plugin_event.bot_info.hash + ) flag_groupEnable = True if flag_is_from_group: if flag_is_from_host: @@ -471,6 +480,65 @@ def unity_reply(plugin_event, Proc): else: tmp_reply_str = dictStrCustom['strBotAlreadyOff'].format(**dictTValue) replyMsg(plugin_event, tmp_reply_str) + elif isMatchWordStart(tmp_reast_str, 'host'): + tmp_reast_str = getMatchWordStartRight(tmp_reast_str, 'host') + tmp_reast_str = skipSpaceStart(tmp_reast_str) + if isMatchWordStart(tmp_reast_str, 'on'): + if flag_is_from_group: + if (flag_is_from_group_have_admin and flag_is_from_group_admin or not flag_is_from_group_have_admin) or flag_is_from_master: + if flag_is_from_host: + if flag_hostLocalEnable != True: + OlivaDiceCore.userConfig.setUserConfigByKey( + userConfigKey = 'hostLocalEnable', + userConfigValue = True, + botHash = plugin_event.bot_info.hash, + userId = plugin_event.data.host_id, + userType = 'host', + platform = plugin_event.platform['platform'] + ) + OlivaDiceCore.userConfig.writeUserConfigByUserHash( + userHash = OlivaDiceCore.userConfig.getUserHash( + userId = plugin_event.data.host_id, + userType = 'host', + platform = plugin_event.platform['platform'] + ) + ) + tmp_reply_str = dictStrCustom['strBotHostLocalOn'].format(**dictTValue) + replyMsg(plugin_event, tmp_reply_str) + else: + tmp_reply_str = dictStrCustom['strBotAlreadyHostLocalOn'].format(**dictTValue) + replyMsg(plugin_event, tmp_reply_str) + else: + tmp_reply_str = dictStrCustom['strBotNotUnderHost'].format(**dictTValue) + replyMsg(plugin_event, tmp_reply_str) + elif isMatchWordStart(tmp_reast_str, 'off'): + if flag_is_from_group: + if (flag_is_from_group_have_admin and flag_is_from_group_admin or not flag_is_from_group_have_admin) or flag_is_from_master: + if flag_is_from_host: + if flag_hostLocalEnable != False: + OlivaDiceCore.userConfig.setUserConfigByKey( + userConfigKey = 'hostLocalEnable', + userConfigValue = False, + botHash = plugin_event.bot_info.hash, + userId = plugin_event.data.host_id, + userType = 'host', + platform = plugin_event.platform['platform'] + ) + OlivaDiceCore.userConfig.writeUserConfigByUserHash( + userHash = OlivaDiceCore.userConfig.getUserHash( + userId = plugin_event.data.host_id, + userType = 'host', + platform = plugin_event.platform['platform'] + ) + ) + tmp_reply_str = dictStrCustom['strBotHostLocalOff'].format(**dictTValue) + replyMsg(plugin_event, tmp_reply_str) + else: + tmp_reply_str = dictStrCustom['strBotAlreadyHostLocalOff'].format(**dictTValue) + replyMsg(plugin_event, tmp_reply_str) + else: + tmp_reply_str = dictStrCustom['strBotNotUnderHost'].format(**dictTValue) + replyMsg(plugin_event, tmp_reply_str) elif isMatchWordStart(tmp_reast_str, 'exit'): if flag_is_from_group: if (flag_is_from_group_have_admin and flag_is_from_group_admin) or flag_is_from_master: @@ -478,7 +546,7 @@ def unity_reply(plugin_event, Proc): replyMsg(plugin_event, tmp_reply_str) time.sleep(1) plugin_event.set_group_leave(plugin_event.data.group_id) - elif isMatchWordStart(tmp_reast_str, 'summary'): + elif isMatchWordStart(tmp_reast_str, 'summary') and flag_is_from_master: tmp_reply_str = '' tmp_reply_str += OlivaDiceCore.data.bot_summary replyMsg(plugin_event, tmp_reply_str) @@ -486,6 +554,9 @@ def unity_reply(plugin_event, Proc): tmp_reply_str = OlivaDiceCore.data.bot_info + '\n' + dictStrCustom['strBot'].format(**dictTValue) replyMsg(plugin_event, tmp_reply_str) return + #此频道关闭时中断处理 + if not flag_hostLocalEnable and not flag_force_reply: + return #此群关闭时中断处理 if not flag_groupEnable and not flag_force_reply: return diff --git a/OlivaDiceCore/userConfig.py b/OlivaDiceCore/userConfig.py index be9bb09..117d9e6 100644 --- a/OlivaDiceCore/userConfig.py +++ b/OlivaDiceCore/userConfig.py @@ -34,6 +34,7 @@ dictUserConfigNoteDefault = { 'groupEnable' : True, 'hostEnable' : True, + 'hostLocalEnable' : True, 'groupWithHostEnable' : False }