Skip to content

Commit

Permalink
支持header token字段
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Dec 27, 2023
1 parent f5a3c98 commit eaea94c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion OlivOS/adapter/onebotV11/onebotSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit eaea94c

Please sign in to comment.