mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
✨ add config for disable network warning log
This commit is contained in:
parent
560fd81db6
commit
2796ea6f8e
@ -148,6 +148,7 @@ sidebar: auto
|
||||
|
||||
- `BISON_PROXY`: 使用的代理连接,形如`http://<ip>:<port>`(可选)
|
||||
- `BISON_UA`: 使用的 User-Agent,默认为 Chrome
|
||||
- `BISON_SHOW_NETWORK_WARNING`: 是否在日志中输出网络异常,默认开启
|
||||
|
||||
## 使用
|
||||
|
||||
|
@ -93,14 +93,16 @@ class Platform(metaclass=PlatformABCMeta, base=True):
|
||||
try:
|
||||
return await self.fetch_new_post(target, users)
|
||||
except httpx.RequestError as err:
|
||||
logger.warning(
|
||||
"network connection error: {}, url: {}".format(
|
||||
type(err), err.request.url
|
||||
if plugin_config.bison_show_network_warning:
|
||||
logger.warning(
|
||||
"network connection error: {}, url: {}".format(
|
||||
type(err), err.request.url
|
||||
)
|
||||
)
|
||||
)
|
||||
return []
|
||||
except ssl.SSLError as err:
|
||||
logger.warning(f"ssl error: {err}")
|
||||
if plugin_config.bison_show_network_warning:
|
||||
logger.warning(f"ssl error: {err}")
|
||||
return []
|
||||
except json.JSONDecodeError as err:
|
||||
logger.warning(f"json error, parsing: {err.doc}")
|
||||
|
@ -19,6 +19,7 @@ class PlugConfig(BaseSettings):
|
||||
bison_resend_times: int = 0
|
||||
bison_proxy: Optional[str]
|
||||
bison_ua: str = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
|
||||
bison_show_network_warning: bool = True
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
|
Loading…
x
Reference in New Issue
Block a user