🐛 Fix Some Bugs

This commit is contained in:
omg-xtao 2023-05-14 18:02:28 +08:00 committed by GitHub
parent e37a4fb777
commit 04d0f3cf31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -5,7 +5,7 @@ import aiofiles
import httpx
from httpx import UnsupportedProtocol
from telegram import Chat, Message, ReplyKeyboardRemove, Update
from telegram.error import BadRequest, Forbidden
from telegram.error import Forbidden, NetworkError
from telegram.ext import CallbackContext, ConversationHandler, Job
from core.dependence.redisdb import RedisDB
@ -53,7 +53,7 @@ class PluginFuncs:
chat_info = f"{full_name}[{chat.id}]"
else:
chat_info = f"{chat.title}[{chat.id}]"
except (BadRequest, Forbidden) as exc:
except (NetworkError, Forbidden) as exc:
logger.warning("获取 chat info 失败 %s", exc.message)
except Exception as exc:
logger.warning("获取 chat info 消息失败 %s", str(exc))
@ -63,7 +63,7 @@ class PluginFuncs:
try:
# noinspection PyTypeChecker
await context.bot.delete_message(chat_id=job.chat_id, message_id=message_id)
except BadRequest as exc:
except NetworkError as exc:
logger.warning("删除消息 %s message_id[%s] 失败 %s", chat_info, message_id, exc.message)
except Forbidden as exc:
logger.warning("删除消息 %s message_id[%s] 失败 %s", chat_info, message_id, exc.message)

View File

@ -90,7 +90,7 @@ class BindAccountPlugin(Plugin.Conversation):
else:
await message.reply_text("选择错误,请重新选择")
return CHECK_SERVER
reply_keyboard = [["通过玩家ID", "过账号ID"], ["退出"]]
reply_keyboard = [["通过玩家ID", "过账号ID"], ["退出"]]
await message.reply_markdown_v2(
"请选择你要绑定的方式", reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True)
)
@ -106,7 +106,7 @@ class BindAccountPlugin(Plugin.Conversation):
if message.text == "通过玩家ID":
await message.reply_text("请输入你的玩家ID非通行证ID", reply_markup=ReplyKeyboardRemove())
return CHECK_PLAYER_ID
if message.text == "过账号ID":
if message.text == "过账号ID":
await message.reply_text("请输入你的通行证ID非玩家ID", reply_markup=ReplyKeyboardRemove())
return CHECK_ACCOUNT_ID
await message.reply_text("选择错误,请重新选择")

View File

@ -334,6 +334,7 @@ class AccountCookiesPlugin(Plugin.Conversation):
player = account_cookies_plugin_data.player
genshin_account = account_cookies_plugin_data.genshin_account
if player:
player.account_id = account_cookies_plugin_data.account_id
await self.players_service.update(player)
cookies_data_base = account_cookies_plugin_data.cookies_data_base
if cookies_data_base:

View File

@ -230,7 +230,8 @@ class DailyMaterial(Plugin):
logger.info("正在获取每日素材缓存")
self.data = await self._refresh_data()
for domain, sche in self.data.items():
area = DOMAIN_AREA_MAP[domain := domain.strip()] # 获取秘境所在的区域
domain = domain.strip()
area = DOMAIN_AREA_MAP[domain] # 获取秘境所在的区域
type_ = "avatar" if DOMAINS.index(domain) < 4 else "weapon" # 获取秘境的培养素材的类型:是天赋书还是武器突破材料
# 将读取到的数据存入 local_data 中
local_data[type_].append({"name": area, "materials": sche[weekday][0], "items": sche[weekday][1]})