diff --git a/OlivOS/L10NDataAPI.py b/OlivOS/L10NDataAPI.py index 3720a76e..23da6e69 100644 --- a/OlivOS/L10NDataAPI.py +++ b/OlivOS/L10NDataAPI.py @@ -50,7 +50,7 @@ 'onebotV12LinkServerAPI_0004': 'OlivOS onebotV12 link server [{0}] websocket link close', 'onebotV12LinkServerAPI_0005': 'OlivOS onebotV12 link server [{0}] websocket link start', 'onebotV12LinkServerAPI_0006': 'OlivOS onebotV12 link server [{0}] websocket link lost', - 'hackChatLinkServerAPI_0001': 'OlivOS hackChat link server [{0}] is running', + 'hackChatLinkServerAPI_0001': 'OlivOS hackChat link server [{0}] is running on [{1}]', 'hackChatLinkServerAPI_0002': 'OlivOS hackChat link server [{0}] websocket link will retry in {1}s', 'hackChatLinkServerAPI_0003': 'OlivOS hackChat link server [{0}] websocket link error', 'hackChatLinkServerAPI_0004': 'OlivOS hackChat link server [{0}] websocket link close', @@ -129,7 +129,7 @@ 'onebotV12LinkServerAPI_0004': 'OlivOS onebotV12 连接服务组件 [{0}] WebSocket 连接 已经关闭', 'onebotV12LinkServerAPI_0005': 'OlivOS onebotV12 连接服务组件 [{0}] WebSocket 连接 已经启动', 'onebotV12LinkServerAPI_0006': 'OlivOS onebotV12 连接服务组件 [{0}] WebSocket 连接 已经丢失', - 'hackChatLinkServerAPI_0001': 'OlivOS hackChat 连接服务组件 [{0}] 正在运作', + 'hackChatLinkServerAPI_0001': 'OlivOS hackChat 连接服务组件 [{0}] 正在运作, 采用WS服务器 [{1}]', 'hackChatLinkServerAPI_0002': 'OlivOS hackChat 连接服务组件 [{0}] WebSocket 连接 将在{1}秒内重试', 'hackChatLinkServerAPI_0003': 'OlivOS hackChat 连接服务组件 [{0}] WebSocket 连接 发生错误', 'hackChatLinkServerAPI_0004': 'OlivOS hackChat 连接服务组件 [{0}] WebSocket 连接 已经关闭', diff --git a/OlivOS/hackChatLinkServerAPI.py b/OlivOS/hackChatLinkServerAPI.py index 51f08ce0..945542a6 100644 --- a/OlivOS/hackChatLinkServerAPI.py +++ b/OlivOS/hackChatLinkServerAPI.py @@ -26,6 +26,8 @@ modelName = 'hackChatLinkServerAPI' +gDefaultWsPath = 'wss://hack.chat/chat-ws' + 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): @@ -49,14 +51,18 @@ def __init__(self, Proc_name, scan_interval=0.001, dead_interval=1, rx_queue=Non self.Proc_data['platform_bot_info_dict'] = None def run(self): - self.log(2, OlivOS.L10NAPI.getTrans('OlivOS hackChat link server [{0}] is running', [self.Proc_name], modelName)) + global gDefaultWsPath + wsPath = gDefaultWsPath + if 'ws_path' in self.Proc_data['bot_info_dict'].extends: + wsPath = self.Proc_data['bot_info_dict'].extends['ws_path'] + self.log(2, OlivOS.L10NAPI.getTrans('OlivOS hackChat link server [{0}] is running on [{1}]', [self.Proc_name, wsPath], modelName)) threading.Thread( target=self.message_router, args=() ).start() while True: try: - self.Proc_data['extend_data']['websocket_url'] = 'wss://hack.chat/chat-ws' + self.Proc_data['extend_data']['websocket_url'] = wsPath except: self.Proc_data['extend_data']['websocket_url'] = None if self.Proc_data['extend_data']['websocket_url'] is not None: diff --git a/OlivOS/hackChatSDK.py b/OlivOS/hackChatSDK.py index 56e46a1a..d345ef42 100644 --- a/OlivOS/hackChatSDK.py +++ b/OlivOS/hackChatSDK.py @@ -53,6 +53,8 @@ class event(object): def __init__(self, payload_data=None, bot_info=None): self.payload = payload_data self.platform = {'sdk': 'hackChat_link', 'platform': 'hackChat', 'model': 'default'} + if type(bot_info.platform) is dict: + self.platform.update(bot_info.platform) self.active = False if self.payload is not None: self.active = True diff --git a/OlivOS/messageAPI.py b/OlivOS/messageAPI.py index 6a30e30b..f871c8e2 100644 --- a/OlivOS/messageAPI.py +++ b/OlivOS/messageAPI.py @@ -115,7 +115,8 @@ }, 'hackChat': { 'hackChat_link': { - 'default': 'olivos_string' + 'default': 'olivos_string', + 'private': 'olivos_string' } }, 'biliLive': { diff --git a/OlivOS/multiLoginUIAPI.py b/OlivOS/multiLoginUIAPI.py index eebb86a0..9aac0368 100644 --- a/OlivOS/multiLoginUIAPI.py +++ b/OlivOS/multiLoginUIAPI.py @@ -369,6 +369,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non 'Telegram', 'Fanbook', 'Hack.Chat', + 'Hack.Chat/私有', 'onebotV12/正向WS', 'onebotV11/Http', 'RED协议', @@ -422,6 +423,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non #'QQ/GoCq/旧': ['签名服务器', 'sign-server'] 'RED协议': ['HTTP地址'], '钉钉': ["AppKey", "AppSecret"], + 'Hack.Chat/私有': ["WS地址"] }, 'type_extends_name_note_list': { #'QQ/GoCq/默认': ['签名服务器', 'KEY'], @@ -430,6 +432,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non #'QQ/GoCq/旧': ['签名服务器', 'KEY'] 'RED协议': ['HTTP地址'], '钉钉': ["AppKey", "AppSecret"], + 'Hack.Chat/私有': ["WS地址"] }, 'type_extends_note_list': { #'QQ/GoCq/默认': {'签名服务器': 'sign-server', 'KEY': 'key'}, @@ -438,6 +441,7 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non #'QQ/GoCq/旧': {'签名服务器': 'sign-server', 'KEY': 'key'}, 'RED协议': {'HTTP地址': 'http-path'}, '钉钉': {"AppKey": 'app_key', "AppSecret": "app_secret"}, + 'Hack.Chat/私有': {"WS地址": 'ws_path'} }, 'type_qsign_array_note_list': { 'QQ/GoCq/默认': {'地址': 'sign-server', 'KEY': 'key'}, @@ -609,6 +613,12 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non '密码': 'edit_root_Entry_Password' } ], + 'Hack.Chat/私有': ['hackChat', 'hackChat_link', 'private', 'True', 'websocket', { + '房间名称': 'edit_root_Entry_Server_host', + 'Bot名称': 'edit_root_Entry_Server_access_token', + '密码': 'edit_root_Entry_Password' + } + ], '虚拟终端': ['terminal', 'terminal_link', 'default', 'True', 'websocket', { '账号': 'edit_root_Entry_ID' } @@ -776,7 +786,8 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non }, 'hackChat': { 'hackChat_link': [ - 'default' + 'default', + 'private' ] }, 'biliLive': { @@ -944,7 +955,7 @@ def tree_edit_commit(self): tmp_host = 'NONEED' if tmp_platform_platform == 'hackChat' \ and tmp_platform_sdk == 'hackChat_link' \ - and tmp_platform_model == 'default': + and tmp_platform_model in ['default', 'private']: if tmp_id == '': tmp_id = random.randint(1000000000, 9999999999) if tmp_port == '':