mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 07:07:46 +00:00
🎨 Improve code quality
This commit is contained in:
parent
c9d85e774a
commit
a06eb61b49
@ -1,7 +1,7 @@
|
||||
from typing import List, Optional
|
||||
|
||||
import genshin
|
||||
from genshin import Game, GenshinException, InvalidCookies, TooManyRequests, types
|
||||
from genshin import GenshinException, InvalidCookies, TooManyRequests, types
|
||||
|
||||
from core.base_service import BaseService
|
||||
from core.basemodel import RegionEnum
|
||||
|
@ -1,9 +1,9 @@
|
||||
import html
|
||||
from http.cookies import SimpleCookie
|
||||
from typing import Tuple
|
||||
from typing import Tuple, TYPE_CHECKING
|
||||
|
||||
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from telegram.ext import filters, ContextTypes
|
||||
from telegram import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from telegram.ext import filters
|
||||
|
||||
from core.basemodel import RegionEnum
|
||||
from core.plugin import Plugin, handler
|
||||
@ -14,6 +14,11 @@ from modules.apihelper.client.components.authclient import AuthClient
|
||||
from modules.apihelper.models.genshin.cookies import CookiesModel
|
||||
from utils.log import logger
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import Update
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
|
||||
__all__ = ("PlayersManagesPlugin",)
|
||||
|
||||
|
||||
@ -35,7 +40,7 @@ class PlayersManagesPlugin(Plugin):
|
||||
@handler.command(command="player", filters=filters.ChatType.PRIVATE, block=False)
|
||||
@handler.command(command="players", filters=filters.ChatType.PRIVATE, block=False)
|
||||
@handler.callback_query(r"^players_manager\|list", block=False)
|
||||
async def command_start(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
async def command_start(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:
|
||||
callback_query = update.callback_query
|
||||
user = update.effective_user
|
||||
message = update.effective_message
|
||||
@ -64,7 +69,7 @@ class PlayersManagesPlugin(Plugin):
|
||||
await message.reply_text("从下面的列表中选择一个玩家", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
|
||||
@handler.callback_query(r"^players_manager\|get\|", block=False)
|
||||
async def get_player(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
async def get_player(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:
|
||||
callback_query = update.callback_query
|
||||
user = callback_query.from_user
|
||||
|
||||
@ -131,7 +136,7 @@ class PlayersManagesPlugin(Plugin):
|
||||
)
|
||||
|
||||
@handler.callback_query(r"^players_manager\|update\|", block=False)
|
||||
async def update_user(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
async def update_user(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:
|
||||
callback_query = update.callback_query
|
||||
user = callback_query.from_user
|
||||
|
||||
@ -167,7 +172,7 @@ class PlayersManagesPlugin(Plugin):
|
||||
)
|
||||
|
||||
@handler.callback_query(r"^players_manager\|refresh_cookies\|", block=False)
|
||||
async def refresh_cookies(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
async def refresh_cookies(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:
|
||||
callback_query = update.callback_query
|
||||
user = callback_query.from_user
|
||||
|
||||
@ -230,7 +235,7 @@ class PlayersManagesPlugin(Plugin):
|
||||
)
|
||||
|
||||
@handler.callback_query(r"^players_manager\|export_cookies\|", block=False)
|
||||
async def export_cookies(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
async def export_cookies(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:
|
||||
callback_query = update.callback_query
|
||||
message = update.effective_message
|
||||
user = callback_query.from_user
|
||||
@ -281,7 +286,7 @@ class PlayersManagesPlugin(Plugin):
|
||||
await message.delete()
|
||||
|
||||
@handler.callback_query(r"^players_manager\|main\|", block=False)
|
||||
async def set_main(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
async def set_main(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:
|
||||
callback_query = update.callback_query
|
||||
user = callback_query.from_user
|
||||
|
||||
@ -323,7 +328,7 @@ class PlayersManagesPlugin(Plugin):
|
||||
)
|
||||
|
||||
@handler.callback_query(r"^players_manager\|del\|", block=False)
|
||||
async def delete(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
async def delete(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None:
|
||||
callback_query = update.callback_query
|
||||
user = callback_query.from_user
|
||||
|
||||
|
@ -143,7 +143,7 @@ class ErrorHandler(Plugin):
|
||||
# notice = self.ERROR_MSG_PREFIX + " 连接 telegram 服务器超时"
|
||||
logger.error("连接 telegram 服务器超时 [%s]", repr(context.error))
|
||||
raise ApplicationHandlerStop
|
||||
elif isinstance(context.error, BadRequest):
|
||||
if isinstance(context.error, BadRequest):
|
||||
if "Replied message not found" in context.error.message:
|
||||
notice = "气死我了!怎么有人喜欢发一个命令就秒删了!"
|
||||
elif "Message is not modified" in context.error.message:
|
||||
|
@ -1,6 +1,5 @@
|
||||
import asyncio
|
||||
import random
|
||||
import re
|
||||
from datetime import datetime, timedelta, time
|
||||
from typing import Optional, Tuple, Union, TYPE_CHECKING
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user