From 4332e416d723fb2487ba236368d0095f5b642d2e Mon Sep 17 00:00:00 2001 From: lunzhipenxil Date: Thu, 18 Nov 2021 22:32:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/API.py | 36 ++++++++++++++++++++++++------------ OlivOS/dodoSDK.py | 7 ++++--- OlivOS/fanbookSDK.py | 2 ++ OlivOS/onebotSDK.py | 7 ++++++- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/OlivOS/API.py b/OlivOS/API.py index eec0d7db..554b7509 100644 --- a/OlivOS/API.py +++ b/OlivOS/API.py @@ -150,8 +150,8 @@ def do_init_log(self): ]) elif self.plugin_info['func_type'] == 'group_message': tmp_host_id = '-' - if self.data.extend['host_group_id'] != None: - tmp_host_id = str(self.data.extend['host_group_id']) + if self.data.host_id != None: + tmp_host_id = str(self.data.host_id) tmp_globalMetaTableTemp_patch = OlivOS.metadataAPI.getPairMapping([ ['host_id', tmp_host_id], ['group_id', self.data.group_id], @@ -291,6 +291,7 @@ def __init__(self, user_id, message, sub_type, flag_lazy = True): class group_message(object): def __init__(self, group_id, user_id, message, sub_type, flag_lazy = True): self.sub_type = sub_type + self.host_id = None self.group_id = group_id self.message = message self.message_sdk = message @@ -505,7 +506,7 @@ def __reply(self, message, flag_log = True): 'group_message' ] ): - self.__send('group', self.data.group_id, tmp_message, host_id = self.data.extend['host_group_id'], flag_log = False) + self.__send('group', self.data.group_id, tmp_message, host_id = self.data.host_id, flag_log = False) flag_type = 'group' elif checkByListOrEqual( self.plugin_info['func_type'], @@ -555,18 +556,19 @@ def __reply(self, message, flag_log = True): 'group_message' ] ): - if self.data.extend['host_group_id'] != None: - self.log_func(2, 'Host(' + str(self.data.extend['host_group_id']) + ') Group(' + str(self.data.group_id) + '): ' + tmp_message_log, [ + if self.data.host_id != None: + self.log_func(2, 'Host(' + str(self.data.host_id) + ') Group(' + str(self.data.group_id) + '): ' + tmp_message_log, [ (self.platform['platform'], 'default'), (self.plugin_info['name'], 'default'), ('reply', 'callback') ]) return - self.log_func(2, 'Group(' + str(self.data.group_id) + '): ' + tmp_message_log, [ - (self.platform['platform'], 'default'), - (self.plugin_info['name'], 'default'), - ('reply', 'callback') - ]) + else: + self.log_func(2, 'Group(' + str(self.data.group_id) + '): ' + tmp_message_log, [ + (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), + ('reply', 'callback') + ]) def reply(self, message, flag_log = True, remote = False): if remote: @@ -585,7 +587,14 @@ def __send(self, send_type, target_id, message, host_id = None, flag_log = True) return if self.platform['sdk'] == 'onebot': if flag_type == 'private': - OlivOS.onebotSDK.event_action.send_private_msg(self, target_id, tmp_message) + if 'host_id' in self.data.__dict__: + if self.data.host_id != None: + #此处缺少接口 + pass + else: + OlivOS.onebotSDK.event_action.send_private_msg(self, target_id, tmp_message) + else: + OlivOS.onebotSDK.event_action.send_private_msg(self, target_id, tmp_message) elif flag_type == 'group': if host_id != None: OlivOS.onebotSDK.event_action.send_guild_channel_msg(self, host_id, target_id, tmp_message) @@ -600,7 +609,10 @@ def __send(self, send_type, target_id, message, host_id = None, flag_log = True) OlivOS.fanbookSDK.event_action.send_msg(self, target_id, tmp_message) elif self.platform['sdk'] == 'dodo_poll': if flag_type == 'private': - OlivOS.dodoSDK.event_action.send_private_msg(self, target_id, tmp_message) + if host_id != None: + OlivOS.dodoSDK.event_action.send_private_msg(self, host_id, target_id, tmp_message) + else: + OlivOS.dodoSDK.event_action.send_private_msg(self, self.data.host_id, target_id, tmp_message) elif flag_type == 'group': OlivOS.dodoSDK.event_action.send_msg(self, target_id, tmp_message) elif self.platform['sdk'] == 'dodobot_ea': diff --git a/OlivOS/dodoSDK.py b/OlivOS/dodoSDK.py index c120d699..87b28324 100644 --- a/OlivOS/dodoSDK.py +++ b/OlivOS/dodoSDK.py @@ -175,6 +175,7 @@ def get_Event_from_SDK(target_event): target_event.data.sender['sex'] = 'unknown' target_event.data.sender['age'] = 0 if target_event.sdk_event.islandId != None: + target_event.data.host_id = target_event.sdk_event.islandId target_event.data.extend['host_group_id'] = target_event.sdk_event.islandId #支持OlivOS API调用的方法实现 @@ -205,10 +206,10 @@ def send_msg(target_event, chat_id, message): if this_msg.data.resourceJson != '{}': this_msg.do_api() - def send_private_msg(target_event, chat_id, message): + def send_private_msg(target_event, host_id, chat_id, message): this_msg = API.sendMessagePrivate(get_SDK_bot_info_from_Event(target_event)) - if target_event.data.extend['host_group_id'] != None: - this_msg.data.islandId = target_event.data.extend['host_group_id'] + if host_id != None: + this_msg.data.islandId = host_id this_msg.data.toUid = chat_id this_msg.data.content = '' for message_this in message.data: diff --git a/OlivOS/fanbookSDK.py b/OlivOS/fanbookSDK.py index a49e2df2..8c2a6b70 100644 --- a/OlivOS/fanbookSDK.py +++ b/OlivOS/fanbookSDK.py @@ -199,6 +199,8 @@ def get_Event_from_SDK(target_event): target_event.data.sender['nickname'] = target_event.sdk_event.json['channel_post']['from']['first_name'] target_event.data.sender['sex'] = 'unknown' target_event.data.sender['age'] = 0 + target_event.data.host_id = target_event.sdk_event.json['channel_post']['chat']['guild_id'] + target_event.data.extend['host_group_id'] = target_event.sdk_event.json['channel_post']['chat']['guild_id'] #支持OlivOS API调用的方法实现 class event_action(object): diff --git a/OlivOS/onebotSDK.py b/OlivOS/onebotSDK.py index 3162595f..81c55404 100644 --- a/OlivOS/onebotSDK.py +++ b/OlivOS/onebotSDK.py @@ -173,8 +173,13 @@ def get_Event_from_SDK(target_event): target_event.data.raw_message_sdk = OlivOS.messageAPI.Message_templet('old_string', target_event.sdk_event.json['message']) target_event.data.font = None target_event.data.sender.update(target_event.sdk_event.json['sender']) - if 'guild_id' in target_event.sdk_event.json != None: + if 'guild_id' in target_event.sdk_event.json: + target_event.data.host_id = target_event.sdk_event.json['guild_id'] target_event.data.extend['host_group_id'] = target_event.sdk_event.json['guild_id'] + if 'self_tiny_id' in target_event.sdk_event.json: + target_event.data.extend['sub_self_id'] = target_event.sdk_event.json['self_tiny_id'] + if target_event.sdk_event.json['user_id'] == target_event.sdk_event.json['self_tiny_id']: + target_event.active = False elif target_event.base_info['type'] == 'notice': if target_event.sdk_event.json['notice_type'] == 'group_upload': target_event.active = True