: zap: 添加api请求超时限制

This commit is contained in:
远野千束 2024-04-26 12:39:43 +08:00
parent bb9b8a1ced
commit 857e58d635
3 changed files with 5 additions and 3 deletions

View File

@ -10,11 +10,10 @@ load_resources()
init_log() init_log()
nonebot.plugin.load_plugins("liteyuki/plugins") nonebot.plugin.load_plugins("liteyuki/plugins")
# 从数据库读取已安装的插件 # 从数据库读取已安装的插件
if not get_config("safe_mode", False): if not get_config("safe_mode", False):
# 安全模式下,不加载插件 # 安全模式下,不加载插件
nonebot.plugin.load_plugins("plugins")
installed_plugins: list[InstalledPlugin] = plugin_db.all(InstalledPlugin()) installed_plugins: list[InstalledPlugin] = plugin_db.all(InstalledPlugin())
if installed_plugins: if installed_plugins:
for installed_plugin in installed_plugins: for installed_plugin in installed_plugins:
@ -22,5 +21,7 @@ if not get_config("safe_mode", False):
nonebot.logger.error(f"{installed_plugin.module_name} not installed, but in loading database. please run `npm fixup` in chat to reinstall it.") nonebot.logger.error(f"{installed_plugin.module_name} not installed, but in loading database. please run `npm fixup` in chat to reinstall it.")
else: else:
nonebot.load_plugin(installed_plugin.module_name) nonebot.load_plugin(installed_plugin.module_name)
nonebot.plugin.load_plugins("plugins")
else: else:
nonebot.logger.info("Safe mode is on, no plugin loaded.") nonebot.logger.info("Safe mode is on, no plugin loaded.")

View File

@ -189,6 +189,7 @@ function main() {
`${localData['free']} ${convertSize(swapData['free'])}`, `${localData['free']} ${convertSize(swapData['free'])}`,
`${localData['total']} ${convertSize(swapData['total'])}` `${localData['total']} ${convertSize(swapData['total'])}`
] ]
console.log(cpuTagArray, memTagArray, swapTagArray)
} }

View File

@ -30,7 +30,7 @@ def register_bot():
} }
try: try:
nonebot.logger.info("Waiting for register to Liteyuki...") nonebot.logger.info("Waiting for register to Liteyuki...")
resp = requests.post(url, json=data) resp = requests.post(url, json=data, timeout=(10, 15))
if resp.status_code == 200: if resp.status_code == 200:
data = resp.json() data = resp.json()
if liteyuki_id := data.get("liteyuki_id"): if liteyuki_id := data.get("liteyuki_id"):