From 0108bf7035ae874389bd4b6d2ac18af2140a5c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Fri, 5 Jan 2024 11:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B1=B3=E6=B8=B8=E7=A4=BE?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=8D=A1=E7=89=87=E7=8B=AC=E7=AB=8B=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/adapter/mhyVila/mhyVilaSDK.py | 63 ++++++++++++++++++++++++++++ OlivOS/core/core/API.py | 4 +- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/OlivOS/adapter/mhyVila/mhyVilaSDK.py b/OlivOS/adapter/mhyVila/mhyVilaSDK.py index 57becc9a..a377489e 100644 --- a/OlivOS/adapter/mhyVila/mhyVilaSDK.py +++ b/OlivOS/adapter/mhyVila/mhyVilaSDK.py @@ -497,3 +497,66 @@ def send_group_msg(target_event, chat_id, message, host_id = None): api_obj.data.object_name = 'MHY:Text' api_obj.do_api('POST') return None + + def create_panel_message(target_event, chat_id, object_name, content:dict, host_id = None): + res_data = OlivOS.contentAPI.api_result_data_template.universal_result() + res_data['active'] = True + if host_id is None: + try: + host_id = target_event.data.host_id + except: + pass + sdk_bot_info = get_SDK_bot_info_from_Event(target_event) + api_obj = API.sendMessage(sdk_bot_info) + api_obj.headdata.vila_id = host_id + api_obj.data.room_id = chat_id + api_obj.data.msg_content = json.dumps(content) + api_obj.data.object_name = object_name + api_obj.do_api('POST') + res_data['data'] = {} + res_data['data']['chat_type'] = 'private' if False else 'group' + res_data['data']['chat_id'] = str(chat_id) + res_data['data']['object_name'] = str(object_name) + res_data['data']['content'] = str(json.dumps(content, ensure_ascii = False)) + return res_data + + +class inde_interface(OlivOS.API.inde_interface_T): + @OlivOS.API.Event.callbackLogger('mhyVila:create_message', ['chat_type', 'chat_id', 'object_name', 'content']) + def __create_message(target_event, chat_type:str, chat_id:str, object_name:str, content:dict, host_id=None, flag_log:bool=True): + res_data = None + if chat_type == 'group': + res_data = OlivOS.mhyVilaSDK.event_action.create_panel_message( + target_event = target_event, + chat_id = chat_id, + object_name = object_name, + content = content, + host_id = host_id + ) + return res_data + + def create_message( + self, + chat_type:str, + chat_id:str, + object_name:str, + content:dict, + host_id:'str|None' = None, + flag_log: bool = True, + remote: bool = False + ): + res_data = None + if remote: + pass + else: + res_data = inde_interface.__create_message( + self.event, + chat_type = chat_type, + chat_id = chat_id, + object_name = object_name, + content = content, + host_id = host_id, + flag_log = True + ) + return res_data + diff --git a/OlivOS/core/core/API.py b/OlivOS/core/core/API.py index 06ab58ae..8635e8e7 100644 --- a/OlivOS/core/core/API.py +++ b/OlivOS/core/core/API.py @@ -169,6 +169,8 @@ def __init_inde_interface(self): self.indeAPI = inde_interface_T(self, self.platform['platform']) if self.platform['sdk'] == 'kaiheila_link': self.indeAPI = OlivOS.kaiheilaSDK.inde_interface(self, self.platform['platform']) + if self.platform['sdk'] == 'mhyVila_link': + self.indeAPI = OlivOS.mhyVilaSDK.inde_interface(self, self.platform['platform']) def get_Event_from_SDK(self): if self.sdk_event_type is OlivOS.virtualTerminalSDK.event: @@ -600,7 +602,7 @@ def funcWarpped(*args, **kwargs): callback_msg_list.append( '%s(%s)' % ( val_list_this, - warppedRes['data'][val_list_this] + str(warppedRes['data'][val_list_this]) ) ) callback_msg = ' '.join(callback_msg_list)