Skip to content

Commit

Permalink
Hack.Chat平台支持私服
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Nov 2, 2023
1 parent c07548d commit 3a17575
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions OlivOS/L10NDataAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 连接 已经关闭',
Expand Down
10 changes: 8 additions & 2 deletions OlivOS/hackChatLinkServerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions OlivOS/hackChatSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion OlivOS/messageAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
},
'hackChat': {
'hackChat_link': {
'default': 'olivos_string'
'default': 'olivos_string',
'private': 'olivos_string'
}
},
'biliLive': {
Expand Down
15 changes: 13 additions & 2 deletions OlivOS/multiLoginUIAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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协议',
Expand Down Expand Up @@ -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'],
Expand All @@ -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'},
Expand All @@ -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'},
Expand Down Expand Up @@ -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'
}
Expand Down Expand Up @@ -776,7 +786,8 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
},
'hackChat': {
'hackChat_link': [
'default'
'default',
'private'
]
},
'biliLive': {
Expand Down Expand Up @@ -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 == '':
Expand Down

0 comments on commit 3a17575

Please sign in to comment.