diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b4657d17..514a49ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,8 @@ repos: - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.2.0 hooks: - id: black args: - --diff - - --check \ No newline at end of file + - --check diff --git a/alembic/versions/1df05b897d3f_tasks.py b/alembic/versions/1df05b897d3f_tasks.py index b69f645b..bd33abf3 100644 --- a/alembic/versions/1df05b897d3f_tasks.py +++ b/alembic/versions/1df05b897d3f_tasks.py @@ -5,6 +5,7 @@ Revises: a1c10da5704b Create Date: 2023-07-23 14:44:59.592519 """ + import logging from alembic import op diff --git a/alembic/versions/27aaa52f9d4a_groups.py b/alembic/versions/27aaa52f9d4a_groups.py index 83400e39..b3ae57f5 100644 --- a/alembic/versions/27aaa52f9d4a_groups.py +++ b/alembic/versions/27aaa52f9d4a_groups.py @@ -5,6 +5,7 @@ Revises: c6282bc5bf67 Create Date: 2024-01-16 13:54:37.980830 """ + from alembic import op import sqlalchemy as sa import sqlmodel diff --git a/alembic/versions/89dcb9109475_tasks_daily.py b/alembic/versions/89dcb9109475_tasks_daily.py index a7e65d69..20c963c4 100644 --- a/alembic/versions/89dcb9109475_tasks_daily.py +++ b/alembic/versions/89dcb9109475_tasks_daily.py @@ -5,6 +5,7 @@ Revises: 27aaa52f9d4a Create Date: 2024-03-10 10:48:10.227236 """ + from alembic import op from sqlalchemy.dialects import mysql diff --git a/alembic/versions/9e9a36470cd5_init.py b/alembic/versions/9e9a36470cd5_init.py index 2caf2953..477da971 100644 --- a/alembic/versions/9e9a36470cd5_init.py +++ b/alembic/versions/9e9a36470cd5_init.py @@ -5,6 +5,7 @@ Revises: Create Date: 2022-09-01 16:55:20.372560 """ + from base64 import b64decode import sqlalchemy as sa diff --git a/alembic/versions/a1c10da5704b_devices.py b/alembic/versions/a1c10da5704b_devices.py index cdeace40..7684bd9e 100644 --- a/alembic/versions/a1c10da5704b_devices.py +++ b/alembic/versions/a1c10da5704b_devices.py @@ -5,6 +5,7 @@ Revises: ddcfba3c7d5c Create Date: 2023-06-13 19:34:47.189846 """ + from alembic import op import sqlalchemy as sa import sqlmodel diff --git a/alembic/versions/c6282bc5bf67_devices_valid.py b/alembic/versions/c6282bc5bf67_devices_valid.py index c455cec1..440138cd 100644 --- a/alembic/versions/c6282bc5bf67_devices_valid.py +++ b/alembic/versions/c6282bc5bf67_devices_valid.py @@ -5,6 +5,7 @@ Revises: 1df05b897d3f Create Date: 2023-10-19 14:54:35.164497 """ + from alembic import op import sqlalchemy as sa diff --git a/alembic/versions/cb37027ecae8_channel_alias.py b/alembic/versions/cb37027ecae8_channel_alias.py index f3e394e2..423f3394 100644 --- a/alembic/versions/cb37027ecae8_channel_alias.py +++ b/alembic/versions/cb37027ecae8_channel_alias.py @@ -5,6 +5,7 @@ Revises: 89dcb9109475 Create Date: 2024-03-10 17:08:14.167818 """ + from alembic import op import sqlalchemy as sa diff --git a/alembic/versions/ddcfba3c7d5c_v4.py b/alembic/versions/ddcfba3c7d5c_v4.py index 396bbfe0..2af47f85 100644 --- a/alembic/versions/ddcfba3c7d5c_v4.py +++ b/alembic/versions/ddcfba3c7d5c_v4.py @@ -5,6 +5,7 @@ Revises: 9e9a36470cd5 Create Date: 2023-02-11 17:07:18.170175 """ + import json import logging from base64 import b64decode diff --git a/core/dependence/assets.pyi b/core/dependence/assets.pyi index ba1b2503..dc1a4702 100644 --- a/core/dependence/assets.pyi +++ b/core/dependence/assets.pyi @@ -38,26 +38,34 @@ class _AssetsService(ABC): @property def game_name(self) -> str: """游戏数据中的名称""" + @property def honey_id(self) -> str: """当前资源在 Honey Impact 所对应的 ID""" + @property def path(self) -> Path: """当前资源的文件夹""" + @property def client(self) -> AsyncClient: """当前的 http client""" + def __init__(self, client: AsyncClient | None = None) -> None: ... def __call__(self, target: int) -> Self: """用于生成与 target 对应的 assets""" + def __getattr__(self, item: str) -> _GET_TYPE: """魔法""" + async def get_link(self, item: str) -> str | None: """获取相应图标链接""" + @abstractmethod @property def game_name_map(self) -> dict[str, str]: """游戏中的图标名""" + @abstractmethod @property def honey_name_map(self) -> dict[str, str]: diff --git a/core/error.py b/core/error.py index ce929526..79028fb7 100644 --- a/core/error.py +++ b/core/error.py @@ -1,4 +1,5 @@ """此模块包含核心模块的错误的基类""" + from gram_core.error import ServiceNotFoundError __all__ = ("ServiceNotFoundError",) diff --git a/metadata/pool/pool_100.py b/metadata/pool/pool_100.py index 45de441f..4df0371c 100644 --- a/metadata/pool/pool_100.py +++ b/metadata/pool/pool_100.py @@ -1 +1,3 @@ -POOL_100 = [{"five": ["新手池"], "four": [], "from": "2020-09-15 06:00:00", "name": "新手池", "to": "2050-09-15 17:59:59"}] +POOL_100 = [ + {"five": ["新手池"], "four": [], "from": "2020-09-15 06:00:00", "name": "新手池", "to": "2050-09-15 17:59:59"} +] diff --git a/metadata/pool/pool_200.py b/metadata/pool/pool_200.py index 382993f6..b3a8032a 100644 --- a/metadata/pool/pool_200.py +++ b/metadata/pool/pool_200.py @@ -1 +1,3 @@ -POOL_200 = [{"five": ["常驻池"], "four": [], "from": "2020-09-15 06:00:00", "name": "奔行世间", "to": "2050-09-15 17:59:59"}] +POOL_200 = [ + {"five": ["常驻池"], "four": [], "from": "2020-09-15 06:00:00", "name": "奔行世间", "to": "2050-09-15 17:59:59"} +] diff --git a/metadata/shortname.py b/metadata/shortname.py index 64c3c60c..69a5419c 100644 --- a/metadata/shortname.py +++ b/metadata/shortname.py @@ -39,13 +39,37 @@ roles = { "黄毛叔叔", "大黄倭瓜那菈", ], - 10000002: ["神里绫华", "ayaka", "kamisato ayaka", "神里", "绫华", "神里凌华", "凌华", "白鹭公主", "神里大小姐", "冰骗骗花", "龟龟"], + 10000002: [ + "神里绫华", + "ayaka", + "kamisato ayaka", + "神里", + "绫华", + "神里凌华", + "凌华", + "白鹭公主", + "神里大小姐", + "冰骗骗花", + "龟龟", + ], 10000003: ["琴", "jean", "团长", "代理团长", "琴团长", "蒲公英骑士", "蒙德砍王", "骑士团的魂"], 10000005: ["空", "aether", "男主", "男主角", "龙哥", "空哥", "王子"], 10000006: ["丽莎", "lisa", "图书管理员", "图书馆管理员", "蔷薇魔女"], 10000007: ["荧", "lumine", "女主", "女主角", "莹", "萤", "黄毛阿姨", "荧妹", "公主殿下"], 10000014: ["芭芭拉", "barbara", "巴巴拉", "拉粑粑", "拉巴巴", "内鬼", "加湿器", "闪耀偶像", "偶像", "蒙德辣王"], - 10000015: ["凯亚", "kaeya", "盖亚", "凯子哥", "凯鸭", "矿工", "矿工头子", "骑兵队长", "凯子", "凝冰渡海真君", "花脸猫"], + 10000015: [ + "凯亚", + "kaeya", + "盖亚", + "凯子哥", + "凯鸭", + "矿工", + "矿工头子", + "骑兵队长", + "凯子", + "凝冰渡海真君", + "花脸猫", + ], 10000016: [ "迪卢克", "diluc", @@ -202,8 +226,33 @@ roles = { "废人养成器", "听书人", ], - 10000031: ["菲谢尔", "fischl", "皇女", "小艾米", "小艾咪", "奥兹", "断罪皇女", "中二病", "中二少女", "中二皇女", "奥兹发射器"], - 10000032: ["班尼特", "bennett", "点赞哥", "点赞", "倒霉少年", "倒霉蛋", "霹雳闪雷真君", "班神", "班爷", "倒霉", "火神", "六星真神"], + 10000031: [ + "菲谢尔", + "fischl", + "皇女", + "小艾米", + "小艾咪", + "奥兹", + "断罪皇女", + "中二病", + "中二少女", + "中二皇女", + "奥兹发射器", + ], + 10000032: [ + "班尼特", + "bennett", + "点赞哥", + "点赞", + "倒霉少年", + "倒霉蛋", + "霹雳闪雷真君", + "班神", + "班爷", + "倒霉", + "火神", + "六星真神", + ], 10000033: [ "达达利亚", "tartaglia", @@ -226,7 +275,19 @@ roles = { "大貉妖处理专家", ], 10000034: ["诺艾尔", "noelle", "女仆", "高达", "岩王帝姬", "山吹", "冰萤术士", "岩王帝姬"], - 10000035: ["七七", "qiqi", "僵尸", "肚饿真君", "度厄真君", "77", "起死回骸童子", "救苦度厄真君", "椰羊创始人", "不卜庐砍王", "不卜庐剑圣"], + 10000035: [ + "七七", + "qiqi", + "僵尸", + "肚饿真君", + "度厄真君", + "77", + "起死回骸童子", + "救苦度厄真君", + "椰羊创始人", + "不卜庐砍王", + "不卜庐剑圣", + ], 10000036: ["重云", "chongyun", "纯阳之体", "冰棍", "驱邪世家", "大外甥"], 10000037: ["甘雨", "ganyu", "椰羊", "椰奶", "鸡腿猎人", "咕噜咕噜滚下山真君", "肝雨", "走路上山真君"], 10000038: [ @@ -406,7 +467,18 @@ roles = { "海天后", "深海舌鲆鱼小姐", ], - 10000055: ["五郎", "gorou", "柴犬", "土狗", "希娜", "希娜小姐", "海祇岛的小狗大将", "修勾", "五郎大将的朋友", "小狗勾"], + 10000055: [ + "五郎", + "gorou", + "柴犬", + "土狗", + "希娜", + "希娜小姐", + "海祇岛的小狗大将", + "修勾", + "五郎大将的朋友", + "小狗勾", + ], 10000056: [ "九条裟罗", "sara", @@ -486,7 +558,18 @@ roles = { "名侦探柯南", "捕快展昭", ], - 10000060: ["夜兰", "yelan", "夜阑", "叶澜", "腋兰", "夜天后", "自称就职于总务司的神秘人士", "岩上茶室老板", "夜上海", "胸怀大痣"], + 10000060: [ + "夜兰", + "yelan", + "夜阑", + "叶澜", + "腋兰", + "夜天后", + "自称就职于总务司的神秘人士", + "岩上茶室老板", + "夜上海", + "胸怀大痣", + ], 10000061: ["绮良良", "kirara", "稻妻猫猫", "猫猫快递"], 10000062: ["埃洛伊", "aloy", "异界的救世主"], 10000063: ["申鹤", "shenhe", "神鹤", "小姨", "阿鹤", "小姨子", "审鹤", "仙家弟子", "驱邪世家旁", "药材杀手"], @@ -546,7 +629,17 @@ roles = { "安柏的挚友", "兰那罗奶奶", ], - 10000068: ["多莉", "dori", "多利", "多力", "多丽", "奸商", "须弥百货商人", "桑歌玛哈巴依老爷", "艾尔卡萨扎莱宫之主"], + 10000068: [ + "多莉", + "dori", + "多利", + "多力", + "多丽", + "奸商", + "须弥百货商人", + "桑歌玛哈巴依老爷", + "艾尔卡萨扎莱宫之主", + ], 10000069: [ "提纳里", "tighnari", @@ -564,7 +657,20 @@ roles = { "柯莱的师父", ], 10000070: ["妮露", "nilou", "尼露", "祖拜尔剧场之星", "红牛"], - 10000071: ["赛诺", "cyno", "赛洛", "大风纪官", "大风机关", "胡狼头大人", "夹击妹抖", "游戏王", "冷笑话爱好者", "牌佬", "沙漠死神", "胡狼"], + 10000071: [ + "赛诺", + "cyno", + "赛洛", + "大风纪官", + "大风机关", + "胡狼头大人", + "夹击妹抖", + "游戏王", + "冷笑话爱好者", + "牌佬", + "沙漠死神", + "胡狼", + ], 10000072: ["坎蒂丝", "candace", "坎迪斯", "水北斗", "赤王后裔", "阿如村守护者"], 10000073: [ "纳西妲", @@ -607,9 +713,37 @@ roles = { "伪神", "阿帽", ], - 10000076: ["珐露珊", "faruzan", "法露珊", "珐妹", "初音", "初音未来", "miku", "发露姗", "发姐", "法姐", "百岁珊", "百岁山", "童姥", "知论派名宿"], + 10000076: [ + "珐露珊", + "faruzan", + "法露珊", + "珐妹", + "初音", + "初音未来", + "miku", + "发露姗", + "发姐", + "法姐", + "百岁珊", + "百岁山", + "童姥", + "知论派名宿", + ], 10000077: ["瑶瑶", "yaoyao", "遥遥", "遥遥无期", "香菱师妹", "萝卜", "四星草奶"], - 10000078: ["艾尔海森", "alhaitham", "爱尔海森", "艾尔海参", "艾尔", "海森", "海参", "海神", "埃尔海森", "草刻晴", "书记官", "代理大贤者"], + 10000078: [ + "艾尔海森", + "alhaitham", + "爱尔海森", + "艾尔海参", + "艾尔", + "海森", + "海参", + "海神", + "埃尔海森", + "草刻晴", + "书记官", + "代理大贤者", + ], 10000079: ["迪希雅", "dehya", "狮女", "狮子", "腕豪", "女拳"], 10000080: ["米卡", "mika", "镜音连", "咪卡", "小米"], 10000081: ["卡维", "kaveh", "夺少"], @@ -620,7 +754,18 @@ roles = { 10000086: ["莱欧斯利", "wriothesley", "典狱长", "大狼狗", "莱欧斯利公爵", "公爵", "公爵大人"], 10000087: ["那维莱特", "neuvillette", "水龙", "龙王", "水龙王", "那维", "大审判官"], 10000088: ["夏洛蒂", "charlotte", "记者", "枫丹记者", "射命丸文", "大新闻", "弄个大新闻"], - 10000089: ["芙宁娜", "furina", "芙宁娜·德·枫丹", "芙芙", "水神", "芙宁娜大人", "芙宁娜女士", "众水的颂诗", "不休独舞", "众水、众方、众民与众律法的女王"], + 10000089: [ + "芙宁娜", + "furina", + "芙宁娜·德·枫丹", + "芙芙", + "水神", + "芙宁娜大人", + "芙宁娜女士", + "众水的颂诗", + "不休独舞", + "众水、众方、众民与众律法的女王", + ], 10000090: ["夏沃蕾", "chevreuse"], 10000091: ["娜维娅", "navia", "黄豆姐"], 10000092: ["嘉明", "gaming"], diff --git a/modules/apihelper/client/components/calendar.py b/modules/apihelper/client/components/calendar.py index 1241af23..381b4e33 100644 --- a/modules/apihelper/client/components/calendar.py +++ b/modules/apihelper/client/components/calendar.py @@ -40,7 +40,9 @@ class Calendar: 762, # 《原神》公平运营声明 762, # 《原神》公平运营声明 ] - IGNORE_RE = re.compile(r"(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时|周边上新|角色演示)") + IGNORE_RE = re.compile( + r"(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时|周边上新|角色演示)" + ) FULL_TIME_RE = re.compile(r"(魔神任务)") def __init__(self): @@ -86,7 +88,9 @@ class Calendar: continue content = re.sub(r'(<|<)[\w "%:;=\-\\/\\(\\),\\.]+(>|>)', "", content) try: - if reg_ret := re.search(r"(?:活动时间|祈愿介绍|任务开放时间|冒险....包|折扣时间)\s*〓([^〓]+)(〓|$)", content): + if reg_ret := re.search( + r"(?:活动时间|祈愿介绍|任务开放时间|冒险....包|折扣时间)\s*〓([^〓]+)(〓|$)", content + ): if time_ret := re.search(r"(?:活动时间)?(?:〓|\s)*([0-9\\/\\: ~]{6,})", reg_ret[1]): start_time, end_time = time_ret[1].split("~") start_time = start_time.replace("/", "-").strip() diff --git a/modules/gacha_log/log.py b/modules/gacha_log/log.py index 4809c02f..3ec93af5 100644 --- a/modules/gacha_log/log.py +++ b/modules/gacha_log/log.py @@ -177,9 +177,13 @@ class GachaLog: four_star = len([i for i in data if i.rank_type == "4"]) if total > 50: if total <= five_star * 15: - raise GachaLogFileError("检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。") + raise GachaLogFileError( + "检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。" + ) if four_star < five_star: - raise GachaLogFileError("检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。") + raise GachaLogFileError( + "检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。" + ) return True except Exception as exc: # pylint: disable=W0703 raise GachaLogFileError from exc diff --git a/modules/wish/system.py b/modules/wish/system.py index efbbc1e7..bd727404 100644 --- a/modules/wish/system.py +++ b/modules/wish/system.py @@ -89,7 +89,9 @@ class BannerSystem: gacha_info: PlayerGachaBannerInfo, ) -> int: # 以下是防止点炒饭 - epitomized = (banner.has_epitomized()) and (rarity == 5) and (gacha_info.wish_item_id != 0) # 判断定轨信息是否正确 + epitomized = ( + (banner.has_epitomized()) and (rarity == 5) and (gacha_info.wish_item_id != 0) + ) # 判断定轨信息是否正确 pity_epitomized = gacha_info.failed_chosen_item_pulls >= banner.wish_max_progress # 判断定轨值 pity_featured = gacha_info.get_failed_featured_item_pulls(rarity) >= 1 # 通过UP值判断当前是否为UP roll_featured = self.random_range(1, 100) <= banner.get_event_chance(rarity) # 随机判断当前是否为UP diff --git a/plugins/account/account.py b/plugins/account/account.py index d7660051..248157c2 100644 --- a/plugins/account/account.py +++ b/plugins/account/account.py @@ -111,10 +111,14 @@ class BindAccountPlugin(Plugin.Conversation): await message.reply_text("退出任务", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END if message.text == "通过玩家ID": - await message.reply_text("请输入你的玩家ID(非通行证ID),此 ID 在 游戏客户端 左/右下角。", reply_markup=ReplyKeyboardRemove()) + await message.reply_text( + "请输入你的玩家ID(非通行证ID),此 ID 在 游戏客户端 左/右下角。", reply_markup=ReplyKeyboardRemove() + ) return CHECK_PLAYER_ID if message.text == "通过账号ID": - await message.reply_text("请输入你的通行证ID(非玩家ID),此 ID 在 社区APP '我的' 页面。", reply_markup=ReplyKeyboardRemove()) + await message.reply_text( + "请输入你的通行证ID(非玩家ID),此 ID 在 社区APP '我的' 页面。", reply_markup=ReplyKeyboardRemove() + ) return CHECK_ACCOUNT_ID await message.reply_text("选择错误,请重新选择") return CHECK_METHOD @@ -140,7 +144,9 @@ class BindAccountPlugin(Plugin.Conversation): await message.reply_text("用户查询次数过多,请稍后重试", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END except CookiesCachePoolExhausted: - await message.reply_text("公共Cookies池已经耗尽,请稍后重试或者绑定 cookie", reply_markup=ReplyKeyboardRemove()) + await message.reply_text( + "公共Cookies池已经耗尽,请稍后重试或者绑定 cookie", reply_markup=ReplyKeyboardRemove() + ) return ConversationHandler.END if region == RegionEnum.HYPERION: client = GenshinClient(cookies=cookies.data, region=Region.CHINESE) @@ -174,7 +180,9 @@ class BindAccountPlugin(Plugin.Conversation): bind_account_plugin_data.account_id = account_id reply_keyboard = [["确认", "退出"]] await message.reply_text("获取角色基础信息成功,请检查是否正确!") - logger.info("用户 %s[%s] 获取账号 %s[%s] 信息成功", user.full_name, user.id, record_card.nickname, record_card.uid) + logger.info( + "用户 %s[%s] 获取账号 %s[%s] 信息成功", user.full_name, user.id, record_card.nickname, record_card.uid + ) text = ( f"*角色信息*\n" f"角色名称:{escape_markdown(record_card.nickname, version=2)}\n" @@ -238,7 +246,9 @@ class BindAccountPlugin(Plugin.Conversation): return ConversationHandler.END reply_keyboard = [["确认", "退出"]] await message.reply_text("获取角色基础信息成功,请检查是否正确!") - logger.info("用户 %s[%s] 获取账号 %s[%s] 信息成功", user.full_name, user.id, player_stats.info.nickname, player_id) + logger.info( + "用户 %s[%s] 获取账号 %s[%s] 信息成功", user.full_name, user.id, player_stats.info.nickname, player_id + ) text = ( f"*角色信息*\n" f"角色名称:{escape_markdown(player_stats.info.nickname, version=2)}\n" diff --git a/plugins/account/cookies.py b/plugins/account/cookies.py index a9a3f304..8477bd05 100644 --- a/plugins/account/cookies.py +++ b/plugins/account/cookies.py @@ -236,7 +236,9 @@ class AccountCookiesPlugin(Plugin.Conversation): logger.success("用户 %s[%s] 绑定时获取 stoken 成功", user.full_name, user.id) check_cookie = True except SimnetBadRequest as exc: - logger.warning("用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original) + logger.warning( + "用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original + ) except Exception as exc: logger.error("绑定时获取新Cookie失败 [%s]", (str(exc))) finally: @@ -245,10 +247,14 @@ class AccountCookiesPlugin(Plugin.Conversation): if not check_cookie: await message.reply_text("检测到Cookie不完整,可能会出现问题。", reply_markup=ReplyKeyboardRemove()) if not cookies.stoken: - await message.reply_text("检测到缺少 stoken,请尝试添加 stoken 后重新绑定。", reply_markup=ReplyKeyboardRemove()) + await message.reply_text( + "检测到缺少 stoken,请尝试添加 stoken 后重新绑定。", reply_markup=ReplyKeyboardRemove() + ) return ConversationHandler.END if cookies.stoken and cookies.stoken.startswith("v2") and cookies.mid is None: - await message.reply_text("检测到缺少 mid,请尝试添加 mid 后重新绑定。", reply_markup=ReplyKeyboardRemove()) + await message.reply_text( + "检测到缺少 mid,请尝试添加 mid 后重新绑定。", reply_markup=ReplyKeyboardRemove() + ) return ConversationHandler.END try: if region == Region.CHINESE: @@ -266,9 +272,13 @@ class AccountCookiesPlugin(Plugin.Conversation): cookies.mid = cookies_model.mid cookies.ltoken = cookies_model.ltoken cookies.cookie_token = cookies_model.cookie_token - logger.success("用户 %s[%s] 绑定时获取 stoken_v2, mid, ltoken, cookie_token 成功", user.full_name, user.id) + logger.success( + "用户 %s[%s] 绑定时获取 stoken_v2, mid, ltoken, cookie_token 成功", user.full_name, user.id + ) except SimnetBadRequest as exc: - logger.warning("用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original) + logger.warning( + "用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original + ) await message.reply_text("Stoken 无效,请重新绑定。", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END except UnicodeEncodeError: @@ -300,13 +310,17 @@ class AccountCookiesPlugin(Plugin.Conversation): except InvalidCookies: logger.info("用户 %s[%s] Cookies已经过期", user.full_name, user.id) await message.reply_text( - "获取账号信息失败,返回Cookies已经过期,请尝试在无痕浏览器中登录获取Cookies。", reply_markup=ReplyKeyboardRemove() + "获取账号信息失败,返回Cookies已经过期,请尝试在无痕浏览器中登录获取Cookies。", + reply_markup=ReplyKeyboardRemove(), ) return ConversationHandler.END except SimnetBadRequest as exc: - logger.info("用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original) + logger.info( + "用户 %s[%s] 获取账号信息发生错误 [%s]%s", user.full_name, user.id, exc.ret_code, exc.original + ) await message.reply_text( - f"获取账号信息发生错误,错误信息为 {exc.original},请检查Cookie或者账号是否正常", reply_markup=ReplyKeyboardRemove() + f"获取账号信息发生错误,错误信息为 {exc.original},请检查Cookie或者账号是否正常", + reply_markup=ReplyKeyboardRemove(), ) return ConversationHandler.END except AccountIdNotFound: @@ -344,7 +358,11 @@ class AccountCookiesPlugin(Plugin.Conversation): reply_keyboard = [["确认", "退出"]] await message.reply_text("获取角色基础信息成功,请检查是否正确!") logger.info( - "用户 %s[%s] 获取账号 %s[%s] 信息成功", user.full_name, user.id, genshin_account.nickname, genshin_account.uid + "用户 %s[%s] 获取账号 %s[%s] 信息成功", + user.full_name, + user.id, + genshin_account.nickname, + genshin_account.uid, ) text = ( f"*角色信息*\n" diff --git a/plugins/account/players.py b/plugins/account/players.py index 8d249222..bd7e6c68 100644 --- a/plugins/account/players.py +++ b/plugins/account/players.py @@ -41,7 +41,9 @@ class PlayersManagesPlugin(Plugin): _handle = _data[-3] _user_id = int(_data[-2]) _player_id = int(_data[-1]) - logger.debug("players_manager_callback函数返回 handle[%s] user_id[%s] player_id[%s]", _handle, _user_id, _player_id) + logger.debug( + "players_manager_callback函数返回 handle[%s] user_id[%s] player_id[%s]", _handle, _user_id, _player_id + ) return _handle, _user_id, _player_id @handler.command(command="player", filters=filters.ChatType.PRIVATE, block=False) @@ -71,7 +73,9 @@ class PlayersManagesPlugin(Plugin): ] ) if callback_query: - await callback_query.edit_message_text("从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons)) + await callback_query.edit_message_text( + "从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons) + ) else: await message.reply_text("从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons)) @@ -136,7 +140,8 @@ class PlayersManagesPlugin(Plugin): buttons.insert(-1, temp_buttons) await callback_query.edit_message_text( - f"这里是 {player.player_id} {player_info.nickname}\n你想用这个账号做什么?", reply_markup=InlineKeyboardMarkup(buttons) + f"这里是 {player.player_id} {player_info.nickname}\n你想用这个账号做什么?", + reply_markup=InlineKeyboardMarkup(buttons), ) @handler.callback_query(r"^players_manager\|update\|", block=False) @@ -208,7 +213,8 @@ class PlayersManagesPlugin(Plugin): cookies_data = await self.cookies_service.get(player.user_id, player.account_id, player.region) if cookies_data is None: await callback_query.edit_message_text( - f"玩家 {player.player_id} {player_info.nickname} cookies 未找到", reply_markup=InlineKeyboardMarkup(buttons) + f"玩家 {player.player_id} {player_info.nickname} cookies 未找到", + reply_markup=InlineKeyboardMarkup(buttons), ) cookies = CookiesModel(**cookies_data.data) @@ -233,11 +239,13 @@ class PlayersManagesPlugin(Plugin): cookies_data.status = CookiesStatusEnum.STATUS_SUCCESS await self.cookies_service.update(cookies_data) await callback_query.edit_message_text( - f"玩家 {player.player_id} {player_info.nickname} cookies 刷新成功", reply_markup=InlineKeyboardMarkup(buttons) + f"玩家 {player.player_id} {player_info.nickname} cookies 刷新成功", + reply_markup=InlineKeyboardMarkup(buttons), ) else: await callback_query.edit_message_text( - f"玩家 {player.player_id} {player_info.nickname} stoken 未找到", reply_markup=InlineKeyboardMarkup(buttons) + f"玩家 {player.player_id} {player_info.nickname} stoken 未找到", + reply_markup=InlineKeyboardMarkup(buttons), ) @handler.callback_query(r"^players_manager\|export_cookies\|", block=False) @@ -274,7 +282,8 @@ class PlayersManagesPlugin(Plugin): cookies_data = await self.cookies_service.get(player.user_id, player.account_id, player.region) if cookies_data is None: await callback_query.edit_message_text( - f"玩家 {player.player_id} {player_info.nickname} cookies 未找到", reply_markup=InlineKeyboardMarkup(buttons) + f"玩家 {player.player_id} {player_info.nickname} cookies 未找到", + reply_markup=InlineKeyboardMarkup(buttons), ) return device = await self.devices_service.get(player.account_id) @@ -292,7 +301,8 @@ class PlayersManagesPlugin(Plugin): f"
{html.escape(cookie_str)}", ) await message.reply_text( - f"玩家 {player.player_id} {player_info.nickname} cookies 导出成功", reply_markup=InlineKeyboardMarkup(buttons) + f"玩家 {player.player_id} {player_info.nickname} cookies 导出成功", + reply_markup=InlineKeyboardMarkup(buttons), ) await message.delete() @@ -393,7 +403,9 @@ class PlayersManagesPlugin(Plugin): ) ], ] - await callback_query.edit_message_text("请问你真的要从Bot中删除改账号吗?", reply_markup=InlineKeyboardMarkup(buttons)) + await callback_query.edit_message_text( + "请问你真的要从Bot中删除改账号吗?", reply_markup=InlineKeyboardMarkup(buttons) + ) else: if callback_query.message: await callback_query.message.delete() diff --git a/plugins/admin/group_manage.py b/plugins/admin/group_manage.py index f3e5f438..e899dd90 100644 --- a/plugins/admin/group_manage.py +++ b/plugins/admin/group_manage.py @@ -89,7 +89,11 @@ class GroupManage(Plugin): message = update.effective_message chat_id = self.get_chat_id(context) if not callback_query else int(callback_query.data.split("|")[2]) logger.info( - "用户 %s[%s] add_block 命令请求 chat_id[%s] callback[%s]", user.full_name, user.id, chat_id, bool(callback_query) + "用户 %s[%s] add_block 命令请求 chat_id[%s] callback[%s]", + user.full_name, + user.id, + chat_id, + bool(callback_query), ) if not chat_id: await message.reply_text("参数错误,请指定群 id !") @@ -126,7 +130,11 @@ class GroupManage(Plugin): message = update.effective_message chat_id = self.get_chat_id(context) if not callback_query else int(callback_query.data.split("|")[2]) logger.info( - "用户 %s[%s] del_block 命令请求 chat_id[%s] callback[%s]", user.full_name, user.id, chat_id, bool(callback_query) + "用户 %s[%s] del_block 命令请求 chat_id[%s] callback[%s]", + user.full_name, + user.id, + chat_id, + bool(callback_query), ) if not chat_id: await message.reply_text("参数错误,请指定群 id !") diff --git a/plugins/admin/post.py b/plugins/admin/post.py index 07848174..652970f1 100644 --- a/plugins/admin/post.py +++ b/plugins/admin/post.py @@ -380,7 +380,10 @@ class Post(Plugin.Conversation): post_handler_data: PostHandlerData = context.chat_data.get("post_handler_data") photo_len = len(post_handler_data.post_images) message = update.effective_message - await message.reply_text("请回复你要删除的图片的序列,从1开始,如果删除多张图片回复的序列请以空格作为分隔符," f"当前一共有 {photo_len} 张图片") + await message.reply_text( + "请回复你要删除的图片的序列,从1开始,如果删除多张图片回复的序列请以空格作为分隔符," + f"当前一共有 {photo_len} 张图片" + ) return GTE_DELETE_PHOTO @conversation.state(state=GTE_DELETE_PHOTO) @@ -445,7 +448,9 @@ class Post(Plugin.Conversation): @staticmethod async def add_tags(update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> int: message = update.effective_message - await message.reply_text("请回复添加的tag名称,如果要添加多个tag请以空格作为分隔符,不用添加 # 作为开头,推送时程序会自动添加") + await message.reply_text( + "请回复添加的tag名称,如果要添加多个tag请以空格作为分隔符,不用添加 # 作为开头,推送时程序会自动添加" + ) return GET_TAGS @conversation.state(state=GET_TAGS) diff --git a/plugins/admin/post_code.py b/plugins/admin/post_code.py index 0ac553b6..ed6c119e 100644 --- a/plugins/admin/post_code.py +++ b/plugins/admin/post_code.py @@ -220,7 +220,9 @@ class PostCode(Plugin.Conversation): return await self.get_channel(update, context) if message.text == "推送并且定时更新": if not post_code_handler_data.real_need_update(): - await message.reply_text("所有兑换码已发放,无需创建更新任务,将直接推送。", reply_markup=ReplyKeyboardRemove()) + await message.reply_text( + "所有兑换码已发放,无需创建更新任务,将直接推送。", reply_markup=ReplyKeyboardRemove() + ) return await self.get_channel(update, context) post_code_handler_data.need_update = True await message.reply_text(post_code_handler_data.get_need_update_text()) diff --git a/plugins/admin/quiz.py b/plugins/admin/quiz.py index e816fa72..38edb764 100644 --- a/plugins/admin/quiz.py +++ b/plugins/admin/quiz.py @@ -104,7 +104,9 @@ class SetQuizPlugin(Plugin.Conversation): return ConversationHandler.END except ResponseError as exc: logger.error("重载问题失败", exc_info=exc) - await update.message.reply_text("重载问题失败,异常抛出Redis请求错误异常,详情错误请看日记", reply_markup=ReplyKeyboardRemove()) + await update.message.reply_text( + "重载问题失败,异常抛出Redis请求错误异常,详情错误请看日记", reply_markup=ReplyKeyboardRemove() + ) return ConversationHandler.END await update.message.reply_text("重载成功", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END @@ -116,7 +118,9 @@ class SetQuizPlugin(Plugin.Conversation): quiz_command_data.new_question = "" quiz_command_data.new_correct_answer = "" quiz_command_data.status = 1 - await update.message.reply_text("请回复你要添加的问题,或发送 /cancel 取消操作", reply_markup=ReplyKeyboardRemove()) + await update.message.reply_text( + "请回复你要添加的问题,或发送 /cancel 取消操作", reply_markup=ReplyKeyboardRemove() + ) return GET_NEW_QUESTION @conversation.state(state=GET_NEW_QUESTION) @@ -161,7 +165,9 @@ class SetQuizPlugin(Plugin.Conversation): ) await update.message.reply_markdown_v2(reply_text) reply_keyboard = [["保存并重载配置", "抛弃修改并退出"]] - await update.message.reply_text("请核对问题,并选择下一步操作。", reply_markup=ReplyKeyboardMarkup(reply_keyboard)) + await update.message.reply_text( + "请核对问题,并选择下一步操作。", reply_markup=ReplyKeyboardMarkup(reply_keyboard) + ) return SAVE_QUESTION @conversation.state(state=SAVE_QUESTION) @@ -216,7 +222,9 @@ class SetQuizPlugin(Plugin.Conversation): await self.quiz_service.refresh_quiz() except ResponseError as exc: logger.error("重载问题失败", exc_info=exc) - await update.message.reply_text("重载问题失败,异常抛出Redis请求错误异常,详情错误请看日记", reply_markup=ReplyKeyboardRemove()) + await update.message.reply_text( + "重载问题失败,异常抛出Redis请求错误异常,详情错误请看日记", reply_markup=ReplyKeyboardRemove() + ) return ConversationHandler.END await update.message.reply_text("重载配置成功", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END diff --git a/plugins/admin/set_command.py b/plugins/admin/set_command.py index d45f661d..fa051a23 100644 --- a/plugins/admin/set_command.py +++ b/plugins/admin/set_command.py @@ -88,7 +88,9 @@ class SetCommandPlugin(Plugin): BotCommand("add_block", "添加黑名单"), BotCommand("del_block", "移除黑名单"), ] - await context.bot.set_my_commands(commands=group_command) # 留空,default 为 botCommandScopeDefault, 所有聊天可见 + await context.bot.set_my_commands( + commands=group_command + ) # 留空,default 为 botCommandScopeDefault, 所有聊天可见 await context.bot.set_my_commands(commands=user_command + group_command, scope=BotCommandScopeAllPrivateChats()) if config.error.notification_chat_id: await context.bot.set_my_commands( diff --git a/plugins/app/inline.py b/plugins/app/inline.py index 10efec03..916ab675 100644 --- a/plugins/app/inline.py +++ b/plugins/app/inline.py @@ -153,7 +153,9 @@ class Inline(Plugin): title=f"当前查询内容为 {args[0]}", description="如果无查看图片描述 这是正常的 客户端问题", thumbnail_url="https://www.miyoushe.com/_nuxt/img/game-ys.dfc535b.jpg", - input_message_content=InputTextMessageContent(f"当前查询内容为 {args[0]}\n如果无查看图片描述 这是正常的 客户端问题"), + input_message_content=InputTextMessageContent( + f"当前查询内容为 {args[0]}\n如果无查看图片描述 这是正常的 客户端问题" + ), ) ) for simple_search_result in simple_search_results: diff --git a/plugins/channel/channel_alias.py b/plugins/channel/channel_alias.py index b2a69283..f513c1e7 100644 --- a/plugins/channel/channel_alias.py +++ b/plugins/channel/channel_alias.py @@ -26,7 +26,9 @@ CHANNEL_ALIAS_OPEN = """成功开启频道透视模式,派蒙将会把你当 - 在转让频道前,请务必关闭此功能。 """ CHANNEL_ALIAS_CLOSE = """成功关闭频道透视模式,派蒙将不会把你当做普通用户,现在你无法使用频道身份执行命令""" -CHANNEL_ADMIN_HELP = "参数错误,可用命令:\n\n- disable