🎨 添加 enka_network_api_agent 可选配置项

This commit is contained in:
洛水居室 2022-10-07 13:55:50 +08:00
parent 51dc36e913
commit 0f343a0e3c
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
3 changed files with 11 additions and 5 deletions

View File

@ -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=""

View File

@ -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

View File

@ -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")