给一点点建议:

这里实际上可以不用固定ip,port,token的
可以用这种方式直接动态读取conf/account.json里面的数据:
def get_account_config(plugin_event):
"""从 conf/account.json 读取账号配置,根据当前bot_id匹配对应账号,失败时返回None"""
config_path = os.path.join('conf', 'account.json')
try:
if not os.path.exists(config_path):
return None
with open(config_path, 'r', encoding='utf-8') as f:
config_data = json.load(f)
if 'account' not in config_data or not config_data['account']:
return None
# 获取当前bot_id
current_bot_id = str(plugin_event.bot_info.id)
# 遍历所有账号配置,查找匹配的bot_id
for account_config in config_data['account']:
if 'id' in account_config and str(account_config['id']) == current_bot_id:
if 'server' not in account_config:
return None
server_config = account_config['server']
required_fields = ['host', 'port', 'access_token']
for field in required_fields:
if field not in server_config:
return None
return server_config
return None
except Exception as e:
return None
这样子就能动态获取base_ip,base_port和token了
不过我相信ip都是127.0.0.1吧