Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
🐛 Fix bugs when bind other than 127.0.0.1 or 0.0.0.0, fix #449
Browse files Browse the repository at this point in the history
  • Loading branch information
mnixry committed Feb 7, 2023
1 parent 23a91f4 commit ac73a67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nonebot_plugin_gocqhttp/process/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

import chevron

from nonebot_plugin_gocqhttp.exceptions import BadConfigFormat

from ..plugin_config import AccountConfig, driver_config, onebot_config
Expand Down Expand Up @@ -40,11 +41,16 @@ def generate(self):

def before_run(self):
template_string = self.read()
host = (
"127.0.0.1"
if driver_config.host.is_loopback or driver_config.host.is_unspecified
else driver_config.host
)
rendered_string = chevron.render(
template_string,
data={
"account": self.account,
"server_address": f"ws://127.0.0.1:{driver_config.port}/onebot/v11/ws",
"server_address": f"ws://{host}:{driver_config.port}/onebot/v11/ws",
"access_token": onebot_config.onebot_access_token or "",
},
)
Expand Down

0 comments on commit ac73a67

Please sign in to comment.