From 04d0f3cf31643c73fe807a27b27ea9657bc32e29 Mon Sep 17 00:00:00 2001 From: omg-xtao <100690902+omg-xtao@users.noreply.github.com> Date: Sun, 14 May 2023 18:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Some=20Bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/plugin/_funcs.py | 6 +++--- plugins/account/account.py | 4 ++-- plugins/account/cookies.py | 1 + plugins/genshin/daily/material.py | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/plugin/_funcs.py b/core/plugin/_funcs.py index 9266f94f..1bbd2879 100644 --- a/core/plugin/_funcs.py +++ b/core/plugin/_funcs.py @@ -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) diff --git a/plugins/account/account.py b/plugins/account/account.py index 5b4062de..a714114d 100644 --- a/plugins/account/account.py +++ b/plugins/account/account.py @@ -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("选择错误,请重新选择") diff --git a/plugins/account/cookies.py b/plugins/account/cookies.py index 95b16004..871a1b34 100644 --- a/plugins/account/cookies.py +++ b/plugins/account/cookies.py @@ -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: diff --git a/plugins/genshin/daily/material.py b/plugins/genshin/daily/material.py index 0d208c73..afb6c4a9 100644 --- a/plugins/genshin/daily/material.py +++ b/plugins/genshin/daily/material.py @@ -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]})