💄 Format with black 24.x.x

* 💄 Format with black 24.x.x

* 💄 Update black version to 24.x.x in pre-commit check
This commit is contained in:
kotoriのねこ 2024-03-15 20:44:15 -05:00 committed by GitHub
parent 4151b80c0b
commit 8c8fa8ea99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
50 changed files with 489 additions and 127 deletions

View File

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 23.12.1 rev: 24.2.0
hooks: hooks:
- id: black - id: black
args: args:

View File

@ -5,6 +5,7 @@ Revises: a1c10da5704b
Create Date: 2023-07-23 14:44:59.592519 Create Date: 2023-07-23 14:44:59.592519
""" """
import logging import logging
from alembic import op from alembic import op

View File

@ -5,6 +5,7 @@ Revises: c6282bc5bf67
Create Date: 2024-01-16 13:54:37.980830 Create Date: 2024-01-16 13:54:37.980830
""" """
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
import sqlmodel import sqlmodel

View File

@ -5,6 +5,7 @@ Revises: 27aaa52f9d4a
Create Date: 2024-03-10 10:48:10.227236 Create Date: 2024-03-10 10:48:10.227236
""" """
from alembic import op from alembic import op
from sqlalchemy.dialects import mysql from sqlalchemy.dialects import mysql

View File

@ -5,6 +5,7 @@ Revises:
Create Date: 2022-09-01 16:55:20.372560 Create Date: 2022-09-01 16:55:20.372560
""" """
from base64 import b64decode from base64 import b64decode
import sqlalchemy as sa import sqlalchemy as sa

View File

@ -5,6 +5,7 @@ Revises: ddcfba3c7d5c
Create Date: 2023-06-13 19:34:47.189846 Create Date: 2023-06-13 19:34:47.189846
""" """
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
import sqlmodel import sqlmodel

View File

@ -5,6 +5,7 @@ Revises: 1df05b897d3f
Create Date: 2023-10-19 14:54:35.164497 Create Date: 2023-10-19 14:54:35.164497
""" """
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa

View File

@ -5,6 +5,7 @@ Revises: 89dcb9109475
Create Date: 2024-03-10 17:08:14.167818 Create Date: 2024-03-10 17:08:14.167818
""" """
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa

View File

@ -5,6 +5,7 @@ Revises: 9e9a36470cd5
Create Date: 2023-02-11 17:07:18.170175 Create Date: 2023-02-11 17:07:18.170175
""" """
import json import json
import logging import logging
from base64 import b64decode from base64 import b64decode

View File

@ -38,26 +38,34 @@ class _AssetsService(ABC):
@property @property
def game_name(self) -> str: def game_name(self) -> str:
"""游戏数据中的名称""" """游戏数据中的名称"""
@property @property
def honey_id(self) -> str: def honey_id(self) -> str:
"""当前资源在 Honey Impact 所对应的 ID""" """当前资源在 Honey Impact 所对应的 ID"""
@property @property
def path(self) -> Path: def path(self) -> Path:
"""当前资源的文件夹""" """当前资源的文件夹"""
@property @property
def client(self) -> AsyncClient: def client(self) -> AsyncClient:
"""当前的 http client""" """当前的 http client"""
def __init__(self, client: AsyncClient | None = None) -> None: ... def __init__(self, client: AsyncClient | None = None) -> None: ...
def __call__(self, target: int) -> Self: def __call__(self, target: int) -> Self:
"""用于生成与 target 对应的 assets""" """用于生成与 target 对应的 assets"""
def __getattr__(self, item: str) -> _GET_TYPE: def __getattr__(self, item: str) -> _GET_TYPE:
"""魔法""" """魔法"""
async def get_link(self, item: str) -> str | None: async def get_link(self, item: str) -> str | None:
"""获取相应图标链接""" """获取相应图标链接"""
@abstractmethod @abstractmethod
@property @property
def game_name_map(self) -> dict[str, str]: def game_name_map(self) -> dict[str, str]:
"""游戏中的图标名""" """游戏中的图标名"""
@abstractmethod @abstractmethod
@property @property
def honey_name_map(self) -> dict[str, str]: def honey_name_map(self) -> dict[str, str]:

View File

@ -1,4 +1,5 @@
"""此模块包含核心模块的错误的基类""" """此模块包含核心模块的错误的基类"""
from gram_core.error import ServiceNotFoundError from gram_core.error import ServiceNotFoundError
__all__ = ("ServiceNotFoundError",) __all__ = ("ServiceNotFoundError",)

View File

@ -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"}
]

View File

@ -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"}
]

View File

@ -39,13 +39,37 @@ roles = {
"黄毛叔叔", "黄毛叔叔",
"大黄倭瓜那菈", "大黄倭瓜那菈",
], ],
10000002: ["神里绫华", "ayaka", "kamisato ayaka", "神里", "绫华", "神里凌华", "凌华", "白鹭公主", "神里大小姐", "冰骗骗花", "龟龟"], 10000002: [
"神里绫华",
"ayaka",
"kamisato ayaka",
"神里",
"绫华",
"神里凌华",
"凌华",
"白鹭公主",
"神里大小姐",
"冰骗骗花",
"龟龟",
],
10000003: ["", "jean", "团长", "代理团长", "琴团长", "蒲公英骑士", "蒙德砍王", "骑士团的魂"], 10000003: ["", "jean", "团长", "代理团长", "琴团长", "蒲公英骑士", "蒙德砍王", "骑士团的魂"],
10000005: ["", "aether", "男主", "男主角", "龙哥", "空哥", "王子"], 10000005: ["", "aether", "男主", "男主角", "龙哥", "空哥", "王子"],
10000006: ["丽莎", "lisa", "图书管理员", "图书馆管理员", "蔷薇魔女"], 10000006: ["丽莎", "lisa", "图书管理员", "图书馆管理员", "蔷薇魔女"],
10000007: ["", "lumine", "女主", "女主角", "", "", "黄毛阿姨", "荧妹", "公主殿下"], 10000007: ["", "lumine", "女主", "女主角", "", "", "黄毛阿姨", "荧妹", "公主殿下"],
10000014: ["芭芭拉", "barbara", "巴巴拉", "拉粑粑", "拉巴巴", "内鬼", "加湿器", "闪耀偶像", "偶像", "蒙德辣王"], 10000014: ["芭芭拉", "barbara", "巴巴拉", "拉粑粑", "拉巴巴", "内鬼", "加湿器", "闪耀偶像", "偶像", "蒙德辣王"],
10000015: ["凯亚", "kaeya", "盖亚", "凯子哥", "凯鸭", "矿工", "矿工头子", "骑兵队长", "凯子", "凝冰渡海真君", "花脸猫"], 10000015: [
"凯亚",
"kaeya",
"盖亚",
"凯子哥",
"凯鸭",
"矿工",
"矿工头子",
"骑兵队长",
"凯子",
"凝冰渡海真君",
"花脸猫",
],
10000016: [ 10000016: [
"迪卢克", "迪卢克",
"diluc", "diluc",
@ -202,8 +226,33 @@ roles = {
"废人养成器", "废人养成器",
"听书人", "听书人",
], ],
10000031: ["菲谢尔", "fischl", "皇女", "小艾米", "小艾咪", "奥兹", "断罪皇女", "中二病", "中二少女", "中二皇女", "奥兹发射器"], 10000031: [
10000032: ["班尼特", "bennett", "点赞哥", "点赞", "倒霉少年", "倒霉蛋", "霹雳闪雷真君", "班神", "班爷", "倒霉", "火神", "六星真神"], "菲谢尔",
"fischl",
"皇女",
"小艾米",
"小艾咪",
"奥兹",
"断罪皇女",
"中二病",
"中二少女",
"中二皇女",
"奥兹发射器",
],
10000032: [
"班尼特",
"bennett",
"点赞哥",
"点赞",
"倒霉少年",
"倒霉蛋",
"霹雳闪雷真君",
"班神",
"班爷",
"倒霉",
"火神",
"六星真神",
],
10000033: [ 10000033: [
"达达利亚", "达达利亚",
"tartaglia", "tartaglia",
@ -226,7 +275,19 @@ roles = {
"大貉妖处理专家", "大貉妖处理专家",
], ],
10000034: ["诺艾尔", "noelle", "女仆", "高达", "岩王帝姬", "山吹", "冰萤术士", "岩王帝姬"], 10000034: ["诺艾尔", "noelle", "女仆", "高达", "岩王帝姬", "山吹", "冰萤术士", "岩王帝姬"],
10000035: ["七七", "qiqi", "僵尸", "肚饿真君", "度厄真君", "77", "起死回骸童子", "救苦度厄真君", "椰羊创始人", "不卜庐砍王", "不卜庐剑圣"], 10000035: [
"七七",
"qiqi",
"僵尸",
"肚饿真君",
"度厄真君",
"77",
"起死回骸童子",
"救苦度厄真君",
"椰羊创始人",
"不卜庐砍王",
"不卜庐剑圣",
],
10000036: ["重云", "chongyun", "纯阳之体", "冰棍", "驱邪世家", "大外甥"], 10000036: ["重云", "chongyun", "纯阳之体", "冰棍", "驱邪世家", "大外甥"],
10000037: ["甘雨", "ganyu", "椰羊", "椰奶", "鸡腿猎人", "咕噜咕噜滚下山真君", "肝雨", "走路上山真君"], 10000037: ["甘雨", "ganyu", "椰羊", "椰奶", "鸡腿猎人", "咕噜咕噜滚下山真君", "肝雨", "走路上山真君"],
10000038: [ 10000038: [
@ -406,7 +467,18 @@ roles = {
"海天后", "海天后",
"深海舌鲆鱼小姐", "深海舌鲆鱼小姐",
], ],
10000055: ["五郎", "gorou", "柴犬", "土狗", "希娜", "希娜小姐", "海祇岛的小狗大将", "修勾", "五郎大将的朋友", "小狗勾"], 10000055: [
"五郎",
"gorou",
"柴犬",
"土狗",
"希娜",
"希娜小姐",
"海祇岛的小狗大将",
"修勾",
"五郎大将的朋友",
"小狗勾",
],
10000056: [ 10000056: [
"九条裟罗", "九条裟罗",
"sara", "sara",
@ -486,7 +558,18 @@ roles = {
"名侦探柯南", "名侦探柯南",
"捕快展昭", "捕快展昭",
], ],
10000060: ["夜兰", "yelan", "夜阑", "叶澜", "腋兰", "夜天后", "自称就职于总务司的神秘人士", "岩上茶室老板", "夜上海", "胸怀大痣"], 10000060: [
"夜兰",
"yelan",
"夜阑",
"叶澜",
"腋兰",
"夜天后",
"自称就职于总务司的神秘人士",
"岩上茶室老板",
"夜上海",
"胸怀大痣",
],
10000061: ["绮良良", "kirara", "稻妻猫猫", "猫猫快递"], 10000061: ["绮良良", "kirara", "稻妻猫猫", "猫猫快递"],
10000062: ["埃洛伊", "aloy", "异界的救世主"], 10000062: ["埃洛伊", "aloy", "异界的救世主"],
10000063: ["申鹤", "shenhe", "神鹤", "小姨", "阿鹤", "小姨子", "审鹤", "仙家弟子", "驱邪世家旁", "药材杀手"], 10000063: ["申鹤", "shenhe", "神鹤", "小姨", "阿鹤", "小姨子", "审鹤", "仙家弟子", "驱邪世家旁", "药材杀手"],
@ -546,7 +629,17 @@ roles = {
"安柏的挚友", "安柏的挚友",
"兰那罗奶奶", "兰那罗奶奶",
], ],
10000068: ["多莉", "dori", "多利", "多力", "多丽", "奸商", "须弥百货商人", "桑歌玛哈巴依老爷", "艾尔卡萨扎莱宫之主"], 10000068: [
"多莉",
"dori",
"多利",
"多力",
"多丽",
"奸商",
"须弥百货商人",
"桑歌玛哈巴依老爷",
"艾尔卡萨扎莱宫之主",
],
10000069: [ 10000069: [
"提纳里", "提纳里",
"tighnari", "tighnari",
@ -564,7 +657,20 @@ roles = {
"柯莱的师父", "柯莱的师父",
], ],
10000070: ["妮露", "nilou", "尼露", "祖拜尔剧场之星", "红牛"], 10000070: ["妮露", "nilou", "尼露", "祖拜尔剧场之星", "红牛"],
10000071: ["赛诺", "cyno", "赛洛", "大风纪官", "大风机关", "胡狼头大人", "夹击妹抖", "游戏王", "冷笑话爱好者", "牌佬", "沙漠死神", "胡狼"], 10000071: [
"赛诺",
"cyno",
"赛洛",
"大风纪官",
"大风机关",
"胡狼头大人",
"夹击妹抖",
"游戏王",
"冷笑话爱好者",
"牌佬",
"沙漠死神",
"胡狼",
],
10000072: ["坎蒂丝", "candace", "坎迪斯", "水北斗", "赤王后裔", "阿如村守护者"], 10000072: ["坎蒂丝", "candace", "坎迪斯", "水北斗", "赤王后裔", "阿如村守护者"],
10000073: [ 10000073: [
"纳西妲", "纳西妲",
@ -607,9 +713,37 @@ roles = {
"伪神", "伪神",
"阿帽", "阿帽",
], ],
10000076: ["珐露珊", "faruzan", "法露珊", "珐妹", "初音", "初音未来", "miku", "发露姗", "发姐", "法姐", "百岁珊", "百岁山", "童姥", "知论派名宿"], 10000076: [
"珐露珊",
"faruzan",
"法露珊",
"珐妹",
"初音",
"初音未来",
"miku",
"发露姗",
"发姐",
"法姐",
"百岁珊",
"百岁山",
"童姥",
"知论派名宿",
],
10000077: ["瑶瑶", "yaoyao", "遥遥", "遥遥无期", "香菱师妹", "萝卜", "四星草奶"], 10000077: ["瑶瑶", "yaoyao", "遥遥", "遥遥无期", "香菱师妹", "萝卜", "四星草奶"],
10000078: ["艾尔海森", "alhaitham", "爱尔海森", "艾尔海参", "艾尔", "海森", "海参", "海神", "埃尔海森", "草刻晴", "书记官", "代理大贤者"], 10000078: [
"艾尔海森",
"alhaitham",
"爱尔海森",
"艾尔海参",
"艾尔",
"海森",
"海参",
"海神",
"埃尔海森",
"草刻晴",
"书记官",
"代理大贤者",
],
10000079: ["迪希雅", "dehya", "狮女", "狮子", "腕豪", "女拳"], 10000079: ["迪希雅", "dehya", "狮女", "狮子", "腕豪", "女拳"],
10000080: ["米卡", "mika", "镜音连", "咪卡", "小米"], 10000080: ["米卡", "mika", "镜音连", "咪卡", "小米"],
10000081: ["卡维", "kaveh", "夺少"], 10000081: ["卡维", "kaveh", "夺少"],
@ -620,7 +754,18 @@ roles = {
10000086: ["莱欧斯利", "wriothesley", "典狱长", "大狼狗", "莱欧斯利公爵", "公爵", "公爵大人"], 10000086: ["莱欧斯利", "wriothesley", "典狱长", "大狼狗", "莱欧斯利公爵", "公爵", "公爵大人"],
10000087: ["那维莱特", "neuvillette", "水龙", "龙王", "水龙王", "那维", "大审判官"], 10000087: ["那维莱特", "neuvillette", "水龙", "龙王", "水龙王", "那维", "大审判官"],
10000088: ["夏洛蒂", "charlotte", "记者", "枫丹记者", "射命丸文", "大新闻", "弄个大新闻"], 10000088: ["夏洛蒂", "charlotte", "记者", "枫丹记者", "射命丸文", "大新闻", "弄个大新闻"],
10000089: ["芙宁娜", "furina", "芙宁娜·德·枫丹", "芙芙", "水神", "芙宁娜大人", "芙宁娜女士", "众水的颂诗", "不休独舞", "众水、众方、众民与众律法的女王"], 10000089: [
"芙宁娜",
"furina",
"芙宁娜·德·枫丹",
"芙芙",
"水神",
"芙宁娜大人",
"芙宁娜女士",
"众水的颂诗",
"不休独舞",
"众水、众方、众民与众律法的女王",
],
10000090: ["夏沃蕾", "chevreuse"], 10000090: ["夏沃蕾", "chevreuse"],
10000091: ["娜维娅", "navia", "黄豆姐"], 10000091: ["娜维娅", "navia", "黄豆姐"],
10000092: ["嘉明", "gaming"], 10000092: ["嘉明", "gaming"],

View File

@ -40,7 +40,9 @@ class Calendar:
762, # 《原神》公平运营声明 762, # 《原神》公平运营声明
762, # 《原神》公平运营声明 762, # 《原神》公平运营声明
] ]
IGNORE_RE = re.compile(r"(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时|周边上新|角色演示)") IGNORE_RE = re.compile(
r"(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时|周边上新|角色演示)"
)
FULL_TIME_RE = re.compile(r"(魔神任务)") FULL_TIME_RE = re.compile(r"(魔神任务)")
def __init__(self): def __init__(self):
@ -86,7 +88,9 @@ class Calendar:
continue continue
content = re.sub(r'(<|&lt;)[\w "%:;=\-\\/\\(\\),\\.]+(>|&gt;)', "", content) content = re.sub(r'(<|&lt;)[\w "%:;=\-\\/\\(\\),\\.]+(>|&gt;)', "", content)
try: 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]): if time_ret := re.search(r"(?:活动时间)?(?:〓|\s)*([0-9\\/\\: ~]{6,})", reg_ret[1]):
start_time, end_time = time_ret[1].split("~") start_time, end_time = time_ret[1].split("~")
start_time = start_time.replace("/", "-").strip() start_time = start_time.replace("/", "-").strip()

View File

@ -177,9 +177,13 @@ class GachaLog:
four_star = len([i for i in data if i.rank_type == "4"]) four_star = len([i for i in data if i.rank_type == "4"])
if total > 50: if total > 50:
if total <= five_star * 15: if total <= five_star * 15:
raise GachaLogFileError("检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。") raise GachaLogFileError(
"检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。"
)
if four_star < five_star: if four_star < five_star:
raise GachaLogFileError("检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。") raise GachaLogFileError(
"检测到您将要导入的抽卡记录中五星数量过多,可能是由于文件错误导致的,请检查后重新导入。"
)
return True return True
except Exception as exc: # pylint: disable=W0703 except Exception as exc: # pylint: disable=W0703
raise GachaLogFileError from exc raise GachaLogFileError from exc

View File

@ -89,7 +89,9 @@ class BannerSystem:
gacha_info: PlayerGachaBannerInfo, gacha_info: PlayerGachaBannerInfo,
) -> int: ) -> 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_epitomized = gacha_info.failed_chosen_item_pulls >= banner.wish_max_progress # 判断定轨值
pity_featured = gacha_info.get_failed_featured_item_pulls(rarity) >= 1 # 通过UP值判断当前是否为UP 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 roll_featured = self.random_range(1, 100) <= banner.get_event_chance(rarity) # 随机判断当前是否为UP

View File

@ -111,10 +111,14 @@ class BindAccountPlugin(Plugin.Conversation):
await message.reply_text("退出任务", reply_markup=ReplyKeyboardRemove()) await message.reply_text("退出任务", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
if message.text == "通过玩家ID": 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 return CHECK_PLAYER_ID
if message.text == "通过账号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 return CHECK_ACCOUNT_ID
await message.reply_text("选择错误,请重新选择") await message.reply_text("选择错误,请重新选择")
return CHECK_METHOD return CHECK_METHOD
@ -140,7 +144,9 @@ class BindAccountPlugin(Plugin.Conversation):
await message.reply_text("用户查询次数过多,请稍后重试", reply_markup=ReplyKeyboardRemove()) await message.reply_text("用户查询次数过多,请稍后重试", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
except CookiesCachePoolExhausted: except CookiesCachePoolExhausted:
await message.reply_text("公共Cookies池已经耗尽请稍后重试或者绑定 cookie", reply_markup=ReplyKeyboardRemove()) await message.reply_text(
"公共Cookies池已经耗尽请稍后重试或者绑定 cookie", reply_markup=ReplyKeyboardRemove()
)
return ConversationHandler.END return ConversationHandler.END
if region == RegionEnum.HYPERION: if region == RegionEnum.HYPERION:
client = GenshinClient(cookies=cookies.data, region=Region.CHINESE) client = GenshinClient(cookies=cookies.data, region=Region.CHINESE)
@ -174,7 +180,9 @@ class BindAccountPlugin(Plugin.Conversation):
bind_account_plugin_data.account_id = account_id bind_account_plugin_data.account_id = account_id
reply_keyboard = [["确认", "退出"]] reply_keyboard = [["确认", "退出"]]
await message.reply_text("获取角色基础信息成功,请检查是否正确!") 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 = ( text = (
f"*角色信息*\n" f"*角色信息*\n"
f"角色名称:{escape_markdown(record_card.nickname, version=2)}\n" f"角色名称:{escape_markdown(record_card.nickname, version=2)}\n"
@ -238,7 +246,9 @@ class BindAccountPlugin(Plugin.Conversation):
return ConversationHandler.END return ConversationHandler.END
reply_keyboard = [["确认", "退出"]] reply_keyboard = [["确认", "退出"]]
await message.reply_text("获取角色基础信息成功,请检查是否正确!") 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 = ( text = (
f"*角色信息*\n" f"*角色信息*\n"
f"角色名称:{escape_markdown(player_stats.info.nickname, version=2)}\n" f"角色名称:{escape_markdown(player_stats.info.nickname, version=2)}\n"

View File

@ -236,7 +236,9 @@ class AccountCookiesPlugin(Plugin.Conversation):
logger.success("用户 %s[%s] 绑定时获取 stoken 成功", user.full_name, user.id) logger.success("用户 %s[%s] 绑定时获取 stoken 成功", user.full_name, user.id)
check_cookie = True check_cookie = True
except SimnetBadRequest as exc: 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: except Exception as exc:
logger.error("绑定时获取新Cookie失败 [%s]", (str(exc))) logger.error("绑定时获取新Cookie失败 [%s]", (str(exc)))
finally: finally:
@ -245,10 +247,14 @@ class AccountCookiesPlugin(Plugin.Conversation):
if not check_cookie: if not check_cookie:
await message.reply_text("检测到Cookie不完整可能会出现问题。", reply_markup=ReplyKeyboardRemove()) await message.reply_text("检测到Cookie不完整可能会出现问题。", reply_markup=ReplyKeyboardRemove())
if not cookies.stoken: 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 return ConversationHandler.END
if cookies.stoken and cookies.stoken.startswith("v2") and cookies.mid is None: 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 return ConversationHandler.END
try: try:
if region == Region.CHINESE: if region == Region.CHINESE:
@ -266,9 +272,13 @@ class AccountCookiesPlugin(Plugin.Conversation):
cookies.mid = cookies_model.mid cookies.mid = cookies_model.mid
cookies.ltoken = cookies_model.ltoken cookies.ltoken = cookies_model.ltoken
cookies.cookie_token = cookies_model.cookie_token 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: 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()) await message.reply_text("Stoken 无效,请重新绑定。", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
except UnicodeEncodeError: except UnicodeEncodeError:
@ -300,13 +310,17 @@ class AccountCookiesPlugin(Plugin.Conversation):
except InvalidCookies: except InvalidCookies:
logger.info("用户 %s[%s] Cookies已经过期", user.full_name, user.id) logger.info("用户 %s[%s] Cookies已经过期", user.full_name, user.id)
await message.reply_text( await message.reply_text(
"获取账号信息失败返回Cookies已经过期请尝试在无痕浏览器中登录获取Cookies。", reply_markup=ReplyKeyboardRemove() "获取账号信息失败返回Cookies已经过期请尝试在无痕浏览器中登录获取Cookies。",
reply_markup=ReplyKeyboardRemove(),
) )
return ConversationHandler.END return ConversationHandler.END
except SimnetBadRequest as exc: 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( await message.reply_text(
f"获取账号信息发生错误,错误信息为 {exc.original}请检查Cookie或者账号是否正常", reply_markup=ReplyKeyboardRemove() f"获取账号信息发生错误,错误信息为 {exc.original}请检查Cookie或者账号是否正常",
reply_markup=ReplyKeyboardRemove(),
) )
return ConversationHandler.END return ConversationHandler.END
except AccountIdNotFound: except AccountIdNotFound:
@ -344,7 +358,11 @@ class AccountCookiesPlugin(Plugin.Conversation):
reply_keyboard = [["确认", "退出"]] reply_keyboard = [["确认", "退出"]]
await message.reply_text("获取角色基础信息成功,请检查是否正确!") await message.reply_text("获取角色基础信息成功,请检查是否正确!")
logger.info( 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 = ( text = (
f"*角色信息*\n" f"*角色信息*\n"

View File

@ -41,7 +41,9 @@ class PlayersManagesPlugin(Plugin):
_handle = _data[-3] _handle = _data[-3]
_user_id = int(_data[-2]) _user_id = int(_data[-2])
_player_id = int(_data[-1]) _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 return _handle, _user_id, _player_id
@handler.command(command="player", filters=filters.ChatType.PRIVATE, block=False) @handler.command(command="player", filters=filters.ChatType.PRIVATE, block=False)
@ -71,7 +73,9 @@ class PlayersManagesPlugin(Plugin):
] ]
) )
if callback_query: if callback_query:
await callback_query.edit_message_text("从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons)) await callback_query.edit_message_text(
"从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons)
)
else: else:
await message.reply_text("从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons)) await message.reply_text("从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons))
@ -136,7 +140,8 @@ class PlayersManagesPlugin(Plugin):
buttons.insert(-1, temp_buttons) buttons.insert(-1, temp_buttons)
await callback_query.edit_message_text( 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) @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) cookies_data = await self.cookies_service.get(player.user_id, player.account_id, player.region)
if cookies_data is None: if cookies_data is None:
await callback_query.edit_message_text( 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) cookies = CookiesModel(**cookies_data.data)
@ -233,11 +239,13 @@ class PlayersManagesPlugin(Plugin):
cookies_data.status = CookiesStatusEnum.STATUS_SUCCESS cookies_data.status = CookiesStatusEnum.STATUS_SUCCESS
await self.cookies_service.update(cookies_data) await self.cookies_service.update(cookies_data)
await callback_query.edit_message_text( 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: else:
await callback_query.edit_message_text( 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) @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) cookies_data = await self.cookies_service.get(player.user_id, player.account_id, player.region)
if cookies_data is None: if cookies_data is None:
await callback_query.edit_message_text( 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 return
device = await self.devices_service.get(player.account_id) device = await self.devices_service.get(player.account_id)
@ -292,7 +301,8 @@ class PlayersManagesPlugin(Plugin):
f"<pre>{html.escape(cookie_str)}</pre>", f"<pre>{html.escape(cookie_str)}</pre>",
) )
await message.reply_text( 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() 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: else:
if callback_query.message: if callback_query.message:
await callback_query.message.delete() await callback_query.message.delete()

View File

@ -89,7 +89,11 @@ class GroupManage(Plugin):
message = update.effective_message message = update.effective_message
chat_id = self.get_chat_id(context) if not callback_query else int(callback_query.data.split("|")[2]) chat_id = self.get_chat_id(context) if not callback_query else int(callback_query.data.split("|")[2])
logger.info( 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: if not chat_id:
await message.reply_text("参数错误,请指定群 id ") await message.reply_text("参数错误,请指定群 id ")
@ -126,7 +130,11 @@ class GroupManage(Plugin):
message = update.effective_message message = update.effective_message
chat_id = self.get_chat_id(context) if not callback_query else int(callback_query.data.split("|")[2]) chat_id = self.get_chat_id(context) if not callback_query else int(callback_query.data.split("|")[2])
logger.info( 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: if not chat_id:
await message.reply_text("参数错误,请指定群 id ") await message.reply_text("参数错误,请指定群 id ")

View File

@ -380,7 +380,10 @@ class Post(Plugin.Conversation):
post_handler_data: PostHandlerData = context.chat_data.get("post_handler_data") post_handler_data: PostHandlerData = context.chat_data.get("post_handler_data")
photo_len = len(post_handler_data.post_images) photo_len = len(post_handler_data.post_images)
message = update.effective_message message = update.effective_message
await message.reply_text("请回复你要删除的图片的序列从1开始如果删除多张图片回复的序列请以空格作为分隔符" f"当前一共有 {photo_len} 张图片") await message.reply_text(
"请回复你要删除的图片的序列从1开始如果删除多张图片回复的序列请以空格作为分隔符"
f"当前一共有 {photo_len} 张图片"
)
return GTE_DELETE_PHOTO return GTE_DELETE_PHOTO
@conversation.state(state=GTE_DELETE_PHOTO) @conversation.state(state=GTE_DELETE_PHOTO)
@ -445,7 +448,9 @@ class Post(Plugin.Conversation):
@staticmethod @staticmethod
async def add_tags(update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> int: async def add_tags(update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> int:
message = update.effective_message message = update.effective_message
await message.reply_text("请回复添加的tag名称如果要添加多个tag请以空格作为分隔符不用添加 # 作为开头,推送时程序会自动添加") await message.reply_text(
"请回复添加的tag名称如果要添加多个tag请以空格作为分隔符不用添加 # 作为开头,推送时程序会自动添加"
)
return GET_TAGS return GET_TAGS
@conversation.state(state=GET_TAGS) @conversation.state(state=GET_TAGS)

View File

@ -220,7 +220,9 @@ class PostCode(Plugin.Conversation):
return await self.get_channel(update, context) return await self.get_channel(update, context)
if message.text == "推送并且定时更新": if message.text == "推送并且定时更新":
if not post_code_handler_data.real_need_update(): 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) return await self.get_channel(update, context)
post_code_handler_data.need_update = True post_code_handler_data.need_update = True
await message.reply_text(post_code_handler_data.get_need_update_text()) await message.reply_text(post_code_handler_data.get_need_update_text())

View File

@ -104,7 +104,9 @@ class SetQuizPlugin(Plugin.Conversation):
return ConversationHandler.END return ConversationHandler.END
except ResponseError as exc: except ResponseError as exc:
logger.error("重载问题失败", exc_info=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 return ConversationHandler.END
await update.message.reply_text("重载成功", reply_markup=ReplyKeyboardRemove()) await update.message.reply_text("重载成功", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
@ -116,7 +118,9 @@ class SetQuizPlugin(Plugin.Conversation):
quiz_command_data.new_question = "" quiz_command_data.new_question = ""
quiz_command_data.new_correct_answer = "" quiz_command_data.new_correct_answer = ""
quiz_command_data.status = 1 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 return GET_NEW_QUESTION
@conversation.state(state=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) await update.message.reply_markdown_v2(reply_text)
reply_keyboard = [["保存并重载配置", "抛弃修改并退出"]] 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 return SAVE_QUESTION
@conversation.state(state=SAVE_QUESTION) @conversation.state(state=SAVE_QUESTION)
@ -216,7 +222,9 @@ class SetQuizPlugin(Plugin.Conversation):
await self.quiz_service.refresh_quiz() await self.quiz_service.refresh_quiz()
except ResponseError as exc: except ResponseError as exc:
logger.error("重载问题失败", exc_info=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 return ConversationHandler.END
await update.message.reply_text("重载配置成功", reply_markup=ReplyKeyboardRemove()) await update.message.reply_text("重载配置成功", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END

View File

@ -88,7 +88,9 @@ class SetCommandPlugin(Plugin):
BotCommand("add_block", "添加黑名单"), BotCommand("add_block", "添加黑名单"),
BotCommand("del_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()) await context.bot.set_my_commands(commands=user_command + group_command, scope=BotCommandScopeAllPrivateChats())
if config.error.notification_chat_id: if config.error.notification_chat_id:
await context.bot.set_my_commands( await context.bot.set_my_commands(

View File

@ -153,7 +153,9 @@ class Inline(Plugin):
title=f"当前查询内容为 {args[0]}", title=f"当前查询内容为 {args[0]}",
description="如果无查看图片描述 这是正常的 客户端问题", description="如果无查看图片描述 这是正常的 客户端问题",
thumbnail_url="https://www.miyoushe.com/_nuxt/img/game-ys.dfc535b.jpg", 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: for simple_search_result in simple_search_results:

View File

@ -26,7 +26,9 @@ CHANNEL_ALIAS_OPEN = """成功开启频道透视模式,派蒙将会把你当
- 在转让频道前请务必关闭此功能 - 在转让频道前请务必关闭此功能
""" """
CHANNEL_ALIAS_CLOSE = """成功关闭频道透视模式,派蒙将不会把你当做普通用户,现在你无法使用频道身份执行命令""" CHANNEL_ALIAS_CLOSE = """成功关闭频道透视模式,派蒙将不会把你当做普通用户,现在你无法使用频道身份执行命令"""
CHANNEL_ADMIN_HELP = "参数错误,可用命令:\n\n- disable <id> 关闭频道透视模式\n- change <cid> <uid> 强制设置频道透视对应的用户 id" CHANNEL_ADMIN_HELP = (
"参数错误,可用命令:\n\n- disable <id> 关闭频道透视模式\n- change <cid> <uid> 强制设置频道透视对应的用户 id"
)
class ChannelAliasError(Exception): class ChannelAliasError(Exception):

View File

@ -1,4 +1,5 @@
"""深渊数据查询""" """深渊数据查询"""
import asyncio import asyncio
import re import re
from datetime import datetime from datetime import datetime

View File

@ -112,7 +112,9 @@ class DailyNotePlugin(Plugin):
async with self.helper.genshin(user_id) as client: async with self.helper.genshin(user_id) as client:
render_result = await self._get_daily_note(client) render_result = await self._get_daily_note(client)
except DataNotPublic: except DataNotPublic:
reply_message = await message.reply_text("查询失败惹,可能是便签功能被禁用了?请尝试通过米游社或者 hoyolab 获取一次便签信息后重试。") reply_message = await message.reply_text(
"查询失败惹,可能是便签功能被禁用了?请尝试通过米游社或者 hoyolab 获取一次便签信息后重试。"
)
if filters.ChatType.GROUPS.filter(message): if filters.ChatType.GROUPS.filter(message):
self.add_delete_message_job(reply_message, delay=30) self.add_delete_message_job(reply_message, delay=30)
self.add_delete_message_job(message, delay=30) self.add_delete_message_job(message, delay=30)

View File

@ -55,7 +55,9 @@ class DailyNoteTasksPlugin(Plugin.Conversation):
return ConversationHandler.END return ConversationHandler.END
note_user = await self.note_system.get_single_task_user(user.id) note_user = await self.note_system.get_single_task_user(user.id)
url = f"{config.pass_challenge_user_web}/tasks1?command=tasks&bot_data={note_user.web_config}" url = f"{config.pass_challenge_user_web}/tasks1?command=tasks&bot_data={note_user.web_config}"
text = f'你好 {user.mention_markdown_v2()} {escape_markdown("!请点击下方按钮,开始设置,或者回复退出取消操作")}' text = (
f'你好 {user.mention_markdown_v2()} {escape_markdown("!请点击下方按钮,开始设置,或者回复退出取消操作")}'
)
await message.reply_markdown_v2( await message.reply_markdown_v2(
text, text,
reply_markup=ReplyKeyboardMarkup.from_button( reply_markup=ReplyKeyboardMarkup.from_button(

View File

@ -80,18 +80,22 @@ class GCSimPlugin(Plugin):
buttons[-1].append(button) buttons[-1].append(button)
buttons.append( buttons.append(
[ [
(
InlineKeyboardButton("上一页", callback_data=f"gcsim_page|{user_id}|{uid}|{page - 1}") InlineKeyboardButton("上一页", callback_data=f"gcsim_page|{user_id}|{uid}|{page - 1}")
if page > 1 if page > 1
else InlineKeyboardButton("更新配队", callback_data=f"gcsim_refresh|{user_id}|{uid}"), else InlineKeyboardButton("更新配队", callback_data=f"gcsim_refresh|{user_id}|{uid}")
),
InlineKeyboardButton( InlineKeyboardButton(
f"{page}/{int(len(fits) / self.scripts_per_page) + 1}", f"{page}/{int(len(fits) / self.scripts_per_page) + 1}",
callback_data=f"gcsim_unclickable|{user_id}|{uid}|unclickable", callback_data=f"gcsim_unclickable|{user_id}|{uid}|unclickable",
), ),
(
InlineKeyboardButton("下一页", callback_data=f"gcsim_page|{user_id}|{uid}|{page + 1}") InlineKeyboardButton("下一页", callback_data=f"gcsim_page|{user_id}|{uid}|{page + 1}")
if page < int(len(fits) / self.scripts_per_page) + 1 if page < int(len(fits) / self.scripts_per_page) + 1
else InlineKeyboardButton( else InlineKeyboardButton(
"更新配队", "更新配队",
callback_data=f"gcsim_refresh|{user_id}|{uid}", callback_data=f"gcsim_refresh|{user_id}|{uid}",
)
), ),
] ]
) )
@ -238,11 +242,15 @@ class GCSimPlugin(Plugin):
_, _, _, reason = callback_query.data.split("|") _, _, _, reason = callback_query.data.split("|")
await callback_query.answer( await callback_query.answer(
text="已经是第一页了!\n" text=(
"已经是第一页了!\n"
if reason == "first_page" if reason == "first_page"
else "已经是最后一页了!\n" else (
"已经是最后一页了!\n"
if reason == "last_page" if reason == "last_page"
else "这个按钮不可用\n" + config.notice.user_mismatch, else "这个按钮不可用\n" + config.notice.user_mismatch
)
),
show_alert=True, show_alert=True,
) )

View File

@ -114,7 +114,9 @@ class LedgerPlugin(Plugin):
async with self.helper.genshin(user_id) as client: async with self.helper.genshin(user_id) as client:
render_result = await self._start_get_ledger(client, month) render_result = await self._start_get_ledger(client, month)
except DataNotPublic: except DataNotPublic:
reply_message = await message.reply_text("查询失败惹,可能是旅行札记功能被禁用了?请先通过米游社或者 hoyolab 获取一次旅行札记后重试。") reply_message = await message.reply_text(
"查询失败惹,可能是旅行札记功能被禁用了?请先通过米游社或者 hoyolab 获取一次旅行札记后重试。"
)
if filters.ChatType.GROUPS.filter(message): if filters.ChatType.GROUPS.filter(message):
self.add_delete_message_job(reply_message, delay=30) self.add_delete_message_job(reply_message, delay=30)
self.add_delete_message_job(message, delay=30) self.add_delete_message_job(message, delay=30)

View File

@ -115,7 +115,9 @@ class Map(Plugin):
return f"派蒙一共找到了 {name}{count} 个位置点\n* 数据来源于米游社wiki" return f"派蒙一共找到了 {name}{count} 个位置点\n* 数据来源于米游社wiki"
@handler(CommandHandler, command="map", block=False) @handler(CommandHandler, command="map", block=False)
@handler(MessageHandler, filters=filters.Regex("^(?P<name>.*)(在哪里|在哪|哪里有|哪儿有|哪有|在哪儿)$"), block=False) @handler(
MessageHandler, filters=filters.Regex("^(?P<name>.*)(在哪里|在哪|哪里有|哪儿有|哪有|在哪儿)$"), block=False
)
@handler(MessageHandler, filters=filters.Regex("^(哪里有|哪儿有|哪有)(?P<name>.*)$"), block=False) @handler(MessageHandler, filters=filters.Regex("^(哪里有|哪儿有|哪有)(?P<name>.*)$"), block=False)
async def command_start(self, update: Update, context: CallbackContext): async def command_start(self, update: Update, context: CallbackContext):
user_id = await self.get_real_user_id(update) user_id = await self.get_real_user_id(update)

View File

@ -20,7 +20,13 @@ __all__ = ("MaterialPlugin",)
class MaterialPlugin(Plugin): class MaterialPlugin(Plugin):
"""角色培养素材查询""" """角色培养素材查询"""
KEYBOARD = [[InlineKeyboardButton(text="查看角色培养素材列表并查询", switch_inline_query_current_chat="查看角色培养素材列表并查询")]] KEYBOARD = [
[
InlineKeyboardButton(
text="查看角色培养素材列表并查询", switch_inline_query_current_chat="查看角色培养素材列表并查询"
)
]
]
def __init__( def __init__(
self, self,

View File

@ -146,9 +146,11 @@ class GCSimCharacterInfo(BaseModel):
f"{self.char} add stats " f"{self.char} add stats "
+ " ".join( + " ".join(
[ [
(
f"{stat.replace('_PERCENT', '%').lower()}={value:.4f}" f"{stat.replace('_PERCENT', '%').lower()}={value:.4f}"
if stat.endswith("_PERCENT") or stat in {"CR", "CD", "ER"} if stat.endswith("_PERCENT") or stat in {"CR", "CD", "ER"}
else f"{stat.lower()}={value:.2f}" else f"{stat.lower()}={value:.2f}"
)
for stat, value in iter(self.stats) for stat, value in iter(self.stats)
if value > 0 if value > 0
] ]
@ -185,9 +187,11 @@ class GCSimTarget(BaseModel):
f"amount={self.amount}" if self.amount is not None else "", f"amount={self.amount}" if self.amount is not None else "",
f"interval={','.join(str(i) for i in self.interval)}" if self.interval else "", f"interval={','.join(str(i) for i in self.interval)}" if self.interval else "",
f"particle_threshold={self.particle_threshold}" if self.particle_threshold is not None else "", f"particle_threshold={self.particle_threshold}" if self.particle_threshold is not None else "",
(
f"particle_drop_count={self.particle_drop_count}" f"particle_drop_count={self.particle_drop_count}"
if self.particle_drop_count is not None if self.particle_drop_count is not None
else "", else ""
),
" ".join([f"{k}={v}" for k, v in self.others.items()]), " ".join([f"{k}={v}" for k, v in self.others.items()]),
], ],
) )

View File

@ -144,7 +144,9 @@ class PayLogPlugin(Plugin.Conversation):
await message.reply_text("你还没有导入充值记录哦~") await message.reply_text("你还没有导入充值记录哦~")
return ConversationHandler.END return ConversationHandler.END
context.chat_data["uid"] = player_info.player_id context.chat_data["uid"] = player_info.player_id
await message.reply_text("你确定要删除充值记录吗?(此项操作无法恢复),如果确定请发送 ”确定“,发送其他内容取消") await message.reply_text(
"你确定要删除充值记录吗?(此项操作无法恢复),如果确定请发送 ”确定“,发送其他内容取消"
)
return CONFIRM_DELETE return CONFIRM_DELETE
@conversation.state(state=CONFIRM_DELETE) @conversation.state(state=CONFIRM_DELETE)
@ -203,7 +205,9 @@ class PayLogPlugin(Plugin.Conversation):
buttons = [ buttons = [
[InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "pay_log_import"))] [InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "pay_log_import"))]
] ]
await message.reply_text("派蒙没有找到你的充值记录,快来私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)) await message.reply_text(
"派蒙没有找到你的充值记录,快来私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)
)
except PayLogAccountNotFound: except PayLogAccountNotFound:
await message.reply_text("导出失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同") await message.reply_text("导出失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同")
except PlayerNotFoundError: except PlayerNotFoundError:
@ -231,7 +235,9 @@ class PayLogPlugin(Plugin.Conversation):
buttons = [ buttons = [
[InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "pay_log_import"))] [InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "pay_log_import"))]
] ]
await message.reply_text("派蒙没有找到你的充值记录,快来点击按钮私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)) await message.reply_text(
"派蒙没有找到你的充值记录,快来点击按钮私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)
)
@staticmethod @staticmethod
async def get_migrate_data( async def get_migrate_data(

View File

@ -230,7 +230,9 @@ class PlayerCards(Plugin):
if characters.name == character_name: if characters.name == character_name:
break break
else: else:
await message.reply_text(f"角色展柜中未找到 {character_name} ,请检查角色是否存在于角色展柜中,或者等待角色数据更新后重试") await message.reply_text(
f"角色展柜中未找到 {character_name} ,请检查角色是否存在于角色展柜中,或者等待角色数据更新后重试"
)
return return
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)
original_data: Optional[Dict] = None original_data: Optional[Dict] = None
@ -279,7 +281,10 @@ class PlayerCards(Plugin):
await callback_query.answer(text=data, show_alert=True) await callback_query.answer(text=data, show_alert=True)
return return
if data.characters is None or len(data.characters) == 0: if data.characters is None or len(data.characters) == 0:
await callback_query.answer("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试", show_alert=True) await callback_query.answer(
"请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试",
show_alert=True,
)
await message.delete() await message.delete()
return return
self.player_gcsim_scripts.remove_fits(uid) self.player_gcsim_scripts.remove_fits(uid)
@ -344,7 +349,10 @@ class PlayerCards(Plugin):
original_data = await self._load_history(uid) original_data = await self._load_history(uid)
enka_response = EnkaNetworkResponse.parse_obj(copy.deepcopy(original_data)) enka_response = EnkaNetworkResponse.parse_obj(copy.deepcopy(original_data))
if enka_response.characters is None or len(enka_response.characters) == 0: if enka_response.characters is None or len(enka_response.characters) == 0:
await callback_query.answer("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试", show_alert=True) await callback_query.answer(
"请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试",
show_alert=True,
)
await message.delete() await message.delete()
return return
if page: if page:
@ -357,7 +365,10 @@ class PlayerCards(Plugin):
break break
else: else:
await message.delete() await message.delete()
await callback_query.answer(f"角色展柜中未找到 {result} ,请检查角色是否存在于角色展柜中,或者等待角色数据更新后重试", show_alert=True) await callback_query.answer(
f"角色展柜中未找到 {result} ,请检查角色是否存在于角色展柜中,或者等待角色数据更新后重试",
show_alert=True,
)
return return
await callback_query.answer(text="正在渲染图片中 请稍等 请不要重复点击按钮", show_alert=False) await callback_query.answer(text="正在渲染图片中 请稍等 请不要重复点击按钮", show_alert=False)
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) await message.reply_chat_action(ChatAction.UPLOAD_PHOTO)

View File

@ -123,7 +123,9 @@ class Sign(Plugin):
not filters.ChatType.PRIVATE.filter(message), not filters.ChatType.PRIVATE.filter(message),
) )
reply_message = await message.reply_text( reply_message = await message.reply_text(
"签到失败,触发验证码风控,请尝试点击下方按钮重新签到", allow_sending_without_reply=True, reply_markup=button "签到失败,触发验证码风控,请尝试点击下方按钮重新签到",
allow_sending_without_reply=True,
reply_markup=button,
) )
if filters.ChatType.GROUPS.filter(reply_message): if filters.ChatType.GROUPS.filter(reply_message):
self.add_delete_message_job(reply_message) self.add_delete_message_job(reply_message)

View File

@ -13,7 +13,9 @@ from utils.log import logger
class StrategyPlugin(Plugin): class StrategyPlugin(Plugin):
"""角色攻略查询""" """角色攻略查询"""
KEYBOARD = [[InlineKeyboardButton(text="查看角色攻略列表并查询", switch_inline_query_current_chat="查看角色攻略列表并查询")]] KEYBOARD = [
[InlineKeyboardButton(text="查看角色攻略列表并查询", switch_inline_query_current_chat="查看角色攻略列表并查询")]
]
def __init__( def __init__(
self, self,
@ -31,7 +33,9 @@ class StrategyPlugin(Plugin):
if len(args) >= 1: if len(args) >= 1:
character_name = args[0] character_name = args[0]
else: else:
reply_message = await message.reply_text("请回复你要查询的攻略的角色名", reply_markup=InlineKeyboardMarkup(self.KEYBOARD)) reply_message = await message.reply_text(
"请回复你要查询的攻略的角色名", reply_markup=InlineKeyboardMarkup(self.KEYBOARD)
)
if filters.ChatType.GROUPS.filter(reply_message): if filters.ChatType.GROUPS.filter(reply_message):
self.add_delete_message_job(message) self.add_delete_message_job(message)
self.add_delete_message_job(reply_message) self.add_delete_message_job(reply_message)

View File

@ -17,7 +17,9 @@ from utils.log import logger
class WeaponPlugin(Plugin): class WeaponPlugin(Plugin):
"""武器查询""" """武器查询"""
KEYBOARD = [[InlineKeyboardButton(text="查看武器列表并查询", switch_inline_query_current_chat="查看武器列表并查询")]] KEYBOARD = [
[InlineKeyboardButton(text="查看武器列表并查询", switch_inline_query_current_chat="查看武器列表并查询")]
]
def __init__( def __init__(
self, self,
@ -39,7 +41,9 @@ class WeaponPlugin(Plugin):
if len(args) >= 1: if len(args) >= 1:
weapon_name = args[0] weapon_name = args[0]
else: else:
reply_message = await message.reply_text("请回复你要查询的武器", reply_markup=InlineKeyboardMarkup(self.KEYBOARD)) reply_message = await message.reply_text(
"请回复你要查询的武器", reply_markup=InlineKeyboardMarkup(self.KEYBOARD)
)
if filters.ChatType.GROUPS.filter(reply_message): if filters.ChatType.GROUPS.filter(reply_message):
self.add_delete_message_job(message) self.add_delete_message_job(message)
self.add_delete_message_job(reply_message) self.add_delete_message_job(reply_message)

View File

@ -214,7 +214,9 @@ class WishSimulatorPlugin(Plugin):
try: try:
gacha_base_info = await self.handle.gacha_base_info(gacha_name) gacha_base_info = await self.handle.gacha_base_info(gacha_name)
except GachaNotFound as exc: except GachaNotFound as exc:
await message.reply_text(f"没有找到名为 {exc.gacha_name} 的卡池,可能是卡池不存在或者卡池已经结束,请检查后重试。如果你想抽取默认卡池,请不要输入参数。") await message.reply_text(
f"没有找到名为 {exc.gacha_name} 的卡池,可能是卡池不存在或者卡池已经结束,请检查后重试。如果你想抽取默认卡池,请不要输入参数。"
)
return return
else: else:
try: try:

View File

@ -139,7 +139,9 @@ class WishLogPlugin(Plugin.Conversation):
elif document.file_name.endswith(".json"): elif document.file_name.endswith(".json"):
file_type = "json" file_type = "json"
else: else:
await message.reply_text("文件格式错误,请发送符合 UIGF 标准的抽卡记录文件或者 paimon.moe、非小酋导出的 xlsx 格式的抽卡记录文件") await message.reply_text(
"文件格式错误,请发送符合 UIGF 标准的抽卡记录文件或者 paimon.moe、非小酋导出的 xlsx 格式的抽卡记录文件"
)
return return
if document.file_size > 5 * 1024 * 1024: if document.file_size > 5 * 1024 * 1024:
await message.reply_text("文件过大,请发送小于 5 MB 的文件") await message.reply_text("文件过大,请发送小于 5 MB 的文件")
@ -234,7 +236,9 @@ class WishLogPlugin(Plugin.Conversation):
if message.text == "自动导入": if message.text == "自动导入":
authkey = await self.gen_authkey(user.id) authkey = await self.gen_authkey(user.id)
if not authkey: if not authkey:
await message.reply_text("自动生成 authkey 失败,请尝试通过其他方式导入。", reply_markup=ReplyKeyboardRemove()) await message.reply_text(
"自动生成 authkey 失败,请尝试通过其他方式导入。", reply_markup=ReplyKeyboardRemove()
)
return ConversationHandler.END return ConversationHandler.END
elif message.text == "退出": elif message.text == "退出":
await message.reply_text("取消导入抽卡记录", reply_markup=ReplyKeyboardRemove()) await message.reply_text("取消导入抽卡记录", reply_markup=ReplyKeyboardRemove())
@ -270,7 +274,9 @@ class WishLogPlugin(Plugin.Conversation):
if not status: if not status:
await message.reply_text("你还没有导入抽卡记录哦~") await message.reply_text("你还没有导入抽卡记录哦~")
return ConversationHandler.END return ConversationHandler.END
await message.reply_text("你确定要删除抽卡记录吗?(此项操作无法恢复),如果确定请发送 ”确定“,发送其他内容取消") await message.reply_text(
"你确定要删除抽卡记录吗?(此项操作无法恢复),如果确定请发送 ”确定“,发送其他内容取消"
)
return CONFIRM_DELETE return CONFIRM_DELETE
@conversation.state(state=CONFIRM_DELETE) @conversation.state(state=CONFIRM_DELETE)
@ -331,7 +337,9 @@ class WishLogPlugin(Plugin.Conversation):
buttons = [ buttons = [
[InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "gacha_log_import"))] [InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "gacha_log_import"))]
] ]
await message.reply_text("派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)) await message.reply_text(
"派蒙没有找到你的抽卡记录,快来私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)
)
except GachaLogAccountNotFound: except GachaLogAccountNotFound:
await message.reply_text("导入失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同") await message.reply_text("导入失败,可能文件包含的祈愿记录所属 uid 与你当前绑定的 uid 不同")
except GachaLogFileError: except GachaLogFileError:
@ -468,7 +476,9 @@ class WishLogPlugin(Plugin.Conversation):
buttons = [ buttons = [
[InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "gacha_log_import"))] [InlineKeyboardButton("点我导入", url=create_deep_linked_url(context.bot.username, "gacha_log_import"))]
] ]
await message.reply_text("派蒙没有找到你的抽卡记录,快来点击按钮私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)) await message.reply_text(
"派蒙没有找到你的抽卡记录,快来点击按钮私聊派蒙导入吧~", reply_markup=InlineKeyboardMarkup(buttons)
)
@handler.callback_query(pattern=r"^get_wish_log\|", block=False) @handler.callback_query(pattern=r"^get_wish_log\|", block=False)
async def get_wish_log(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None: async def get_wish_log(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:

View File

@ -90,7 +90,9 @@ class GroupCaptcha(Plugin):
chat_id=job.chat_id, user_id=job.user_id, until_date=int(time.time()) + self.kick_time chat_id=job.chat_id, user_id=job.user_id, until_date=int(time.time()) + self.kick_time
) )
except BadRequest as exc: except BadRequest as exc:
logger.error("GroupCaptcha插件在 chat_id[%s] user_id[%s] 执行kick失败", job.chat_id, job.user_id, exc_info=exc) logger.error(
"GroupCaptcha插件在 chat_id[%s] user_id[%s] 执行kick失败", job.chat_id, job.user_id, exc_info=exc
)
@staticmethod @staticmethod
async def clean_message_job(context: "ContextTypes.DEFAULT_TYPE"): async def clean_message_job(context: "ContextTypes.DEFAULT_TYPE"):
@ -100,11 +102,19 @@ class GroupCaptcha(Plugin):
await context.bot.delete_message(chat_id=job.chat_id, message_id=job.data) await context.bot.delete_message(chat_id=job.chat_id, message_id=job.data)
except BadRequest as exc: except BadRequest as exc:
if "not found" in exc.message: if "not found" in exc.message:
logger.warning("GroupCaptcha插件删除消息 chat_id[%s] message_id[%s]失败 消息不存在", job.chat_id, job.data) logger.warning(
"GroupCaptcha插件删除消息 chat_id[%s] message_id[%s]失败 消息不存在", job.chat_id, job.data
)
elif "Message can't be deleted" in exc.message: elif "Message can't be deleted" in exc.message:
logger.warning("GroupCaptcha插件删除消息 chat_id[%s] message_id[%s]失败 消息无法删除 可能是没有授权", job.chat_id, job.data) logger.warning(
"GroupCaptcha插件删除消息 chat_id[%s] message_id[%s]失败 消息无法删除 可能是没有授权",
job.chat_id,
job.data,
)
else: else:
logger.error("GroupCaptcha插件删除消息 chat_id[%s] message_id[%s]失败", job.chat_id, job.data, exc_info=exc) logger.error(
"GroupCaptcha插件删除消息 chat_id[%s] message_id[%s]失败", job.chat_id, job.data, exc_info=exc
)
@staticmethod @staticmethod
async def restore_member(context: "ContextTypes.DEFAULT_TYPE", chat_id: int, user_id: int): async def restore_member(context: "ContextTypes.DEFAULT_TYPE", chat_id: int, user_id: int):
@ -174,7 +184,9 @@ class GroupCaptcha(Plugin):
) )
else: else:
await message.edit_text(f"{member_info} 被本群管理员放行", parse_mode=ParseMode.MARKDOWN_V2) await message.edit_text(f"{member_info} 被本群管理员放行", parse_mode=ParseMode.MARKDOWN_V2)
logger.info("用户 %s 在群 %s[%s] 被 %s[%s] 管理放行", member_info, chat.title, chat.id, user.full_name, user.id) logger.info(
"用户 %s 在群 %s[%s] 被 %s[%s] 管理放行", member_info, chat.title, chat.id, user.full_name, user.id
)
elif result == "kick": elif result == "kick":
await callback_query.answer(text="驱离", show_alert=False) await callback_query.answer(text="驱离", show_alert=False)
await context.bot.ban_chat_member(chat.id, user_id) await context.bot.ban_chat_member(chat.id, user_id)
@ -193,7 +205,9 @@ class GroupCaptcha(Plugin):
) )
else: else:
await message.edit_text(f"{member_info} 被本群管理员驱离", parse_mode=ParseMode.MARKDOWN_V2) await message.edit_text(f"{member_info} 被本群管理员驱离", parse_mode=ParseMode.MARKDOWN_V2)
logger.info("用户 %s 在群 %s[%s] 被 %s[%s] 管理驱离", member_info, chat.title, chat.id, user.full_name, user.id) logger.info(
"用户 %s 在群 %s[%s] 被 %s[%s] 管理驱离", member_info, chat.title, chat.id, user.full_name, user.id
)
elif result == "unban": elif result == "unban":
await callback_query.answer(text="解除驱离", show_alert=False) await callback_query.answer(text="解除驱离", show_alert=False)
await self.restore_member(context, chat.id, user_id) await self.restore_member(context, chat.id, user_id)
@ -214,7 +228,9 @@ class GroupCaptcha(Plugin):
) )
else: else:
await message.edit_text(f"{member_info} 被本群管理员解除封禁", parse_mode=ParseMode.MARKDOWN_V2) await message.edit_text(f"{member_info} 被本群管理员解除封禁", parse_mode=ParseMode.MARKDOWN_V2)
logger.info("用户 %s 在群 %s[%s] 被 %s[%s] 管理驱离", member_info, chat.title, chat.id, user.full_name, user.id) logger.info(
"用户 %s 在群 %s[%s] 被 %s[%s] 管理驱离", member_info, chat.title, chat.id, user.full_name, user.id
)
else: else:
logger.warning("auth 模块 admin 函数 发现未知命令 result[%s]", result) logger.warning("auth 模块 admin 函数 发现未知命令 result[%s]", result)
await context.bot.send_message(chat.id, "派蒙这边收到了错误的消息!请检查详细日记!") await context.bot.send_message(chat.id, "派蒙这边收到了错误的消息!请检查详细日记!")
@ -252,7 +268,12 @@ class GroupCaptcha(Plugin):
await callback_query.answer(text="这不是你的验证!\n" + self.user_mismatch, show_alert=True) await callback_query.answer(text="这不是你的验证!\n" + self.user_mismatch, show_alert=True)
return return
logger.info( logger.info(
"用户 %s[%s] 在群 %s[%s] 认证结果为 %s", user.full_name, user.id, chat.title, chat.id, "通过" if result else "失败" "用户 %s[%s] 在群 %s[%s] 认证结果为 %s",
user.full_name,
user.id,
chat.title,
chat.id,
"通过" if result else "失败",
) )
if result: if result:
buttons = [[InlineKeyboardButton("驱离", callback_data=f"auth_admin|kick|{user.id}")]] buttons = [[InlineKeyboardButton("驱离", callback_data=f"auth_admin|kick|{user.id}")]]
@ -437,12 +458,18 @@ class GroupCaptcha(Plugin):
text = f"{user.full_name} 由于加入群组后,在验证缝隙间发送了带有 Forward 的消息,已被踢出群组,并加入了封禁列表。" text = f"{user.full_name} 由于加入群组后,在验证缝隙间发送了带有 Forward 的消息,已被踢出群组,并加入了封禁列表。"
if text is not None: if text is not None:
await context.bot.ban_chat_member(chat.id, user.id) await context.bot.ban_chat_member(chat.id, user.id)
button = [[InlineKeyboardButton("解除封禁", callback_data=f"auth_admin|pass|{user.id}")]] button = [
[InlineKeyboardButton("解除封禁", callback_data=f"auth_admin|pass|{user.id}")]
]
await question_message.edit_text(text, reply_markup=InlineKeyboardMarkup(button)) await question_message.edit_text(text, reply_markup=InlineKeyboardMarkup(button))
if schedule := context.job_queue.scheduler.get_job(f"{chat.id}|{user.id}|auth_kick"): if schedule := context.job_queue.scheduler.get_job(f"{chat.id}|{user.id}|auth_kick"):
schedule.remove() schedule.remove()
logger.info( logger.info(
"用户 %s[%s] 在群 %s[%s] 验证缝隙间发送消息 现已删除", user.full_name, user.id, chat.title, chat.id "用户 %s[%s] 在群 %s[%s] 验证缝隙间发送消息 现已删除",
user.full_name,
user.id,
chat.title,
chat.id,
) )
except BadRequest as exc: except BadRequest as exc:
logger.error("后验证处理中发生错误 %s", exc.message) logger.error("后验证处理中发生错误 %s", exc.message)

View File

@ -73,7 +73,9 @@ class RefreshCookiesJob(Plugin):
if "UPDATE" in str(_exc): if "UPDATE" in str(_exc):
logger.warning("用户 user_id[%s] 刷新 Cookies 失败,数据不存在", cookie_model.user_id) logger.warning("用户 user_id[%s] 刷新 Cookies 失败,数据不存在", cookie_model.user_id)
else: else:
logger.error("用户 user_id[%s] 更新 Cookies 时出现错误", cookie_model.user_id, exc_info=_exc) logger.error(
"用户 user_id[%s] 更新 Cookies 时出现错误", cookie_model.user_id, exc_info=_exc
)
except Exception as _exc: except Exception as _exc:
logger.error("用户 user_id[%s] 更新 Cookies 状态失败", cookie_model.user_id, exc_info=_exc) logger.error("用户 user_id[%s] 更新 Cookies 状态失败", cookie_model.user_id, exc_info=_exc)
else: else:

View File

@ -78,7 +78,9 @@ class ErrorHandler(Plugin):
buttons = InlineKeyboardMarkup( buttons = InlineKeyboardMarkup(
[ [
[ [
InlineKeyboardButton("点我重新绑定", url=create_deep_linked_url(context.bot.username, "set_cookie")), InlineKeyboardButton(
"点我重新绑定", url=create_deep_linked_url(context.bot.username, "set_cookie")
),
_import_button, _import_button,
], ],
] ]
@ -150,7 +152,10 @@ class ErrorHandler(Plugin):
if exc.retcode in (10001, -100): if exc.retcode in (10001, -100):
notice = self.ERROR_MSG_PREFIX + "Cookie 无效,请尝试重新绑定" notice = self.ERROR_MSG_PREFIX + "Cookie 无效,请尝试重新绑定"
elif exc.retcode == 10103: elif exc.retcode == 10103:
notice = self.ERROR_MSG_PREFIX + "Cookie 有效,但没有绑定到游戏帐户,请尝试登录通行证,在账号管理里面选择账号游戏信息,将原神设置为默认角色。" notice = (
self.ERROR_MSG_PREFIX
+ "Cookie 有效,但没有绑定到游戏帐户,请尝试登录通行证,在账号管理里面选择账号游戏信息,将原神设置为默认角色。"
)
else: else:
logger.error("未知Cookie错误", exc_info=exc) logger.error("未知Cookie错误", exc_info=exc)
notice = self.ERROR_MSG_PREFIX + f"Cookie 无效 错误信息为 {exc.original} 请尝试重新绑定" notice = self.ERROR_MSG_PREFIX + f"Cookie 无效 错误信息为 {exc.original} 请尝试重新绑定"
@ -231,9 +236,15 @@ class ErrorHandler(Plugin):
if isinstance(exc, APIHelperTimedOut): if isinstance(exc, APIHelperTimedOut):
notice = self.ERROR_MSG_PREFIX + " 服务器熟啦 ~ 请稍后再试" notice = self.ERROR_MSG_PREFIX + " 服务器熟啦 ~ 请稍后再试"
elif isinstance(exc, ReturnCodeError): elif isinstance(exc, ReturnCodeError):
notice = self.ERROR_MSG_PREFIX + f"API请求错误 错误信息为 {exc.message if exc.message else exc.code} ~ 请稍后再试" notice = (
self.ERROR_MSG_PREFIX
+ f"API请求错误 错误信息为 {exc.message if exc.message else exc.code} ~ 请稍后再试"
)
elif isinstance(exc, ResponseException): elif isinstance(exc, ResponseException):
notice = self.ERROR_MSG_PREFIX + f"API请求错误 错误信息为 {exc.message if exc.message else exc.code} ~ 请稍后再试" notice = (
self.ERROR_MSG_PREFIX
+ f"API请求错误 错误信息为 {exc.message if exc.message else exc.code} ~ 请稍后再试"
)
if notice: if notice:
self.create_notice_task(update, context, notice) self.create_notice_task(update, context, notice)
raise ApplicationHandlerStop raise ApplicationHandlerStop

View File

@ -135,7 +135,9 @@ class SignSystem(Plugin):
if not daily_reward_info.signed_in: if not daily_reward_info.signed_in:
try: try:
if validate: if validate:
logger.info("UID[%s] 正在尝试通过验证码\nchallenge[%s]\nvalidate[%s]", client.player_id, challenge, validate) logger.info(
"UID[%s] 正在尝试通过验证码\nchallenge[%s]\nvalidate[%s]", client.player_id, challenge, validate
)
request_daily_reward = await client.request_daily_reward( request_daily_reward = await client.request_daily_reward(
"sign", "sign",
method="POST", method="POST",
@ -191,7 +193,9 @@ class SignSystem(Plugin):
logger.info("UID[%s] 创建验证码\ngt[%s]\nchallenge[%s]", client.player_id, _gt, _challenge) logger.info("UID[%s] 创建验证码\ngt[%s]\nchallenge[%s]", client.player_id, _gt, _challenge)
_validate = await RecognizeSystem.recognize(_gt, _challenge, uid=client.player_id) _validate = await RecognizeSystem.recognize(_gt, _challenge, uid=client.player_id)
if _validate: if _validate:
logger.success("recognize 通过验证成功\nchallenge[%s]\nvalidate[%s]", _challenge, _validate) logger.success(
"recognize 通过验证成功\nchallenge[%s]\nvalidate[%s]", _challenge, _validate
)
request_daily_reward = await client.request_daily_reward( request_daily_reward = await client.request_daily_reward(
"sign", "sign",
method="POST", method="POST",
@ -219,7 +223,9 @@ class SignSystem(Plugin):
) )
gt = request_daily_reward.get("gt", "") gt = request_daily_reward.get("gt", "")
challenge = request_daily_reward.get("challenge", "") challenge = request_daily_reward.get("challenge", "")
logger.success("UID[%s] 创建验证成功\ngt[%s]\nchallenge[%s]", client.player_id, gt, challenge) logger.success(
"UID[%s] 创建验证成功\ngt[%s]\nchallenge[%s]", client.player_id, gt, challenge
)
raise NeedChallenge(uid=client.player_id, gt=gt, challenge=challenge) raise NeedChallenge(uid=client.player_id, gt=gt, challenge=challenge)
else: else:
request_daily_reward = await client.request_daily_reward( request_daily_reward = await client.request_daily_reward(

View File

@ -1,6 +1,7 @@
"""Test Url """Test Url
https://bbs.mihoyo.com/ys/article/29023709 https://bbs.mihoyo.com/ys/article/29023709
""" """
import logging import logging
import pytest import pytest

View File

@ -1,4 +1,5 @@
"""一些常量""" """一些常量"""
from functools import WRAPPER_ASSIGNMENTS as _WRAPPER_ASSIGNMENTS from functools import WRAPPER_ASSIGNMENTS as _WRAPPER_ASSIGNMENTS
from typing import List from typing import List

View File

@ -1,4 +1,5 @@
"""目录常量""" """目录常量"""
from pathlib import Path from pathlib import Path
__all__ = ["PROJECT_ROOT", "CORE_DIR", "PLUGIN_DIR", "RESOURCE_DIR", "CACHE_DIR", "METADATA_DIR", "DATA_DIR"] __all__ = ["PROJECT_ROOT", "CORE_DIR", "PLUGIN_DIR", "RESOURCE_DIR", "CACHE_DIR", "METADATA_DIR", "DATA_DIR"]

View File

@ -198,7 +198,8 @@ class Traceback(BaseTraceback):
filename=filename or "?", filename=filename or "?",
lineno=line_no, lineno=line_no,
name=frame_summary.f_code.co_name, name=frame_summary.f_code.co_name,
locals={ locals=(
{
key: pretty.traverse( key: pretty.traverse(
Traceback.filter_value(value), Traceback.filter_value(value),
max_length=locals_max_length, max_length=locals_max_length,
@ -208,7 +209,8 @@ class Traceback(BaseTraceback):
for key, value in frame_summary.f_locals.items() for key, value in frame_summary.f_locals.items()
} }
if show_locals if show_locals
else None, else None
),
) )
append(frame) append(frame)
if frame_summary.f_locals.get("_rich_traceback_guard", False): if frame_summary.f_locals.get("_rich_traceback_guard", False):