From 0f343a0e3cadce91d63008a80028b906ea3fecdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Fri, 7 Oct 2022 13:55:50 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E6=B7=BB=E5=8A=A0=20`enka=5Fnet?= =?UTF-8?q?work=5Fapi=5Fagent`=20=E5=8F=AF=E9=80=89=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 11 +++++++---- core/config.py | 2 ++ plugins/genshin/player_cards.py | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index a9ac8bb..87fe375 100644 --- a/.env.example +++ b/.env.example @@ -16,16 +16,16 @@ REDIS_DB=0 # 联系 https://t.me/BotFather 使用 /newbot 命令创建机器人并获取 token BOT_TOKEN="xxxxxxx" -# 记录错误并发送消息通知开发人员 +# 记录错误并发送消息通知开发人员 可选配置项 ERROR_NOTIFICATION_CHAT_ID=chat_id -# 文章推送群组 +# 文章推送群组 可选配置项 CHANNELS=[{ "name": "", "chat_id": 1}] # bot 管理员 ADMINS=[{ "username": "", "user_id": -1 }] -# 群验证功能 +# 群验证功能 可选配置项 VERIFY_GROUPS=[] # logger 配置 @@ -35,6 +35,9 @@ LOGGER_TIME_FORMAT="[%Y-%m-%d %X]" LOGGER_TRACEBACK_MAX_FRAMES=20 LOGGER_RENDER_KEYWORDS=["BOT"] -# mtp 客户端 +# mtp 客户端 可选配置项 API_ID=12345 API_HASH="abcdefg" + +# ENKA_NETWORK_API 可选配置项 +ENKA_NETWORK_API_AGENT="" \ No newline at end of file diff --git a/core/config.py b/core/config.py index 41e2894..6ef6d52 100644 --- a/core/config.py +++ b/core/config.py @@ -48,6 +48,8 @@ class BotConfig(BaseSettings): logger_traceback_max_frames: int = 20 logger_render_keywords: List[str] = ['BOT'] + enka_network_api_agent: str = "" + class Config: case_sensitive = False json_loads = json.loads diff --git a/plugins/genshin/player_cards.py b/plugins/genshin/player_cards.py index af279a2..93c3357 100644 --- a/plugins/genshin/player_cards.py +++ b/plugins/genshin/player_cards.py @@ -23,6 +23,7 @@ from telegram.constants import ChatAction from telegram.ext import CallbackContext, CallbackQueryHandler, CommandHandler, MessageHandler, filters from core.baseplugin import BasePlugin +from core.config import config from core.plugin import Plugin, handler from core.template import TemplateService from core.user import UserService @@ -43,7 +44,7 @@ assets = Assets(lang="chs") class PlayerCards(Plugin, BasePlugin): def __init__(self, user_service: UserService = None, template_service: TemplateService = None): self.user_service = user_service - self.client = EnkaNetworkAPI(lang="chs", agent="TGPaimonBot/3.0") + self.client = EnkaNetworkAPI(lang="chs", agent=config.enka_network_api_agent) self.template_service = template_service self.temp_photo = open("resources/img/kitsune.png", "rb")