From 17dff30387a7e4bc62827ffbbc43d089f967bdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Tue, 28 Nov 2023 11:42:58 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E6=94=B9=E8=BF=9BKOOK=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/kaiheilaSDK.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OlivOS/kaiheilaSDK.py b/OlivOS/kaiheilaSDK.py index f7e64a5e..cdd56e4a 100644 --- a/OlivOS/kaiheilaSDK.py +++ b/OlivOS/kaiheilaSDK.py @@ -587,7 +587,8 @@ def send_msg(target_event, chat_id, message, flag_direct=False, message_type_in= elif message_type == 'card': res_data = { "type": "card", - "theme": "secondary", + "theme": "primary", + "color": "#009FE9", "size": "lg", "modules": [] } From be208ea7fc29a0532bea78c5696a713e08e1b642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Tue, 28 Nov 2023 15:43:58 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B1=B3=E5=93=88?= =?UTF-8?q?=E6=B8=B8=E5=A4=A7=E5=88=AB=E9=87=8E=E7=9A=84=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/multiLoginUIAPI.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/OlivOS/multiLoginUIAPI.py b/OlivOS/multiLoginUIAPI.py index 5aef7059..8d683ed6 100644 --- a/OlivOS/multiLoginUIAPI.py +++ b/OlivOS/multiLoginUIAPI.py @@ -22,6 +22,7 @@ import shutil import platform import traceback +import json from tkinter import ttk from tkinter import messagebox @@ -367,6 +368,8 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non 'QQ官方/私域/V2', 'QQ官方/公域/V1', 'QQ官方/私域/V1', + '米游社/大别野/公域', + '米游社/大别野/私域', 'Discord', 'Telegram', 'Fanbook', @@ -569,6 +572,18 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non 'Token': 'edit_root_Entry_Server_access_token' } ], + '米游社/大别野/公域': ['vila', 'vila_link', 'public', 'True', 'websocket', { + 'Bot_Id': 'edit_root_Entry_ID', + 'Secret': 'edit_root_Entry_Password', + 'Pub_Key': 'edit_root_Entry_Server_access_token' + } + ], + '米游社/大别野/私域': ['vila', 'vila_link', 'private', 'True', 'websocket', { + 'Bot_Id': 'edit_root_Entry_ID', + 'Secret': 'edit_root_Entry_Password', + 'Pub_Key': 'edit_root_Entry_Server_access_token' + } + ], 'B站直播间/游客': ['biliLive', 'biliLive_link', 'default', 'True', 'websocket', { '直播间ID': 'edit_root_Entry_Server_access_token' } @@ -665,6 +680,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non 'qq', 'qqGuild', 'kaiheila', + 'vila', 'telegram', 'dodo', 'fanbook', @@ -696,6 +712,9 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non # 'dodo_poll', # 'dodobot_ea' ], + 'vila': [ + 'vila_link' + ], 'fanbook': [ 'fanbook_poll' ], @@ -766,6 +785,13 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non 'text' ] }, + 'vila': { + 'vila_link': [ + 'private', + 'public', + 'default' + ] + }, 'telegram': { 'telegram_poll': [ 'default' @@ -883,6 +909,20 @@ def tree_edit_commit(self): tmp_host = 'NONEED' if tmp_port == '': tmp_port = '0' + if tmp_platform_platform == 'vila' \ + and tmp_platform_sdk == 'vila_link': + tmp_id = tmp_id.strip('\n') + if tmp_host == '': + tmp_host = 'NONEED' + if tmp_port == '': + tmp_port = '0' + try: + tmp_access_token_new = json.loads(tmp_access_token) + if type(tmp_access_token_new) is str: + tmp_access_token = tmp_access_token_new + except Exception as e: + pass + #traceback.print_exc() if tmp_platform_platform == 'telegram' \ and tmp_platform_sdk == 'telegram_poll': if tmp_id == '': From a54f4c2be9c888927993ac0ae0291dbdca5df5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Tue, 28 Nov 2023 15:46:32 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E5=BC=95=E5=85=A5CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b02cdef..da27d01f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: CI-Packing-all on: push: - branches: [ main, dev ] + branches: [ main, dev, dev-vila] jobs: build-win64-release: runs-on: windows-latest From 290a517599b18b10f314068d360f00f16d33da30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Tue, 28 Nov 2023 19:16:19 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=8F=91=E9=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/kaiheilaSDK.py | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/OlivOS/kaiheilaSDK.py b/OlivOS/kaiheilaSDK.py index cdd56e4a..1f91814a 100644 --- a/OlivOS/kaiheilaSDK.py +++ b/OlivOS/kaiheilaSDK.py @@ -671,6 +671,17 @@ def send_msg(target_event, chat_id, message, flag_direct=False, message_type_in= this_msg.data.content = json.dumps([res_data], ensure_ascii=False) this_msg.do_api() + def create_message(target_event, chat_id, content_type:int, content:str, flag_direct=False): + this_msg = None + if flag_direct: + this_msg = API.creatDirectMessage(get_SDK_bot_info_from_Event(target_event)) + else: + this_msg = API.creatMessage(get_SDK_bot_info_from_Event(target_event)) + this_msg.data.target_id = str(chat_id) + this_msg.data.type = content_type + this_msg.data.content = content + this_msg.do_api() + def get_login_info(target_event): res_data = OlivOS.contentAPI.api_result_data_template.get_login_info() raw_obj = None @@ -889,6 +900,44 @@ def set_playgame_activity_game(self, game_id:int, flag_log: bool = True, remote: res_data = inde_interface.__set_playgame_activity_game(self.event, game_id, flag_log=True) return res_data + @OlivOS.API.Event.callbackLogger('kaiheila:create_message', ['chat_type', 'chat_id', 'content_type', 'content']) + def __create_message(target_event, chat_type:str, chat_id:str, content_type:int, content:str, flag_log:bool=True): + res_data = None + res_data = OlivOS.kaiheilaSDK.event_action.create_message( + target_event, + chat_id, + content_type, + content, + flag_direct = (False if chat_type == 'group' else True) + ) + if type(res_data) is not dict: + res_data.setdefault('data', {}) + if type(res_data['data']) is not dict: + res_data['data'] = {} + res_data['data'].update({ + 'chat_type': chat_type, + 'chat_id': chat_id, + 'content_type': content_type, + 'content': json.dumps(content, ensure_ascii=False) + }) + return res_data + + def create_message( + self, + chat_type:str, + chat_id:str, + content_type:int, + content:str, + 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_id, content_type, content, flag_log=True) + return res_data + @OlivOS.API.Event.callbackLogger('kaiheila:set_playgame_activity_music', ['music_name', 'singer', 'software']) def __set_playgame_activity_music(target_event, music_name, singer, software, flag_log=True): res_data = None From 9a5d3d6d0600156123695b9ddfff48f9e802aba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Tue, 28 Nov 2023 19:27:25 +0800 Subject: [PATCH 05/19] 0.11.25 --- OlivOS/infoAPI.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OlivOS/infoAPI.py b/OlivOS/infoAPI.py index 4b1b06ec..e7f4dace 100644 --- a/OlivOS/infoAPI.py +++ b/OlivOS/infoAPI.py @@ -17,8 +17,8 @@ import OlivOS -OlivOS_Version = '0.11.24' -OlivOS_SVN = 144 +OlivOS_Version = '0.11.25' +OlivOS_SVN = 145 # Compatible <= Plugin[compatible_svn] : Compatible # OldCompatible <= Plugin[compatible_svn] < Compatible : OldCompatible Warn From 5bd7087a15ba6af54898c56e1948bef43b2eee89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Tue, 28 Nov 2023 19:44:32 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E6=95=85=E9=9A=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/kaiheilaSDK.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/OlivOS/kaiheilaSDK.py b/OlivOS/kaiheilaSDK.py index 1f91814a..73ecaf1e 100644 --- a/OlivOS/kaiheilaSDK.py +++ b/OlivOS/kaiheilaSDK.py @@ -672,6 +672,8 @@ def send_msg(target_event, chat_id, message, flag_direct=False, message_type_in= this_msg.do_api() def create_message(target_event, chat_id, content_type:int, content:str, flag_direct=False): + res_data = OlivOS.contentAPI.api_result_data_template.universal_result() + res_data['active'] = True this_msg = None if flag_direct: this_msg = API.creatDirectMessage(get_SDK_bot_info_from_Event(target_event)) @@ -681,6 +683,12 @@ def create_message(target_event, chat_id, content_type:int, content:str, flag_di this_msg.data.type = content_type this_msg.data.content = content this_msg.do_api() + res_data['data'] = {} + res_data['data']['chat_type'] = 'private' if flag_direct else 'group' + res_data['data']['chat_id'] = str(chat_id) + res_data['data']['content_type'] = str(content_type) + res_data['data']['content'] = str(json.dumps(content, ensure_ascii = False)) + return res_data def get_login_info(target_event): res_data = OlivOS.contentAPI.api_result_data_template.get_login_info() @@ -910,16 +918,6 @@ def __create_message(target_event, chat_type:str, chat_id:str, content_type:int, content, flag_direct = (False if chat_type == 'group' else True) ) - if type(res_data) is not dict: - res_data.setdefault('data', {}) - if type(res_data['data']) is not dict: - res_data['data'] = {} - res_data['data'].update({ - 'chat_type': chat_type, - 'chat_id': chat_id, - 'content_type': content_type, - 'content': json.dumps(content, ensure_ascii=False) - }) return res_data def create_message( From de36377eef7568f4c0a3f195629e9ec5b6c5c10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Thu, 30 Nov 2023 17:22:39 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E6=96=B0=E5=A2=9EmhyVilaProto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdPartyModule/mhyVilaProto/__init__.py | 4 ++ .../mhyVilaProto/command_pb2.py | 46 ++++++++++++++ .../mhyVilaProto/model_pb2.py | 62 +++++++++++++++++++ .../mhyVilaProto/robot_event_message_pb2.py | 27 ++++++++ requirements.txt | 3 + requirements310.txt | 3 + requirements310_pure.txt | 3 + requirements310_win.txt | 3 + requirements_pure.txt | 3 + requirements_win.txt | 3 + 10 files changed, 157 insertions(+) create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/__init__.py create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/command_pb2.py create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/model_pb2.py create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/__init__.py b/OlivOS/thirdPartyModule/mhyVilaProto/__init__.py new file mode 100644 index 00000000..e3af63f0 --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +from . import command_pb2 as command +from . import model_pb2 as model +from . import robot_event_message_pb2 as robot_event_message diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/command_pb2.py b/OlivOS/thirdPartyModule/mhyVilaProto/command_pb2.py new file mode 100644 index 00000000..2faf44af --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/command_pb2.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: command.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rcommand.proto\x12\x08vila_bot\"&\n\nPHeartBeat\x12\x18\n\x10\x63lient_timestamp\x18\x01 \x01(\t\"9\n\x0fPHeartBeatReply\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x18\n\x10server_timestamp\x18\x02 \x01(\x04\"\xc0\x01\n\x06PLogin\x12\x0b\n\x03uid\x18\x01 \x01(\x04\x12\r\n\x05token\x18\x02 \x01(\t\x12\x10\n\x08platform\x18\x03 \x01(\x05\x12\x0e\n\x06\x61pp_id\x18\x04 \x01(\x05\x12\x11\n\tdevice_id\x18\x05 \x01(\t\x12\x0e\n\x06region\x18\x06 \x01(\t\x12(\n\x04meta\x18\x07 \x03(\x0b\x32\x1a.vila_bot.PLogin.MetaEntry\x1a+\n\tMetaEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"S\n\x0bPLoginReply\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x0b\n\x03msg\x18\x02 \x01(\t\x12\x18\n\x10server_timestamp\x18\x03 \x01(\x04\x12\x0f\n\x07\x63onn_id\x18\x04 \x01(\x04\"[\n\x07PLogout\x12\x0b\n\x03uid\x18\x01 \x01(\x04\x12\x10\n\x08platform\x18\x02 \x01(\x05\x12\x0e\n\x06\x61pp_id\x18\x03 \x01(\x05\x12\x11\n\tdevice_id\x18\x04 \x01(\t\x12\x0e\n\x06region\x18\x05 \x01(\t\":\n\x0cPLogoutReply\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x0b\n\x03msg\x18\x02 \x01(\t\x12\x0f\n\x07\x63onn_id\x18\x03 \x01(\x04\"(\n\x0b\x43ommonReply\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x0b\n\x03msg\x18\x02 \x01(\t\"(\n\x08PKickOff\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x0e\n\x06reason\x18\x02 \x01(\t*\xf8\x01\n\x07\x43ommand\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x10\n\x0c\x45XCHANGE_KEY\x10\x01\x12\r\n\tHEARTBEAT\x10\x02\x12\t\n\x05LOGIN\x10\x03\x12\n\n\x06LOGOUT\x10\x04\x12\x12\n\x0eP_EXCHANGE_KEY\x10\x05\x12\x0f\n\x0bP_HEARTBEAT\x10\x06\x12\x0b\n\x07P_LOGIN\x10\x07\x12\x0c\n\x08P_LOGOUT\x10\x08\x12\x0c\n\x08KICK_OFF\x10\x33\x12\x0c\n\x08SHUTDOWN\x10\x34\x12\x0e\n\nP_KICK_OFF\x10\x35\x12\x0e\n\nROOM_ENTER\x10<\x12\x0e\n\nROOM_LEAVE\x10=\x12\x0e\n\nROOM_CLOSE\x10>\x12\x0c\n\x08ROOM_MSG\x10?B6Z4gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_botb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'command_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'Z4gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_bot' + _PLOGIN_METAENTRY._options = None + _PLOGIN_METAENTRY._serialized_options = b'8\001' + _globals['_COMMAND']._serialized_start=644 + _globals['_COMMAND']._serialized_end=892 + _globals['_PHEARTBEAT']._serialized_start=27 + _globals['_PHEARTBEAT']._serialized_end=65 + _globals['_PHEARTBEATREPLY']._serialized_start=67 + _globals['_PHEARTBEATREPLY']._serialized_end=124 + _globals['_PLOGIN']._serialized_start=127 + _globals['_PLOGIN']._serialized_end=319 + _globals['_PLOGIN_METAENTRY']._serialized_start=276 + _globals['_PLOGIN_METAENTRY']._serialized_end=319 + _globals['_PLOGINREPLY']._serialized_start=321 + _globals['_PLOGINREPLY']._serialized_end=404 + _globals['_PLOGOUT']._serialized_start=406 + _globals['_PLOGOUT']._serialized_end=497 + _globals['_PLOGOUTREPLY']._serialized_start=499 + _globals['_PLOGOUTREPLY']._serialized_end=557 + _globals['_COMMONREPLY']._serialized_start=559 + _globals['_COMMONREPLY']._serialized_end=599 + _globals['_PKICKOFF']._serialized_start=601 + _globals['_PKICKOFF']._serialized_end=641 +# @@protoc_insertion_point(module_scope) diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/model_pb2.py b/OlivOS/thirdPartyModule/mhyVilaProto/model_pb2.py new file mode 100644 index 00000000..6d88dc9d --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/model_pb2.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: model.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0bmodel.proto\x12\x08vila_bot\"\xf8\x02\n\rRobotTemplate\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x65sc\x18\x03 \x01(\t\x12\x0c\n\x04icon\x18\x04 \x01(\t\x12\x31\n\x08\x63ommands\x18\x05 \x03(\x0b\x32\x1f.vila_bot.RobotTemplate.Command\x12>\n\x0f\x63ustom_settings\x18\x06 \x03(\x0b\x32%.vila_bot.RobotTemplate.CustomSetting\x12%\n\x1dis_allowed_add_to_other_villa\x18\x07 \x01(\x08\x1a\x15\n\x05Param\x12\x0c\n\x04\x64\x65sc\x18\x01 \x01(\t\x1aT\n\x07\x43ommand\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x65sc\x18\x02 \x01(\t\x12-\n\x06params\x18\x03 \x03(\x0b\x32\x1d.vila_bot.RobotTemplate.Param\x1a*\n\rCustomSetting\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\"D\n\x05Robot\x12)\n\x08template\x18\x01 \x01(\x0b\x32\x17.vila_bot.RobotTemplate\x12\x10\n\x08villa_id\x18\x02 \x01(\x04\"\xb7\x01\n\x10QuoteMessageInfo\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x12\x0f\n\x07msg_uid\x18\x02 \x01(\t\x12\x0f\n\x07send_at\x18\x03 \x01(\x03\x12\x10\n\x08msg_type\x18\x04 \x01(\t\x12\x12\n\nbot_msg_id\x18\x05 \x01(\t\x12\x14\n\x0c\x66rom_user_id\x18\x06 \x01(\x04\x12\x18\n\x10\x66rom_user_id_str\x18\x07 \x01(\t\x12\x1a\n\x12\x66rom_user_nickname\x18\x08 \x01(\t\"\xbd\x0f\n\nRobotEvent\x12\x1e\n\x05robot\x18\x01 \x01(\x0b\x32\x0f.vila_bot.Robot\x12,\n\x04type\x18\x02 \x01(\x0e\x32\x1e.vila_bot.RobotEvent.EventType\x12\x34\n\x0b\x65xtend_data\x18\x03 \x01(\x0b\x32\x1f.vila_bot.RobotEvent.ExtendData\x12\x12\n\ncreated_at\x18\x04 \x01(\x03\x12\n\n\x02id\x18\x05 \x01(\t\x12\x0f\n\x07send_at\x18\x06 \x01(\x03\x1a\xcf\x0c\n\nExtendData\x12\x43\n\njoin_villa\x18\x01 \x01(\x0b\x32-.vila_bot.RobotEvent.ExtendData.JoinVillaInfoH\x00\x12G\n\x0csend_message\x18\x02 \x01(\x0b\x32/.vila_bot.RobotEvent.ExtendData.SendMessageInfoH\x00\x12G\n\x0c\x63reate_robot\x18\x03 \x01(\x0b\x32/.vila_bot.RobotEvent.ExtendData.CreateRobotInfoH\x00\x12G\n\x0c\x64\x65lete_robot\x18\x04 \x01(\x0b\x32/.vila_bot.RobotEvent.ExtendData.DeleteRobotInfoH\x00\x12R\n\x12\x61\x64\x64_quick_emoticon\x18\x05 \x01(\x0b\x32\x34.vila_bot.RobotEvent.ExtendData.AddQuickEmoticonInfoH\x00\x12K\n\x0e\x61udit_callback\x18\x06 \x01(\x0b\x32\x31.vila_bot.RobotEvent.ExtendData.AuditCallbackInfoH\x00\x12T\n\x13\x63lick_msg_component\x18\x07 \x01(\x0b\x32\x35.vila_bot.RobotEvent.ExtendData.ClickMsgComponentInfoH\x00\x1a`\n\rJoinVillaInfo\x12\x10\n\x08join_uid\x18\x01 \x01(\x04\x12\x1a\n\x12join_user_nickname\x18\x02 \x01(\t\x12\x0f\n\x07join_at\x18\x03 \x01(\x03\x12\x10\n\x08villa_id\x18\x04 \x01(\x04\x1a\xfd\x01\n\x0fSendMessageInfo\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x12\x14\n\x0c\x66rom_user_id\x18\x02 \x01(\x04\x12\x0f\n\x07send_at\x18\x03 \x01(\x03\x12)\n\x0bobject_name\x18\x04 \x01(\x0e\x32\x14.vila_bot.ObjectName\x12\x0f\n\x07room_id\x18\x05 \x01(\x04\x12\x10\n\x08nickname\x18\x06 \x01(\t\x12\x0f\n\x07msg_uid\x18\x07 \x01(\t\x12\x12\n\nbot_msg_id\x18\x08 \x01(\t\x12\x10\n\x08villa_id\x18\t \x01(\x04\x12-\n\tquote_msg\x18\n \x01(\x0b\x32\x1a.vila_bot.QuoteMessageInfo\x1a#\n\x0f\x43reateRobotInfo\x12\x10\n\x08villa_id\x18\x01 \x01(\x04\x1a#\n\x0f\x44\x65leteRobotInfo\x12\x10\n\x08villa_id\x18\x01 \x01(\x04\x1a\xbc\x01\n\x14\x41\x64\x64QuickEmoticonInfo\x12\x10\n\x08villa_id\x18\x01 \x01(\x04\x12\x0f\n\x07room_id\x18\x02 \x01(\x04\x12\x0b\n\x03uid\x18\x03 \x01(\x04\x12\x13\n\x0b\x65moticon_id\x18\x04 \x01(\r\x12\x10\n\x08\x65moticon\x18\x05 \x01(\t\x12\x0f\n\x07msg_uid\x18\x06 \x01(\t\x12\x11\n\tis_cancel\x18\x07 \x01(\x08\x12\x12\n\nbot_msg_id\x18\x08 \x01(\t\x12\x15\n\remoticon_type\x18\t \x01(\r\x1a\x87\x02\n\x11\x41uditCallbackInfo\x12\x10\n\x08\x61udit_id\x18\x01 \x01(\t\x12\x12\n\nbot_tpl_id\x18\x02 \x01(\t\x12\x10\n\x08villa_id\x18\x03 \x01(\x04\x12\x0f\n\x07room_id\x18\x04 \x01(\x04\x12\x0f\n\x07user_id\x18\x05 \x01(\x04\x12\x14\n\x0cpass_through\x18\x06 \x01(\t\x12S\n\x0c\x61udit_result\x18\x07 \x01(\x0e\x32=.vila_bot.RobotEvent.ExtendData.AuditCallbackInfo.AuditResult\"-\n\x0b\x41uditResult\x12\x08\n\x04None\x10\x00\x12\x08\n\x04Pass\x10\x01\x12\n\n\x06Reject\x10\x02\x1a\xa6\x01\n\x15\x43lickMsgComponentInfo\x12\x10\n\x08villa_id\x18\x01 \x01(\x04\x12\x0f\n\x07room_id\x18\x02 \x01(\x04\x12\x14\n\x0c\x63omponent_id\x18\x03 \x01(\t\x12\x0f\n\x07msg_uid\x18\x04 \x01(\t\x12\x0b\n\x03uid\x18\x05 \x01(\x04\x12\x12\n\nbot_msg_id\x18\x06 \x01(\t\x12\x13\n\x0btemplate_id\x18\x07 \x01(\x04\x12\r\n\x05\x65xtra\x18\x08 \x01(\tB\x0c\n\nevent_data\"\xa7\x01\n\tEventType\x12\x18\n\x14UnknowRobotEventType\x10\x00\x12\r\n\tJoinVilla\x10\x01\x12\x0f\n\x0bSendMessage\x10\x02\x12\x0f\n\x0b\x43reateRobot\x10\x03\x12\x0f\n\x0b\x44\x65leteRobot\x10\x04\x12\x14\n\x10\x41\x64\x64QuickEmoticon\x10\x05\x12\x11\n\rAuditCallback\x10\x06\x12\x15\n\x11\x43lickMsgComponent\x10\x07*b\n\x08RoomType\x12\x13\n\x0fRoomTypeInvalid\x10\x00\x12\x14\n\x10RoomTypeChatRoom\x10\x01\x12\x14\n\x10RoomTypePostRoom\x10\x02\x12\x15\n\x11RoomTypeSceneRoom\x10\x03*6\n\nObjectName\x12\x14\n\x10UnknowObjectName\x10\x00\x12\x08\n\x04Text\x10\x01\x12\x08\n\x04Post\x10\x02\x42\x36Z4gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_botb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'model_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'Z4gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_bot' + _globals['_ROOMTYPE']._serialized_start=2644 + _globals['_ROOMTYPE']._serialized_end=2742 + _globals['_OBJECTNAME']._serialized_start=2744 + _globals['_OBJECTNAME']._serialized_end=2798 + _globals['_ROBOTTEMPLATE']._serialized_start=26 + _globals['_ROBOTTEMPLATE']._serialized_end=402 + _globals['_ROBOTTEMPLATE_PARAM']._serialized_start=251 + _globals['_ROBOTTEMPLATE_PARAM']._serialized_end=272 + _globals['_ROBOTTEMPLATE_COMMAND']._serialized_start=274 + _globals['_ROBOTTEMPLATE_COMMAND']._serialized_end=358 + _globals['_ROBOTTEMPLATE_CUSTOMSETTING']._serialized_start=360 + _globals['_ROBOTTEMPLATE_CUSTOMSETTING']._serialized_end=402 + _globals['_ROBOT']._serialized_start=404 + _globals['_ROBOT']._serialized_end=472 + _globals['_QUOTEMESSAGEINFO']._serialized_start=475 + _globals['_QUOTEMESSAGEINFO']._serialized_end=658 + _globals['_ROBOTEVENT']._serialized_start=661 + _globals['_ROBOTEVENT']._serialized_end=2642 + _globals['_ROBOTEVENT_EXTENDDATA']._serialized_start=857 + _globals['_ROBOTEVENT_EXTENDDATA']._serialized_end=2472 + _globals['_ROBOTEVENT_EXTENDDATA_JOINVILLAINFO']._serialized_start=1406 + _globals['_ROBOTEVENT_EXTENDDATA_JOINVILLAINFO']._serialized_end=1502 + _globals['_ROBOTEVENT_EXTENDDATA_SENDMESSAGEINFO']._serialized_start=1505 + _globals['_ROBOTEVENT_EXTENDDATA_SENDMESSAGEINFO']._serialized_end=1758 + _globals['_ROBOTEVENT_EXTENDDATA_CREATEROBOTINFO']._serialized_start=1760 + _globals['_ROBOTEVENT_EXTENDDATA_CREATEROBOTINFO']._serialized_end=1795 + _globals['_ROBOTEVENT_EXTENDDATA_DELETEROBOTINFO']._serialized_start=1797 + _globals['_ROBOTEVENT_EXTENDDATA_DELETEROBOTINFO']._serialized_end=1832 + _globals['_ROBOTEVENT_EXTENDDATA_ADDQUICKEMOTICONINFO']._serialized_start=1835 + _globals['_ROBOTEVENT_EXTENDDATA_ADDQUICKEMOTICONINFO']._serialized_end=2023 + _globals['_ROBOTEVENT_EXTENDDATA_AUDITCALLBACKINFO']._serialized_start=2026 + _globals['_ROBOTEVENT_EXTENDDATA_AUDITCALLBACKINFO']._serialized_end=2289 + _globals['_ROBOTEVENT_EXTENDDATA_AUDITCALLBACKINFO_AUDITRESULT']._serialized_start=2244 + _globals['_ROBOTEVENT_EXTENDDATA_AUDITCALLBACKINFO_AUDITRESULT']._serialized_end=2289 + _globals['_ROBOTEVENT_EXTENDDATA_CLICKMSGCOMPONENTINFO']._serialized_start=2292 + _globals['_ROBOTEVENT_EXTENDDATA_CLICKMSGCOMPONENTINFO']._serialized_end=2458 + _globals['_ROBOTEVENT_EVENTTYPE']._serialized_start=2475 + _globals['_ROBOTEVENT_EVENTTYPE']._serialized_end=2642 +# @@protoc_insertion_point(module_scope) diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py b/OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py new file mode 100644 index 00000000..330d5c20 --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: robot_event_message.proto +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +import model_pb2 as model__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19robot_event_message.proto\x12\x08vila_bot\x1a\x0bmodel.proto\"8\n\x11RobotEventMessage\x12#\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x14.vila_bot.RobotEventB6Z4gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_botb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'robot_event_message_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'Z4gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_bot' + _globals['_ROBOTEVENTMESSAGE']._serialized_start=52 + _globals['_ROBOTEVENTMESSAGE']._serialized_end=108 +# @@protoc_insertion_point(module_scope) diff --git a/requirements.txt b/requirements.txt index 9615364a..e8f92b30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,3 +25,6 @@ prompt_toolkit regex rich filetype +grpcio +grpcio-tools +protobuf diff --git a/requirements310.txt b/requirements310.txt index bb03ff52..466dd2cb 100644 --- a/requirements310.txt +++ b/requirements310.txt @@ -25,3 +25,6 @@ prompt_toolkit regex rich filetype +grpcio +grpcio-tools +protobuf diff --git a/requirements310_pure.txt b/requirements310_pure.txt index cbe91be6..d07efc9a 100644 --- a/requirements310_pure.txt +++ b/requirements310_pure.txt @@ -16,3 +16,6 @@ brotli pyjson5 pywebview filetype +grpcio +grpcio-tools +protobuf diff --git a/requirements310_win.txt b/requirements310_win.txt index 7fbd12fa..a2667e68 100644 --- a/requirements310_win.txt +++ b/requirements310_win.txt @@ -27,3 +27,6 @@ regex rich pywebview filetype +grpcio +grpcio-tools +protobuf diff --git a/requirements_pure.txt b/requirements_pure.txt index bd61f6a7..8e85c3b7 100644 --- a/requirements_pure.txt +++ b/requirements_pure.txt @@ -16,3 +16,6 @@ brotli pyjson5 pywebview filetype +grpcio +grpcio-tools +protobuf diff --git a/requirements_win.txt b/requirements_win.txt index 201b635d..a3a372ff 100644 --- a/requirements_win.txt +++ b/requirements_win.txt @@ -27,3 +27,6 @@ regex rich pywebview filetype +grpcio +grpcio-tools +protobuf From ce70ecb767b049ad1c30d840ca4efd84b63d7524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Thu, 30 Nov 2023 17:31:28 +0800 Subject: [PATCH 08/19] Update robot_event_message_pb2.py --- OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py b/OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py index 330d5c20..5b2a7d56 100644 --- a/OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py +++ b/OlivOS/thirdPartyModule/mhyVilaProto/robot_event_message_pb2.py @@ -11,7 +11,7 @@ _sym_db = _symbol_database.Default() -import model_pb2 as model__pb2 +from . import model_pb2 as model__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19robot_event_message.proto\x12\x08vila_bot\x1a\x0bmodel.proto\"8\n\x11RobotEventMessage\x12#\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x14.vila_bot.RobotEventB6Z4gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_botb\x06proto3') From 18fa422c793ff3f4fb2cf7c3cf64cebfbafb7903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Thu, 30 Nov 2023 17:56:05 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E4=BE=9D=E8=B5=96=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 6 +++--- requirements_pure.txt | 6 +++--- requirements_win.txt | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index e8f92b30..0eb3d01b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,6 +25,6 @@ prompt_toolkit regex rich filetype -grpcio -grpcio-tools -protobuf +grpcio==1.51.3 +grpcio-tools==1.51.3 +protobuf==4.24.4 diff --git a/requirements_pure.txt b/requirements_pure.txt index 8e85c3b7..f98239a1 100644 --- a/requirements_pure.txt +++ b/requirements_pure.txt @@ -16,6 +16,6 @@ brotli pyjson5 pywebview filetype -grpcio -grpcio-tools -protobuf +grpcio==1.51.3 +grpcio-tools==1.51.3 +protobuf==4.24.4 diff --git a/requirements_win.txt b/requirements_win.txt index a3a372ff..35ccf182 100644 --- a/requirements_win.txt +++ b/requirements_win.txt @@ -27,6 +27,6 @@ regex rich pywebview filetype -grpcio -grpcio-tools -protobuf +grpcio==1.51.3 +grpcio-tools==1.51.3 +protobuf==4.24.4 From 90ac8361c89e9f098d4f69158d0af26c42262065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Fri, 1 Dec 2023 01:36:45 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=80=A7=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/__init__.py | 2 + OlivOS/bootAPI.py | 22 +++ OlivOS/bootDataAPI.py | 13 ++ OlivOS/mhyVilaLinkServerAPI.py | 105 ++++++++++++++ OlivOS/mhyVilaSDK.py | 246 +++++++++++++++++++++++++++++++++ OlivOS/multiLoginUIAPI.py | 29 ++-- 6 files changed, 408 insertions(+), 9 deletions(-) create mode 100644 OlivOS/mhyVilaLinkServerAPI.py create mode 100644 OlivOS/mhyVilaSDK.py diff --git a/OlivOS/__init__.py b/OlivOS/__init__.py index 0aa31342..86b36715 100644 --- a/OlivOS/__init__.py +++ b/OlivOS/__init__.py @@ -64,6 +64,8 @@ from . import fanbookPollServerAPI from . import kaiheilaSDK from . import kaiheilaLinkServerAPI +from . import mhyVilaSDK +from . import mhyVilaLinkServerAPI from . import biliLiveSDK from . import biliLiveLinkServerAPI from . import updateAPI diff --git a/OlivOS/bootAPI.py b/OlivOS/bootAPI.py index f402264c..44863cbf 100644 --- a/OlivOS/bootAPI.py +++ b/OlivOS/bootAPI.py @@ -450,6 +450,28 @@ def start(self): ) Proc_Proc_dict[tmp_Proc_name] = Proc_dict[tmp_Proc_name].start_unity( tmp_proc_mode) + elif basic_conf_models_this['type'] == 'mhyVila_link': + flag_need_enable = False + for bot_info_key in plugin_bot_info_dict: + if plugin_bot_info_dict[bot_info_key].platform['sdk'] == 'mhyVila_link': + flag_need_enable = True + if not flag_need_enable: + continue + for bot_info_key in plugin_bot_info_dict: + if plugin_bot_info_dict[bot_info_key].platform['sdk'] == 'mhyVila_link': + tmp_Proc_name = basic_conf_models_this['name'] + '=' + bot_info_key + Proc_dict[tmp_Proc_name] = OlivOS.mhyVilaLinkServerAPI.server( + Proc_name=tmp_Proc_name, + scan_interval=basic_conf_models_this['interval'], + dead_interval=basic_conf_models_this['dead_interval'], + rx_queue=None, + tx_queue=multiprocessing_dict[basic_conf_models_this['tx_queue']], + logger_proc=Proc_dict[basic_conf_models_this['logger_proc']], + bot_info_dict=plugin_bot_info_dict[bot_info_key], + debug_mode=False + ) + Proc_Proc_dict[tmp_Proc_name] = Proc_dict[tmp_Proc_name].start_unity( + tmp_proc_mode) elif basic_conf_models_this['type'] == 'biliLive_link': flag_need_enable = False for bot_info_key in plugin_bot_info_dict: diff --git a/OlivOS/bootDataAPI.py b/OlivOS/bootDataAPI.py index 6ca1522e..8fbece2b 100644 --- a/OlivOS/bootDataAPI.py +++ b/OlivOS/bootDataAPI.py @@ -45,6 +45,7 @@ "OlivOS_telegram_poll", "OlivOS_fanbook_poll", "OlivOS_kaiheila_link", + "OlivOS_mhyVila_link", "OlivOS_dodo_link", "OlivOS_biliLive_link", "OlivOS_update_check" @@ -86,6 +87,7 @@ "OlivOS_telegram_poll", "OlivOS_fanbook_poll", "OlivOS_kaiheila_link", + "OlivOS_mhyVila_link", "OlivOS_dodo_link", "OlivOS_biliLive_link", ] @@ -107,6 +109,7 @@ "telegram_poll", "fanbook_poll", "kaiheila_link", + "mhyVila_link", "dodo_link", "biliLive_link", ] @@ -359,6 +362,16 @@ "logger_proc": "OlivOS_logger", "debug": False }, + "OlivOS_mhyVila_link": { + "enable": True, + "name": "OlivOS_mhyVila_link", + "type": "mhyVila_link", + "interval": 0.2, + "dead_interval": 1, + "tx_queue": "OlivOS_rx_queue", + "logger_proc": "OlivOS_logger", + "debug": False + }, "OlivOS_telegram_poll": { "enable": True, "name": "OlivOS_telegram_poll", diff --git a/OlivOS/mhyVilaLinkServerAPI.py b/OlivOS/mhyVilaLinkServerAPI.py new file mode 100644 index 00000000..4bf6536d --- /dev/null +++ b/OlivOS/mhyVilaLinkServerAPI.py @@ -0,0 +1,105 @@ +# -*- encoding: utf-8 -*- +''' +@ _______________________ ________________ +@ __ __ \__ /____ _/_ | / /_ __ \_ ___/ +@ _ / / /_ / __ / __ | / /_ / / /____ \ +@ / /_/ /_ /____/ / __ |/ / / /_/ /____/ / +@ \____/ /_____/___/ _____/ \____/ /____/ +@ +@File : OlivOS/mhyVilaLinkServerAPI.py +@Author : lunzhiPenxil仑质 +@Contact : lunzhipenxil@gmail.com +@License : AGPL3 +@Copyright : (C) 2020-2023, OlivOS-Team +@Desc : None +''' + +import multiprocessing +import threading +import time +import json +import websocket +import uuid +import requests as req +import traceback + +import OlivOS + + +class server(OlivOS.API.Proc_templet): + def __init__(self, Proc_name, scan_interval=0.001, dead_interval=1, rx_queue=None, tx_queue=None, logger_proc=None, + debug_mode=False, bot_info_dict=None): + OlivOS.API.Proc_templet.__init__( + self, + Proc_name=Proc_name, + Proc_type='mhyVila_link', + scan_interval=scan_interval, + dead_interval=dead_interval, + rx_queue=rx_queue, + tx_queue=tx_queue, + logger_proc=logger_proc + ) + self.Proc_config['debug_mode'] = debug_mode + self.Proc_data['bot_info_dict'] = bot_info_dict + self.Proc_data['extend_data'] = { + 'websocket_url': None, + 'pulse_interval': None, + 'last_s': None, + 'ws_obj': None, + 'ws_item': None + } + self.Proc_data['platform_bot_info_dict'] = None + + def run(self): + self.log(2, 'OlivOS kaiheila link server [' + self.Proc_name + '] is running') + while True: + api_obj = OlivOS.mhyVilaSDK.API.getWebsocketInfo( + OlivOS.mhyVilaSDK.get_SDK_bot_info_from_Plugin_bot_info( + self.Proc_data['bot_info_dict'] + ) + ) + try: + api_obj.do_api('GET') + api_obj_json = json.loads(api_obj.res) + if api_obj_json['retcode'] == 0: + self.Proc_data['extend_data']['websocket_url'] = api_obj_json['data']['websocket_url'] + else: + self.Proc_data['extend_data']['websocket_url'] = None + except: + self.Proc_data['extend_data']['websocket_url'] = None + print(self.Proc_data['extend_data']['websocket_url']) + #if self.Proc_data['extend_data']['websocket_url'] is not None: + # self.run_websocket_rx_connect_start() + time.sleep(10) + + def on_message(self, ws, message): + try: + print(message) + except: + pass + + def on_error(self, ws, error): + self.log(0, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link error') + + def on_close(self, ws, close_status_code, close_msg): + self.log(0, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link close') + + def on_open(self, ws): + self.log(2, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link start') + + def run_websocket_rx_connect_start(self): + websocket.enableTrace(False) + ws = websocket.WebSocketApp( + self.Proc_data['extend_data']['websocket_url'], + on_open=self.on_open, + on_message=self.on_message, + on_error=self.on_error, + on_close=self.on_close + ) + self.Proc_data['extend_data']['ws_obj'] = ws + self.Proc_data['extend_data']['ws_item'] = uuid.uuid4() + ws.run_forever() + self.Proc_data['extend_data']['pulse_interval'] = None + self.Proc_data['extend_data']['ws_obj'] = None + self.Proc_data['extend_data']['ws_item'] = None + self.log(2, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link lost') diff --git a/OlivOS/mhyVilaSDK.py b/OlivOS/mhyVilaSDK.py new file mode 100644 index 00000000..3eb31f24 --- /dev/null +++ b/OlivOS/mhyVilaSDK.py @@ -0,0 +1,246 @@ +# -*- encoding: utf-8 -*- +''' +@ _______________________ ________________ +@ __ __ \__ /____ _/_ | / /_ __ \_ ___/ +@ _ / / /_ / __ / __ | / /_ / / /____ \ +@ / /_/ /_ /____/ / __ |/ / / /_/ /____/ / +@ \____/ /_____/___/ _____/ \____/ /____/ +@ +@File : OlivOS/mhyVilaSDK.py +@Author : lunzhiPenxil仑质 +@Contact : lunzhipenxil@gmail.com +@License : AGPL3 +@Copyright : (C) 2020-2023, OlivOS-Team +@Desc : None +''' + +import sys +import json +import requests as req +import time +from requests_toolbelt import MultipartEncoder +import uuid +import traceback +import base64 +from urllib import parse +import hashlib +import hmac +import struct + +import OlivOS +import OlivOS.thirdPartyModule.mhyVilaProto as mhyVilaProto + +sdkAPIHost = { + 'default': 'https://bbs-api.miyoushe.com' +} + +sdkAPIRoute = { + 'platform': '/vila/api/bot/platform' +} + +sdkAPIRouteTemp = {} + +sdkSubSelfInfo = {} + + +class bot_info_T(object): + def __init__( + self, + id = -1, + password = '', + access_token = '', + port = 0 + ): + self.bot_id = id + self.secret = password + self.pub_key = access_token + self.vila_id = port + self.debug_mode = False + self.debug_logger = None + +def get_SDK_bot_info_from_Plugin_bot_info(plugin_bot_info): + res = bot_info_T( + id = plugin_bot_info.id, + password = plugin_bot_info.password, + access_token = plugin_bot_info.post_info.access_token, + port = plugin_bot_info.post_info.port + ) + res.debug_mode = plugin_bot_info.debug_mode + return res + +def get_SDK_bot_info_from_Event(target_event): + return get_SDK_bot_info_from_Plugin_bot_info(target_event.bot_info) + + +''' +对于WEBSOCKET接口的PAYLOAD实现 +''' + +class payload_template(object): + def __init__(self, raw:'bytearray|None'=None): + self.active = True + self.raw = raw + self.is_rx = False + if self.raw is not None: + self.is_rx = True + self.magicHeader = self.magicHeader_T() + self.dataHeader = self.dataHeader_T() + self.dataDataBody:bytearray = b'' + self.data = None + self.dataProto = None + + class magicHeader_T(object): + def __init__(self): + self.HeaderLen:int = 8 + self.Magic:bytearray = b'\xBA\xBE\xFA\xCE' + self.DataLen:int = 0 + + class dataHeader_T(object): + def __init__(self): + self.HeaderLen:int = 24 # uint32 变长头总长度,变长头部分所有字段(包括HeaderLen本身)的总长度。 注:也就是说这玩意每个版本是固定的 + self.ID:int = 0 # uint64 协议包序列ID,同一条连接上的发出的协议包应该单调递增,相同序列ID且Flag字段相同的包应该被认为是同一个包 + self.Flag:int = 1 # uint32 配合bizType使用,用于标识同一个bizType协议的方向。 + # 用 1 代表主动发到服务端的request包 + # 用 2 代表针对某个request包回应的response包 + self.BizType:int = 0 # uint32 消息体的业务类型,用于标识Body字段中的消息所属业务类型 + self.AppId:int = 104 # int32 应用标识。固定为 104 + + def __dump_dataDataBody(self): + if self.data is not None \ + and self.dataProto is not None: + self.dataDataBody = self.dataProto(**self.data.__dict__).SerializeToString() + return self.dataDataBody + + def __update_DataLen(self): + self.magicHeader.DataLen = self.magicHeader.HeaderLen + self.dataHeader.HeaderLen + len(self.dataDataBody) + return self.magicHeader.DataLen + + def __dump_magicHeader(self): + return struct.pack( + '<4sI', + self.magicHeader.Magic, + self.magicHeader.DataLen + ) + + def __dump_dataHeader(self): + return struct.pack( + ' Date: Fri, 1 Dec 2023 01:56:47 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0mhyVilaProto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/mhyVilaSDK.py | 15 +- .../mhyVilaProto/protoFile/command.proto | 113 +++++++++++++ .../mhyVilaProto/protoFile/model.proto | 158 ++++++++++++++++++ .../protoFile/robot_event_message.proto | 10 ++ 4 files changed, 287 insertions(+), 9 deletions(-) create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/protoFile/command.proto create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/protoFile/model.proto create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/protoFile/robot_event_message.proto diff --git a/OlivOS/mhyVilaSDK.py b/OlivOS/mhyVilaSDK.py index 3eb31f24..761f7fac 100644 --- a/OlivOS/mhyVilaSDK.py +++ b/OlivOS/mhyVilaSDK.py @@ -158,12 +158,12 @@ def __init__(self): class data_T(object): def __init__(self): - self.uid:int = 1 - self.token:str = '2' - self.platform:int = 3 - self.app_id:int = 4 - self.device_id:str = '5' - self.region:str = '6' + self.uid:int = 0 + self.token:str = '' + self.platform:int = 0 + self.app_id:int = 0 + self.device_id:str = '' + self.region:str = '' ''' @@ -241,6 +241,3 @@ def __init__(self): self.room_id = -1 self.object_name = 'MHY:Text' self.msg_content = '' - -# test -print(PAYLOAD.PLogin().dump()) diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/command.proto b/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/command.proto new file mode 100644 index 00000000..d85953d0 --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/command.proto @@ -0,0 +1,113 @@ +syntax = "proto3"; + +package vila_bot; + +option go_package = "gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_bot"; + +enum Command { + UNKNOWN = 0; + + EXCHANGE_KEY = 1; + HEARTBEAT = 2; + LOGIN = 3; + LOGOUT = 4; + + P_EXCHANGE_KEY = 5; + P_HEARTBEAT = 6; + P_LOGIN = 7; + P_LOGOUT = 8; + + KICK_OFF = 51; + SHUTDOWN = 52; + P_KICK_OFF = 53; + + ROOM_ENTER = 60; + ROOM_LEAVE = 61; + ROOM_CLOSE = 62; + ROOM_MSG = 63; + +} + +// 心跳请求命令字 +message PHeartBeat { + // 客户端时间戳,精确到ms + string client_timestamp = 1; +} + +// 心跳返回 +message PHeartBeatReply { + // 错误码 非0表示失败 + int32 code = 1; + // 服务端时间戳,精确到ms + uint64 server_timestamp = 2; +} + +// 登录命令 +message PLogin { + // 长连接侧唯一id,uint64格式 + uint64 uid = 1; + // 用于业务后端验证的token + string token = 2; + // 客户端操作平台枚举 + int32 platform = 3; + // 业务所在客户端应用标识,用于在同一个客户端隔离不同业务的长连接通道。 + int32 app_id = 4; + string device_id = 5; + // 区域划分字段,通过uid+app_id+platform+region四个字段唯一确定一条长连接 + string region = 6; + // 长连内部的扩展字段,是个map + map meta = 7; +} + + +// 登录命令返回 +message PLoginReply { + // 错误码 非0表示失败 + int32 code = 1; + // 错误信息 + string msg = 2; + // 服务端时间戳,精确到ms + uint64 server_timestamp = 3; + // 唯一连接ID + uint64 conn_id = 4; +} + +// 登出命令字 +message PLogout { + // 长连接侧唯一id,uint64格式 + uint64 uid = 1; + // 客户端操作平台枚举 + int32 platform = 2; + // 业务所在客户端应用标识,用于在同一个客户端隔离不同业务的长连接通道。 + int32 app_id = 3; + // 客户端设备唯一标识 + string device_id = 4; + // 区域划分字段,通过uid+app_id+platform+region四个字段唯一确定一条长连接 + string region = 5; +} + +// 登出命令返回 +message PLogoutReply { + // 错误码 非0表示失败 + int32 code = 1; + // 错误信息 + string msg = 2; + // 连接id + uint64 conn_id = 3; +} + +// 通用返回 +message CommonReply { + // 错误码 非0表示失败 + int32 code = 1; + // 错误信息 + string msg = 2; +} + +// 踢出连接协议 +message PKickOff{ + // 踢出原因状态码 + int32 code = 1; + // 状态码对应的文案 + string reason = 2; +} \ No newline at end of file diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/model.proto b/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/model.proto new file mode 100644 index 00000000..5e2e68e1 --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/model.proto @@ -0,0 +1,158 @@ +syntax = "proto3"; + +package vila_bot; +option go_package="gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_bot"; + +enum RoomType { + RoomTypeInvalid = 0; + RoomTypeChatRoom = 1; // 聊天放假 + RoomTypePostRoom = 2; // 帖子房间 + RoomTypeSceneRoom = 3; // 场景房间 +} + +message RobotTemplate { + message Param { + string desc = 1; // 参数描述 + } + + message Command { + string name = 1; // 指令名称 + string desc = 2; // 指令描述 + repeated Param params = 3; // 指令参数 + } + message CustomSetting { + string name = 1; // 自定义设置项名称 + string url = 2; // 自定义设置项页面 + } + + string id = 1; // 机器人模板 id + string name = 2; // 机器人名称 + string desc = 3; // 机器人描述 + string icon = 4; // 机器人 icon + repeated Command commands = 5; // 指令列表 + repeated CustomSetting custom_settings = 6; // 自定义设置项 + bool is_allowed_add_to_other_villa = 7; // 是否允许添加到其他大别野 +} + +enum ObjectName { + UnknowObjectName = 0 ; + Text = 1; // 文本消息 + Post = 2; // 帖子消息 +} + + +message Robot { + RobotTemplate template = 1; // 所属机器人模板 + uint64 villa_id = 2; // 大别野 id +} + +message QuoteMessageInfo { + string content = 1; // 消息内容 + string msg_uid = 2; // 消息msg_uid + int64 send_at = 3; + string msg_type = 4; // 消息类型 + string bot_msg_id = 5; // 如果是机器人消息,则该字段不为空字符串 + uint64 from_user_id = 6; // 发送者id + string from_user_id_str = 7; // 发送者id(string) + string from_user_nickname = 8; // 发送者昵称 +} + +message RobotEvent { + enum EventType { + UnknowRobotEventType = 0; + JoinVilla = 1; // 加入大别野 + SendMessage = 2; // 发送消息 + CreateRobot = 3; // 大别野添加机器人实例 + DeleteRobot = 4; // 大别野删除机器人实例 + AddQuickEmoticon = 5; // 表情表态 + AuditCallback = 6; // 审核结果回调 + ClickMsgComponent = 7; // 点击消息组件 + } + + message ExtendData { + message JoinVillaInfo { + uint64 join_uid = 1; // 加入用户 uid + string join_user_nickname = 2; // 加入用户昵称 + int64 join_at = 3; // 加入时间 [待废弃, 可以改用 RobotEvent.created_at] + uint64 villa_id = 4; // 大别野 id + } + + message SendMessageInfo { + string content = 1; // 消息内容 + uint64 from_user_id = 2; // 发送人 uid + int64 send_at = 3; // 发送时间 [待废弃, 可以改用 RobotEvent.created_at] + ObjectName object_name = 4; // 消息类型 + uint64 room_id = 5; // 房间 id + string nickname = 6; // 昵称 + string msg_uid = 7; // 消息 id + string bot_msg_id = 8; // 如果被回复的消息从属于机器人,则该字段不为空字符串 + uint64 villa_id = 9; // 大别野 id + QuoteMessageInfo quote_msg = 10; // 引用消息的内容 + } + + message CreateRobotInfo { + uint64 villa_id = 1; // 创建机器人实例的大别野 id + } + + + message DeleteRobotInfo { + uint64 villa_id = 1; + } + + message AddQuickEmoticonInfo { + uint64 villa_id = 1; // 大别野 id + uint64 room_id = 2; // 房间 id + uint64 uid = 3; // 回复用户 id + uint32 emoticon_id = 4; // 表情 id + string emoticon = 5; // 表情 + string msg_uid = 6; // 消息 id + bool is_cancel = 7; // 是否是取消表情 + string bot_msg_id = 8; // 如果被回复的消息从属于机器人,则该字段不为空字符串 + uint32 emoticon_type = 9; // 表情类型 + } + + message AuditCallbackInfo { + enum AuditResult { + None = 0; + Pass = 1; + Reject = 2; + } + + string audit_id = 1; // 机器人平台审核事件 id + string bot_tpl_id = 2; // 机器人 id + uint64 villa_id = 3; // 大别野 id + uint64 room_id = 4; // 房间 id + uint64 user_id = 5; // 用户 id + string pass_through = 6; // 透传字段 + AuditResult audit_result = 7; // 审核结果 + } + + message ClickMsgComponentInfo { + uint64 villa_id = 1; + uint64 room_id = 2; + string component_id = 3; // 自定义组件id + string msg_uid = 4; + uint64 uid = 5; + string bot_msg_id = 6; + uint64 template_id = 7; // 模板id + string extra = 8; // 机器人自定义透传数据 + } + + oneof event_data { + JoinVillaInfo join_villa = 1; // 加入大别野扩展信息 + SendMessageInfo send_message = 2; // 发送消息扩展信息 + CreateRobotInfo create_robot = 3; // 添加机器人扩展信息 + DeleteRobotInfo delete_robot = 4; // 删除机器人扩展信息 + AddQuickEmoticonInfo add_quick_emoticon = 5; // 表情表态扩展信息 + AuditCallbackInfo audit_callback = 6; // 审核回调信息 + ClickMsgComponentInfo click_msg_component = 7; // 点击消息组件回传 + } + } + + Robot robot = 1; // 事件相关机器人 + EventType type = 2; // 事件类型 + ExtendData extend_data = 3; // 事件拓展信息 + int64 created_at = 4; // 事件发生时间 + string id = 5; // 事件 id + int64 send_at = 6; // 事件消息投递时间 +} \ No newline at end of file diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/robot_event_message.proto b/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/robot_event_message.proto new file mode 100644 index 00000000..29149a49 --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/protoFile/robot_event_message.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package vila_bot; +option go_package="gopkg.mihoyo.com/vila-bot-go/proto/vila_bot;vila_bot"; + +import 'model.proto'; + +message RobotEventMessage { + RobotEvent event = 1; +} From 74d8d1d4f2f1cf59adee2b3f85997edbb7063dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Fri, 1 Dec 2023 02:20:12 +0800 Subject: [PATCH 12/19] Update mhyVilaSDK.py --- OlivOS/mhyVilaSDK.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OlivOS/mhyVilaSDK.py b/OlivOS/mhyVilaSDK.py index 761f7fac..544139b4 100644 --- a/OlivOS/mhyVilaSDK.py +++ b/OlivOS/mhyVilaSDK.py @@ -147,7 +147,7 @@ def load(self, data, is_rx): class PAYLOAD(object): class rxPacket(payload_template): def __init__(self, raw): - payload_template.__init__(self, data, True) + payload_template.__init__(self, raw, True) # 登录命令 class PLogin(payload_template): From 2c73c302f4c9ff543b96a36125eebc198676c087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Sat, 2 Dec 2023 00:24:31 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E7=B1=B3=E6=B8=B8=E7=A4=BE=E5=A4=A7?= =?UTF-8?q?=E5=88=AB=E9=87=8E=E5=9F=BA=E6=9C=AC=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivOS/API.py | 10 + OlivOS/messageAPI.py | 8 + OlivOS/mhyVilaLinkServerAPI.py | 107 +++++-- OlivOS/mhyVilaSDK.py | 292 ++++++++++++++++-- OlivOS/thirdPartyModule/__init__.py | 1 + .../thirdPartyModule/mhyVilaProto/__init__.py | 1 + OlivOS/thirdPartyModule/mhyVilaProto/tools.py | 1 + 7 files changed, 382 insertions(+), 38 deletions(-) create mode 100644 OlivOS/thirdPartyModule/mhyVilaProto/tools.py diff --git a/OlivOS/API.py b/OlivOS/API.py index 1ff6a4ad..920c41af 100644 --- a/OlivOS/API.py +++ b/OlivOS/API.py @@ -197,6 +197,8 @@ def get_Event_from_SDK(self): OlivOS.contentAPI.get_Event_from_fake_SDK(self) elif self.sdk_event_type is OlivOS.kaiheilaSDK.event: OlivOS.kaiheilaSDK.get_Event_from_SDK(self) + elif self.sdk_event_type is OlivOS.mhyVilaSDK.event: + OlivOS.mhyVilaSDK.get_Event_from_SDK(self) elif self.sdk_event_type is OlivOS.qqRedSDK.event: OlivOS.qqRedSDK.get_Event_from_SDK(self) elif self.sdk_event_type is OlivOS.hackChatSDK.event: @@ -894,6 +896,14 @@ def __send(self, send_type, target_id, message, host_id=None, flag_log=True): OlivOS.kaiheilaSDK.event_action.send_msg(self, target_id, tmp_message, flag_direct=False) elif flag_type == 'private': OlivOS.kaiheilaSDK.event_action.send_msg(self, target_id, tmp_message, flag_direct=True) + elif self.platform['sdk'] == 'mhyVila_link': + if flag_type == 'group': + if host_id is not None: + OlivOS.mhyVilaSDK.event_action.send_group_msg(self, target_id, tmp_message, host_id=host_id) + elif 'host_id' in self.data.__dict__: + OlivOS.mhyVilaSDK.event_action.send_group_msg(self, target_id, tmp_message, host_id=self.data.host_id) + elif flag_type == 'private': + pass elif self.platform['sdk'] == 'hackChat_link': OlivOS.hackChatSDK.event_action.send_msg(self, tmp_message, self.plugin_info['control_queue']) elif self.platform['sdk'] == 'biliLive_link': diff --git a/OlivOS/messageAPI.py b/OlivOS/messageAPI.py index cfc55137..598bd5b4 100644 --- a/OlivOS/messageAPI.py +++ b/OlivOS/messageAPI.py @@ -83,6 +83,14 @@ 'text': 'olivos_para' } }, + 'mhyVila': { + 'mhyVila_link': { + 'default': 'olivos_string', + 'public': 'olivos_string', + 'private': 'olivos_string', + 'sandbox': 'olivos_string' + } + }, 'discord': { 'discord_link': { 'default': 'olivos_para' diff --git a/OlivOS/mhyVilaLinkServerAPI.py b/OlivOS/mhyVilaLinkServerAPI.py index 4bf6536d..89213b08 100644 --- a/OlivOS/mhyVilaLinkServerAPI.py +++ b/OlivOS/mhyVilaLinkServerAPI.py @@ -46,46 +46,111 @@ def __init__(self, Proc_name, scan_interval=0.001, dead_interval=1, rx_queue=Non 'pulse_interval': None, 'last_s': None, 'ws_obj': None, - 'ws_item': None + 'ws_item': None, + 'ws_PLogin': { + 'uid': 0, + 'token': '', + 'platform': 3, + 'app_id': 104, + 'device_id': '' + } } self.Proc_data['platform_bot_info_dict'] = None def run(self): - self.log(2, 'OlivOS kaiheila link server [' + self.Proc_name + '] is running') + self.log(2, 'OlivOS mhyVila link server [' + self.Proc_name + '] is running') while True: - api_obj = OlivOS.mhyVilaSDK.API.getWebsocketInfo( - OlivOS.mhyVilaSDK.get_SDK_bot_info_from_Plugin_bot_info( - self.Proc_data['bot_info_dict'] - ) + sdk_bot_info = OlivOS.mhyVilaSDK.get_SDK_bot_info_from_Plugin_bot_info( + self.Proc_data['bot_info_dict'] ) + api_obj = OlivOS.mhyVilaSDK.API.getWebsocketInfo(sdk_bot_info) try: api_obj.do_api('GET') api_obj_json = json.loads(api_obj.res) if api_obj_json['retcode'] == 0: + self.Proc_data['extend_data']['ws_PLogin']['uid'] = int(api_obj_json['data']['uid']) + self.Proc_data['extend_data']['ws_PLogin']['token'] = '%s.%s.%s' % ( + str(sdk_bot_info.vila_id), + OlivOS.mhyVilaSDK.get_bot_secret(sdk_bot_info), + str(sdk_bot_info.bot_id) + ) + self.Proc_data['extend_data']['ws_PLogin']['platform'] = int(api_obj_json['data']['platform']) + self.Proc_data['extend_data']['ws_PLogin']['app_id'] = int(api_obj_json['data']['app_id']) + self.Proc_data['extend_data']['ws_PLogin']['device_id'] = str(api_obj_json['data']['device_id']) self.Proc_data['extend_data']['websocket_url'] = api_obj_json['data']['websocket_url'] else: self.Proc_data['extend_data']['websocket_url'] = None except: self.Proc_data['extend_data']['websocket_url'] = None - print(self.Proc_data['extend_data']['websocket_url']) - #if self.Proc_data['extend_data']['websocket_url'] is not None: - # self.run_websocket_rx_connect_start() + if self.Proc_data['extend_data']['websocket_url'] is not None: + self.run_websocket_rx_connect_start() time.sleep(10) - def on_message(self, ws, message): + def on_data(self, ws:websocket.WebSocketApp, data, opcode, FIN): + #print([data, opcode, FIN]) + pass + + def on_message(self, ws:websocket.WebSocketApp, message): try: - print(message) - except: - pass + #print(message) + messageObj = OlivOS.mhyVilaSDK.PAYLOAD.rxPacket(message) + if messageObj.dataHeader.BizType in [ + OlivOS.mhyVilaSDK.protoEnum.Model_ROBOTEVENT.value + ]: + sdk_event = OlivOS.mhyVilaSDK.event( + messageObj.dataHeader.BizType, + messageObj.dataTable, + self.Proc_data['bot_info_dict'] + ) + tx_packet_data = OlivOS.pluginAPI.shallow.rx_packet(sdk_event) + self.Proc_info.tx_queue.put(tx_packet_data, block=False) + except Exception as e: + traceback.print_exc() + + def on_error(self, ws:websocket.WebSocketApp, error): + self.log(0, 'OlivOS mhyVila link server [' + self.Proc_name + '] websocket link error') + + def on_close(self, ws:websocket.WebSocketApp, close_status_code, close_msg): + self.log(0, 'OlivOS mhyVila link server [' + self.Proc_name + '] websocket link close') - def on_error(self, ws, error): - self.log(0, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link error') + def on_open(self, ws:websocket.WebSocketApp): + self.send_PLogin(ws) + threading.Thread( + target=self.run_pulse, + args=() + ).start() + self.log(2, 'OlivOS mhyVila link server [' + self.Proc_name + '] websocket link start') - def on_close(self, ws, close_status_code, close_msg): - self.log(0, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link close') + def run_pulse(self): + tmp_ws_item = self.Proc_data['extend_data']['ws_item'] + while self.Proc_data['extend_data']['pulse_interval'] is not None: + tmp_pulse_interval = self.Proc_data['extend_data']['pulse_interval'] + time.sleep(tmp_pulse_interval) + tmp_data = OlivOS.mhyVilaSDK.PAYLOAD.PHeartBeat().dump() + if tmp_ws_item != self.Proc_data['extend_data']['ws_item'] or self.Proc_data['extend_data']['ws_item'] is None: + self.log(0, 'OlivOS mhyVila link server [' + self.Proc_name + '] websocket pulse giveup') + return + if self.Proc_data['extend_data']['ws_obj'] is not None: + try: + self.Proc_data['extend_data']['ws_obj'].send(tmp_data, opcode=websocket.ABNF.OPCODE_BINARY) + self.log(0, 'OlivOS mhyVila link server [' + self.Proc_name + '] websocket pulse send') + except: + break + else: + break + self.log(0, 'OlivOS mhyVila link server [' + self.Proc_name + '] websocket pulse lost') + return - def on_open(self, ws): - self.log(2, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link start') + def send_PLogin(self, ws:websocket.WebSocketApp): + tmp_data = OlivOS.mhyVilaSDK.PAYLOAD.PLogin() + tmp_data.data.uid = self.Proc_data['extend_data']['ws_PLogin']['uid'] + tmp_data.data.token = self.Proc_data['extend_data']['ws_PLogin']['token'] + tmp_data.data.platform = self.Proc_data['extend_data']['ws_PLogin']['platform'] + tmp_data.data.app_id = self.Proc_data['extend_data']['ws_PLogin']['app_id'] + tmp_data.data.device_id = self.Proc_data['extend_data']['ws_PLogin']['device_id'] + tmp_data.dump() + #print(tmp_data) + ws.send(tmp_data.raw, opcode=websocket.ABNF.OPCODE_BINARY) def run_websocket_rx_connect_start(self): websocket.enableTrace(False) @@ -93,13 +158,15 @@ def run_websocket_rx_connect_start(self): self.Proc_data['extend_data']['websocket_url'], on_open=self.on_open, on_message=self.on_message, + on_data=self.on_data, on_error=self.on_error, on_close=self.on_close ) self.Proc_data['extend_data']['ws_obj'] = ws self.Proc_data['extend_data']['ws_item'] = uuid.uuid4() + self.Proc_data['extend_data']['pulse_interval'] = 20 ws.run_forever() self.Proc_data['extend_data']['pulse_interval'] = None self.Proc_data['extend_data']['ws_obj'] = None self.Proc_data['extend_data']['ws_item'] = None - self.log(2, 'OlivOS kaiheila link server [' + self.Proc_name + '] websocket link lost') + self.log(2, 'OlivOS mhyVila link server [' + self.Proc_name + '] websocket link lost') diff --git a/OlivOS/mhyVilaSDK.py b/OlivOS/mhyVilaSDK.py index 544139b4..57becc9a 100644 --- a/OlivOS/mhyVilaSDK.py +++ b/OlivOS/mhyVilaSDK.py @@ -18,6 +18,7 @@ import json import requests as req import time +from datetime import datetime, timezone, timedelta from requests_toolbelt import MultipartEncoder import uuid import traceback @@ -26,9 +27,11 @@ import hashlib import hmac import struct +import enum import OlivOS import OlivOS.thirdPartyModule.mhyVilaProto as mhyVilaProto +from OlivOS.thirdPartyModule.mhyVilaProto.tools import MessageToDict sdkAPIHost = { 'default': 'https://bbs-api.miyoushe.com' @@ -38,10 +41,13 @@ 'platform': '/vila/api/bot/platform' } +sdkIDCount = {} + sdkAPIRouteTemp = {} sdkSubSelfInfo = {} +sdkNameDict = {} class bot_info_T(object): def __init__( @@ -71,11 +77,189 @@ def get_SDK_bot_info_from_Plugin_bot_info(plugin_bot_info): def get_SDK_bot_info_from_Event(target_event): return get_SDK_bot_info_from_Plugin_bot_info(target_event.bot_info) +class event(object): + def __init__(self, BizType:int, dataTable:dict, botInfo): + self.payload = dataTable + self.BizType = BizType + self.platform = botInfo.platform + self.active = False + if self.payload is not None: + self.active = True + self.base_info = {} + if self.active: + self.base_info['time'] = int(time.time()) + self.base_info['self_id'] = botInfo.id + self.base_info['post_type'] = None + +def set_name(id:str, name:str): + global sdkNameDict + sdkNameDict[str(id)] = str(name) + +def get_name(id:str): + global sdkNameDict + return sdkNameDict.get(str(id), str(id)) + +def get_message(contentData:dict): + msg = contentData.get('content', {}).get('text', '') + res_msg = '' + count = 0 + atTable = contentData.get('content', {}).get('entities', []) + if type(atTable) is list: + for atTable_this in atTable: + if type(atTable_this) is dict: + i_offset = atTable_this.get('offset', None) + i_length = atTable_this.get('length', None) + s_type = atTable_this.get('entity', {}).get('type', None) + if type(i_offset) is int \ + and type(i_length) is int \ + and type(s_type) is str \ + and i_offset + i_length <= len(msg): + if s_type == 'mentioned_robot': + s_bot_id = atTable_this.get('entity', {}).get('bot_id', None) + if type(s_bot_id) is str: + res_msg += msg[count:i_offset] + res_msg += f'[OP:at,id={s_bot_id}] ' + set_name(s_bot_id, msg[i_offset + 1:i_offset + i_length - 1]) + count = i_offset + i_length + if s_type == 'mentioned_user': + s_user_id = atTable_this.get('entity', {}).get('user_id', None) + if type(s_user_id) is str: + res_msg += msg[count:i_offset] + res_msg += f'[OP:at,id={s_user_id}] ' + set_name(s_user_id, msg[i_offset + 1:i_offset + i_length - 1]) + count = i_offset + i_length + if count <= len(msg): + res_msg += msg[count:] + return res_msg + + +def release_message(msg:str): + res = { + 'content': { + 'text': '', + 'entities': [] + } + } + message_obj = OlivOS.messageAPI.Message_templet( + 'olivos_string', + msg + ) + for message_obj_this in message_obj.data: + if type(message_obj_this) is OlivOS.messageAPI.PARA.at: + i_offset = len(res['content']['text']) + res['content']['text'] += f"@{get_name(message_obj_this.data['id'])}" + i_length = len(res['content']['text']) - i_offset + obj_this = { + 'offset': i_offset, + 'length': i_length + } + if str(message_obj_this.data['id']).isdecimal(): + obj_this['entity'] = { + 'type': 'mentioned_user', + 'user_id': message_obj_this.data['id'] + } + else: + obj_this['entity'] = { + 'type': 'mentioned_robot', + 'bot_id': message_obj_this.data['id'] + } + res['content']['entities'].append(obj_this) + elif type(message_obj_this) is OlivOS.messageAPI.PARA.text: + res['content']['text'] += message_obj_this.data['text'] + return res + +def get_Event_from_SDK(target_event): + global sdkSubSelfInfo + #print(json.dumps(target_event.sdk_event.__dict__, ensure_ascii=False, indent=4)) + target_event.base_info['time'] = target_event.sdk_event.base_info['time'] + target_event.base_info['self_id'] = str(target_event.sdk_event.base_info['self_id']) + target_event.base_info['type'] = target_event.sdk_event.base_info['post_type'] + target_event.platform['sdk'] = target_event.sdk_event.platform['sdk'] + target_event.platform['platform'] = target_event.sdk_event.platform['platform'] + target_event.platform['model'] = target_event.sdk_event.platform['model'] + target_event.plugin_info['message_mode_rx'] = 'olivos_string' + plugin_event_bot_hash = OlivOS.API.getBotHash( + bot_id=target_event.base_info['self_id'], + platform_sdk=target_event.platform['sdk'], + platform_platform=target_event.platform['platform'], + platform_model=target_event.platform['model'] + ) + #print(type(target_event.sdk_event.payload)) + if target_event.sdk_event.BizType == protoEnum.Model_ROBOTEVENT.value \ + and type(target_event.sdk_event.payload) is dict \ + and target_event.sdk_event.payload.get('type', None) == 'SendMessage' \ + and type(target_event.sdk_event.payload.get('extendData', None)) is dict: + messageData = target_event.sdk_event.payload.get('extendData', {}).get('sendMessage', None) + if type(messageData) is dict: + contentData_str = messageData.get('content', None) + if type(contentData_str) is str \ + and messageData.get('objectName', None) == 'Text': + villaId = messageData.get('villaId', None) + roomId = messageData.get('roomId', None) + msgUid = messageData.get('msgUid', None) + nickname = messageData.get('nickname', None) + fromUserId = messageData.get('fromUserId', None) + contentData = json.loads(contentData_str) + #print(json.dumps(contentData, ensure_ascii=False, indent=4)) + if type(villaId) is str \ + and type(roomId) is str \ + and type(msgUid) is str \ + and type(nickname) is str \ + and type(fromUserId) is str: + msg = get_message(contentData) + target_event.active = True + target_event.plugin_info['func_type'] = 'group_message' + target_event.data = target_event.group_message( + roomId, + fromUserId, + msg, + 'group' + ) + target_event.data.message_sdk = OlivOS.messageAPI.Message_templet( + 'olivos_string', + msg + ) + target_event.data.message_id = msgUid + target_event.data.raw_message = target_event.data.message + target_event.data.raw_message_sdk = target_event.data.message_sdk + target_event.data.host_id = villaId + target_event.data.font = None + target_event.data.sender['name'] = nickname + target_event.data.sender['id'] = fromUserId + target_event.data.sender['nickname'] = target_event.data.sender['name'] + target_event.data.sender['user_id'] = target_event.data.sender['id'] ''' 对于WEBSOCKET接口的PAYLOAD实现 ''' +def getIDCount(botId:str) -> int: + global sdkIDCount + if type(sdkIDCount.get(str(botId), None)) is not int: + sdkIDCount[str(botId)] = 0 + res:int = sdkIDCount[str(botId)] + 1 + sdkIDCount[str(botId)] = res + return res + +class protoEnum(enum.Enum): + Command_P_HEARTBEAT = mhyVilaProto.command.Command.P_HEARTBEAT + Command_P_LOGIN = mhyVilaProto.command.Command.P_LOGIN + Command_P_LOGOUT = mhyVilaProto.command.Command.P_LOGOUT + Model_ROBOTEVENT = 30001 + +recvProtoDict = { + protoEnum.Command_P_HEARTBEAT.value: mhyVilaProto.command.PHeartBeatReply, + protoEnum.Command_P_LOGIN.value: mhyVilaProto.command.PLoginReply, + protoEnum.Command_P_LOGOUT.value: mhyVilaProto.command.PLogoutReply, + protoEnum.Model_ROBOTEVENT.value: mhyVilaProto.model.RobotEvent, +} + +sendProtoDict = { + protoEnum.Command_P_HEARTBEAT.value: mhyVilaProto.command.PHeartBeat, + protoEnum.Command_P_LOGIN.value: mhyVilaProto.command.PLogin, + protoEnum.Command_P_LOGOUT.value: mhyVilaProto.command.PLogout, +} + class payload_template(object): def __init__(self, raw:'bytearray|None'=None): self.active = True @@ -87,18 +271,20 @@ def __init__(self, raw:'bytearray|None'=None): self.dataHeader = self.dataHeader_T() self.dataDataBody:bytearray = b'' self.data = None + self.dataTable = {} self.dataProto = None + if self.is_rx: + self.load() class magicHeader_T(object): def __init__(self): - self.HeaderLen:int = 8 - self.Magic:bytearray = b'\xBA\xBE\xFA\xCE' + self.Magic:int = 0xBABEFACE self.DataLen:int = 0 class dataHeader_T(object): def __init__(self): self.HeaderLen:int = 24 # uint32 变长头总长度,变长头部分所有字段(包括HeaderLen本身)的总长度。 注:也就是说这玩意每个版本是固定的 - self.ID:int = 0 # uint64 协议包序列ID,同一条连接上的发出的协议包应该单调递增,相同序列ID且Flag字段相同的包应该被认为是同一个包 + self.ID:int = 1 # uint64 协议包序列ID,同一条连接上的发出的协议包应该单调递增,相同序列ID且Flag字段相同的包应该被认为是同一个包 self.Flag:int = 1 # uint32 配合bizType使用,用于标识同一个bizType协议的方向。 # 用 1 代表主动发到服务端的request包 # 用 2 代表针对某个request包回应的response包 @@ -106,23 +292,25 @@ def __init__(self): self.AppId:int = 104 # int32 应用标识。固定为 104 def __dump_dataDataBody(self): - if self.data is not None \ - and self.dataProto is not None: - self.dataDataBody = self.dataProto(**self.data.__dict__).SerializeToString() + if self.data is not None: + self.dataTable = self.data.__dict__ + if self.dataProto is not None: + self.dataDataBody = self.dataProto(**self.dataTable).SerializeToString() return self.dataDataBody def __update_DataLen(self): - self.magicHeader.DataLen = self.magicHeader.HeaderLen + self.dataHeader.HeaderLen + len(self.dataDataBody) + self.magicHeader.DataLen = self.dataHeader.HeaderLen + len(self.dataDataBody) return self.magicHeader.DataLen def __dump_magicHeader(self): return struct.pack( - '<4sI', + '= 32: + self.magicHeader.Magic, \ + self.magicHeader.DataLen = struct.unpack( + '' class PAYLOAD(object): class rxPacket(payload_template): def __init__(self, raw): - payload_template.__init__(self, raw, True) + payload_template.__init__(self, raw) # 登录命令 class PLogin(payload_template): def __init__(self): payload_template.__init__(self) + self.dataHeader.Flag = 1 + self.dataHeader.BizType = protoEnum.Command_P_LOGIN.value self.data = self.data_T() - self.dataProto = mhyVilaProto.command.PLogin + self.dataProto = sendProtoDict[self.dataHeader.BizType] class data_T(object): def __init__(self): @@ -164,12 +384,33 @@ def __init__(self): self.app_id:int = 0 self.device_id:str = '' self.region:str = '' + self.meta:dict = {} + + # 心跳命令 + class PHeartBeat(payload_template): + def __init__(self): + payload_template.__init__(self) + self.dataHeader.Flag = 1 + self.dataHeader.BizType = protoEnum.Command_P_HEARTBEAT.value + self.data = self.data_T() + self.dataProto = sendProtoDict[self.dataHeader.BizType] + + class data_T(object): + def __init__(self): + self.client_timestamp:str = str(int(datetime.now(timezone.utc).timestamp() * 1000)) ''' 对于POST接口的实现 ''' +def get_bot_secret(bot_info:bot_info_T): + return str(hmac.new( + str(bot_info.pub_key).encode('utf-8'), + str(bot_info.secret).encode('utf-8'), + hashlib.sha256 + ).hexdigest()) + class api_templet(object): def __init__(self): self.bot_info:'bot_info_T|None' = None @@ -201,11 +442,7 @@ def do_api(self, req_type='POST'): headers = { 'Content-Type': 'application/json', 'User-Agent': OlivOS.infoAPI.OlivOS_Header_UA, - 'x-rpc-bot_secret': '%s' % str(hmac.new( - str(self.bot_info.pub_key).encode('utf-8'), - str(self.bot_info.secret).encode('utf-8'), - hashlib.sha256 - ).hexdigest()), + 'x-rpc-bot_secret': '%s' % get_bot_secret(self.bot_info), 'x-rpc-bot_id': '%s' % str(self.bot_info.bot_id) } if self.headdata.vila_id is not None: @@ -218,6 +455,7 @@ def do_api(self, req_type='POST'): msg_res = req.request("GET", send_url, headers=headers) self.res = msg_res.text + #print(self.res) return msg_res.text except: return None @@ -241,3 +479,21 @@ def __init__(self): self.room_id = -1 self.object_name = 'MHY:Text' self.msg_content = '' + + +# 支持OlivOS API调用的方法实现 +class event_action(object): + def send_group_msg(target_event, chat_id, message, host_id = None): + 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(release_message(message)) + api_obj.data.object_name = 'MHY:Text' + api_obj.do_api('POST') + return None diff --git a/OlivOS/thirdPartyModule/__init__.py b/OlivOS/thirdPartyModule/__init__.py index e44b8ad5..b674ca78 100644 --- a/OlivOS/thirdPartyModule/__init__.py +++ b/OlivOS/thirdPartyModule/__init__.py @@ -17,3 +17,4 @@ # here put the import lib from . import blivedm +from . import mhyVilaProto diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/__init__.py b/OlivOS/thirdPartyModule/mhyVilaProto/__init__.py index e3af63f0..3bb3d891 100644 --- a/OlivOS/thirdPartyModule/mhyVilaProto/__init__.py +++ b/OlivOS/thirdPartyModule/mhyVilaProto/__init__.py @@ -2,3 +2,4 @@ from . import command_pb2 as command from . import model_pb2 as model from . import robot_event_message_pb2 as robot_event_message +from . import tools diff --git a/OlivOS/thirdPartyModule/mhyVilaProto/tools.py b/OlivOS/thirdPartyModule/mhyVilaProto/tools.py new file mode 100644 index 00000000..b1e25c0f --- /dev/null +++ b/OlivOS/thirdPartyModule/mhyVilaProto/tools.py @@ -0,0 +1 @@ +from google.protobuf.json_format import MessageToDict From b36eb39906af9e5613430de1eff25ae7edcecb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Sat, 2 Dec 2023 00:26:40 +0800 Subject: [PATCH 14/19] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da27d01f..0b02cdef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: CI-Packing-all on: push: - branches: [ main, dev, dev-vila] + branches: [ main, dev ] jobs: build-win64-release: runs-on: windows-latest From a98e78e99ffc63d56d9e0e3f7dfd9e78b8eccf6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Sat, 2 Dec 2023 00:36:19 +0800 Subject: [PATCH 15/19] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f1e7612a..2a3c22b9 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,8 @@ [![Discord](https://img.shields.io/badge/-Discord-6666CC?style=flat-square&logo=Discord&logoColor=white)](https://discord.com/) [![Bilibili](https://img.shields.io/badge/-Bilibili-FB7299?style=flat-square&logo=Bilibili&logoColor=white)](http://www.bilibili.com/) [![Telegram](https://img.shields.io/badge/-Telegram-26A5E4?style=flat-square&logo=Telegram&logoColor=white)](https://telegram.org/) -[![开黑啦](https://img.shields.io/badge/-%E5%BC%80%E9%BB%91%E5%95%A6KOOK-83E700?style=flat-square&logo=Discord&logoColor=white)](https://www.kookapp.cn/) +[![KOOK](https://img.shields.io/badge/-%E5%BC%80%E9%BB%91%E5%95%A6KOOK-83E700?style=flat-square&logo=Discord&logoColor=white)](https://www.kookapp.cn/) +[![大别野](https://img.shields.io/badge/-%E7%B1%B3%E6%B8%B8%E7%A4%BE%E5%A4%A7%E5%88%AB%E9%87%8E-59DBFC?style=flat-square&logoColor=white)](https://open.miyoushe.com/) [![Dodo](https://img.shields.io/badge/-Dodo-00B8AA?style=flat-square&logo=%2Fe%2F&logoColor=white)](https://dodo.link/) [![Fanbook](https://img.shields.io/badge/-Fanbook-1A52F3?style=flat-square&logo=sharp&logoColor=white)](https://fanbook.mobi/) [![Hack.Chat](https://img.shields.io/badge/-Hack.Chat-20201D?style=flat-square&logo=Hetzner&logoColor=white)](https://hack.chat/) From c96272dc8e4c3676ee9890f11c131107a66ccb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Sat, 2 Dec 2023 10:45:55 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 + requirements310.txt | 1 + requirements310_pure.txt | 1 + requirements310_win.txt | 1 + requirements_pure.txt | 1 + requirements_win.txt | 1 + 6 files changed, 6 insertions(+) diff --git a/requirements.txt b/requirements.txt index 0eb3d01b..1f93ee6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Flask==2.0.2 +Werkzeug==2.2.2 gevent==21.12.0 lxml==4.7.1 openpyxl==3.0.10 diff --git a/requirements310.txt b/requirements310.txt index 466dd2cb..26106166 100644 --- a/requirements310.txt +++ b/requirements310.txt @@ -1,5 +1,6 @@ pyinstaller flask +Werkzeug==2.2.2 gevent psutil requests diff --git a/requirements310_pure.txt b/requirements310_pure.txt index d07efc9a..83096c9f 100644 --- a/requirements310_pure.txt +++ b/requirements310_pure.txt @@ -1,5 +1,6 @@ pyinstaller flask +Werkzeug==2.2.2 gevent psutil requests diff --git a/requirements310_win.txt b/requirements310_win.txt index a2667e68..7d4e97a9 100644 --- a/requirements310_win.txt +++ b/requirements310_win.txt @@ -1,5 +1,6 @@ pyinstaller flask +Werkzeug==2.2.2 gevent psutil requests diff --git a/requirements_pure.txt b/requirements_pure.txt index f98239a1..dc26e862 100644 --- a/requirements_pure.txt +++ b/requirements_pure.txt @@ -1,4 +1,5 @@ Flask==2.0.2 +Werkzeug==2.2.2 gevent==21.12.0 Pillow==9.3.0 psutil==5.9.0 diff --git a/requirements_win.txt b/requirements_win.txt index 35ccf182..8578ef7e 100644 --- a/requirements_win.txt +++ b/requirements_win.txt @@ -1,4 +1,5 @@ Flask==2.0.2 +Werkzeug==2.2.2 gevent==21.12.0 lxml==4.7.1 openpyxl==3.0.10 From 49879fda608659ba3cd6695542ebf886ac069fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Sat, 2 Dec 2023 18:17:37 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E8=A7=A3=E5=86=B3linux=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 4 ++-- main_linux.spec | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 main_linux.spec diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b02cdef..58a0a57d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -185,7 +185,7 @@ jobs: run: | cp ./OlivOS/hook.py ./OlivOS/hook_bak.py cp ./OlivOS/hook_pack_debug.py ./OlivOS/hook.py - pyinstaller ./main_debug.spec + pyinstaller ./main_linux.spec - name: Run artifact run: | mkdir OlivOS-PKG @@ -374,7 +374,7 @@ jobs: run: | cp ./OlivOS/hook.py ./OlivOS/hook_bak.py cp ./OlivOS/hook_pack_debug.py ./OlivOS/hook.py - pyinstaller ./main_debug.spec + pyinstaller ./main_linux.spec - name: Run artifact run: | mkdir OlivOS-PKG diff --git a/main_linux.spec b/main_linux.spec new file mode 100644 index 00000000..cb44685e --- /dev/null +++ b/main_linux.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + + +a = Analysis(['main.py'], + pathex=['./'], + binaries=[], + datas=[], + hiddenimports=[ + 'websockets.legacy.auth', + 'websockets.legacy.client', + 'websockets.legacy.server' + ], + hookspath=['./hook'], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir='./runtime/', + console=True , icon='resource/favoricon.ico') From 3a5b6573d22354e91d4c1722b6723d29ac5b3abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Sat, 2 Dec 2023 18:27:05 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main_linux.spec | 2 +- main_mac.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main_linux.spec b/main_linux.spec index cb44685e..54b27b45 100644 --- a/main_linux.spec +++ b/main_linux.spec @@ -33,5 +33,5 @@ exe = EXE(pyz, strip=False, upx=True, upx_exclude=[], - runtime_tmpdir='./runtime/', + runtime_tmpdir='./', console=True , icon='resource/favoricon.ico') diff --git a/main_mac.spec b/main_mac.spec index cb44685e..54b27b45 100644 --- a/main_mac.spec +++ b/main_mac.spec @@ -33,5 +33,5 @@ exe = EXE(pyz, strip=False, upx=True, upx_exclude=[], - runtime_tmpdir='./runtime/', + runtime_tmpdir='./', console=True , icon='resource/favoricon.ico') From 3ae7a31bc9bdb75233c843941572c3cdf71e74ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Tue, 5 Dec 2023 14:42:01 +0800 Subject: [PATCH 19/19] =?UTF-8?q?Pypi=E7=89=88=E6=9C=AC=E6=8E=A8=E8=BF=9B?= =?UTF-8?q?=E8=87=B30.11.25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 59e8651f..9e113c65 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ long_description = f.read() setuptools.setup(name='olivos', - version='0.11.24', + version='0.11.25', description='OlivOS - Witness Union', long_description=long_description, long_description_content_type='text/markdown', @@ -29,6 +29,7 @@ url='https://github.com/OlivOS-Team/OlivOS', install_requires=[ 'flask', + 'Werkzeug==2.2.2', 'gevent', 'psutil', 'requests', @@ -44,7 +45,10 @@ 'brotli', 'pyjson5', 'pywebview', - 'filetype' + 'filetype', + 'grpcio', + 'grpcio-tools', + 'protobuf', ], license='AGPLv3 License', packages=setuptools.find_packages(),