diff --git a/OlivOS/adapter/onebotV11/onebotSDK.py b/OlivOS/adapter/onebotV11/onebotSDK.py index 2e08e7f3..815fa518 100644 --- a/OlivOS/adapter/onebotV11/onebotSDK.py +++ b/OlivOS/adapter/onebotV11/onebotSDK.py @@ -67,7 +67,12 @@ def send_onebot_post_json(self): pass else: tmp_host = 'http://' + tmp_host - send_url = f'{self.bot_info.host}:{self.bot_info.port}/{self.node_ext}?access_token={self.bot_info.access_token}' + token_str = '' + token_dict = {} + if len(self.bot_info.access_token) > 0: + token_str = f'?access_token={self.bot_info.access_token}' + token_dict = {'Authorization': f'Bearer {self.bot_info.access_token}'} + send_url = f'{self.bot_info.host}:{self.bot_info.port}/{self.node_ext}{token_str}' if self.bot_info.debug_mode: if self.bot_info.debug_logger is not None: @@ -76,6 +81,7 @@ def send_onebot_post_json(self): headers = { 'Content-Type': 'application/json' } + headers.update(token_dict) msg_res = req.request("POST", send_url, headers=headers, data=json_str_tmp.encode('utf-8')) if self.bot_info.debug_mode: