diff --git a/plugins/genshin/birthday.py b/plugins/genshin/birthday.py index fbf3bae..cf050af 100644 --- a/plugins/genshin/birthday.py +++ b/plugins/genshin/birthday.py @@ -9,7 +9,7 @@ from core.baseplugin import BasePlugin from core.plugin import Plugin, handler from metadata.genshin import AVATAR_DATA from metadata.shortname import roleToId, roleToName -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.log import logger @@ -45,7 +45,7 @@ class BirthdayPlugin(Plugin, BasePlugin): + "_" + rm_starting_str(datetime.now().strftime("%d"), "0") ) - args = get_all_args(context) + args = get_args(context) if len(args) >= 1: msg = args[0] logger.info(f"用户 {user.full_name}[{user.id}] 查询角色生日命令请求 || 参数 {msg}") diff --git a/plugins/genshin/daily/material.py b/plugins/genshin/daily/material.py index ef23d71..52c4244 100644 --- a/plugins/genshin/daily/material.py +++ b/plugins/genshin/daily/material.py @@ -32,7 +32,7 @@ from core.template import TemplateService from core.template.models import FileType, RenderGroupResult from core.user.error import UserNotFoundError from metadata.genshin import AVATAR_DATA, HONEY_DATA -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.admins import bot_admins_rights_check from utils.decorators.error import error_callable from utils.decorators.restricts import restricts @@ -211,7 +211,7 @@ class DailyMaterial(Plugin, BasePlugin): async def daily_material(self, update: Update, context: CallbackContext): user = update.effective_user message = update.effective_message - args = get_all_args(context) + args = get_args(context) now = datetime.now() try: diff --git a/plugins/genshin/gacha/gacha.py b/plugins/genshin/gacha/gacha.py index e8b191e..3d125be 100644 --- a/plugins/genshin/gacha/gacha.py +++ b/plugins/genshin/gacha/gacha.py @@ -20,7 +20,7 @@ from modules.apihelper.hyperion import GachaInfo, GachaInfoObject from modules.gacha.banner import BannerType, GachaBanner from modules.gacha.player.info import PlayerGachaInfo from modules.gacha.system import BannerSystem -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.log import logger @@ -169,7 +169,7 @@ class Gacha(Plugin, BasePlugin): async def command_start(self, update: Update, context: CallbackContext) -> None: message = update.effective_message user = update.effective_user - args = get_all_args(context) + args = get_args(context) gacha_name = "角色活动" if len(args) >= 1: gacha_name = args[0] @@ -245,7 +245,7 @@ class Gacha(Plugin, BasePlugin): async def set_wish(self, update: Update, context: CallbackContext) -> None: message = update.effective_message user = update.effective_user - args = get_all_args(context) + args = get_args(context) try: gacha_base_info = await self.handle.gacha_base_info("武器活动") except GachaNotFound: diff --git a/plugins/genshin/gacha/gacha_log.py b/plugins/genshin/gacha/gacha_log.py index 6f5abdb..9c02708 100644 --- a/plugins/genshin/gacha/gacha_log.py +++ b/plugins/genshin/gacha/gacha_log.py @@ -30,7 +30,7 @@ from modules.gacha_log.error import ( ) from modules.gacha_log.helpers import from_url_get_authkey from modules.gacha_log.log import GachaLog -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.admins import bot_admins_rights_check from utils.decorators.error import error_callable from utils.decorators.restricts import restricts @@ -150,7 +150,7 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation): async def command_start(self, update: Update, context: CallbackContext) -> int: message = update.effective_message user = update.effective_user - args = get_all_args(context) + args = get_args(context) logger.info(f"用户 {user.full_name}[{user.id}] 导入抽卡记录命令请求") authkey = from_url_get_authkey(args[0] if args else "") if not args: @@ -269,7 +269,7 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation): @bot_admins_rights_check async def command_gacha_log_force_delete(self, update: Update, context: CallbackContext): message = update.effective_message - args = get_all_args(context) + args = get_args(context) if not args: await message.reply_text("请指定用户ID") return @@ -335,7 +335,7 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation): message = update.effective_message user = update.effective_user pool_type = BannerType.CHARACTER1 - if args := get_all_args(context): + if args := get_args(context): if "武器" in args: pool_type = BannerType.WEAPON elif "常驻" in args: @@ -383,7 +383,7 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation): user = update.effective_user pool_type = BannerType.CHARACTER1 all_five = False - if args := get_all_args(context): + if args := get_args(context): if "武器" in args: pool_type = BannerType.WEAPON elif "常驻" in args: diff --git a/plugins/genshin/hilichurls.py b/plugins/genshin/hilichurls.py index c5c93d8..f7330b3 100644 --- a/plugins/genshin/hilichurls.py +++ b/plugins/genshin/hilichurls.py @@ -7,7 +7,7 @@ from telegram.ext import filters from core.baseplugin import BasePlugin from core.plugin import Plugin, handler -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.log import logger @@ -27,7 +27,7 @@ class HilichurlsPlugin(Plugin, BasePlugin): async def command_start(self, update: Update, context: CallbackContext) -> None: message = update.effective_message user = update.effective_user - args = get_all_args(context) + args = get_args(context) if len(args) >= 1: msg = args[0] else: diff --git a/plugins/genshin/ledger.py b/plugins/genshin/ledger.py index 6af80c4..d3b6567 100644 --- a/plugins/genshin/ledger.py +++ b/plugins/genshin/ledger.py @@ -15,7 +15,7 @@ from core.plugin import Plugin, handler from core.template.services import RenderResult, TemplateService from core.user.error import UserNotFoundError from core.user.services import UserService -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client @@ -30,7 +30,7 @@ def get_now() -> datetime: def check_ledger_month(context: CallbackContext) -> int: now_time = get_now() month = now_time.month - args = get_all_args(context) + args = get_args(context) if len(args) >= 1: month = args[0].replace("月", "") if re_data := re.findall(r"\d+", str(month)): diff --git a/plugins/genshin/material.py b/plugins/genshin/material.py index f534e67..66b076d 100644 --- a/plugins/genshin/material.py +++ b/plugins/genshin/material.py @@ -6,7 +6,7 @@ from core.baseplugin import BasePlugin from core.game.services import GameMaterialService from core.plugin import Plugin, handler from metadata.shortname import roleToName -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import url_to_file @@ -28,7 +28,7 @@ class Material(Plugin, BasePlugin): async def command_start(self, update: Update, context: CallbackContext) -> None: message = update.effective_message user = update.effective_user - args = get_all_args(context) + args = get_args(context) if len(args) >= 1: character_name = args[0] else: diff --git a/plugins/genshin/player_cards.py b/plugins/genshin/player_cards.py index 481e195..3af4089 100644 --- a/plugins/genshin/player_cards.py +++ b/plugins/genshin/player_cards.py @@ -31,7 +31,7 @@ from core.user import UserService from core.user.error import UserNotFoundError from metadata.shortname import roleToName from modules.playercards.helpers import ArtifactStatsTheory, fix_skills_level_data -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import url_to_file @@ -68,7 +68,7 @@ class PlayerCards(Plugin, BasePlugin): async def player_cards(self, update: Update, context: CallbackContext) -> None: user = update.effective_user message = update.effective_message - args = get_all_args(context) + args = get_args(context) await message.reply_chat_action(ChatAction.TYPING) try: user_info = await self.user_service.get_user_by_id(user.id) diff --git a/plugins/genshin/sign.py b/plugins/genshin/sign.py index 4167047..6436063 100644 --- a/plugins/genshin/sign.py +++ b/plugins/genshin/sign.py @@ -27,7 +27,7 @@ from core.sign.services import SignServices from core.user.error import UserNotFoundError from core.user.services import UserService from modules.apihelper.hyperion import Verification -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import get_genshin_client @@ -345,7 +345,7 @@ class Sign(Plugin, BasePlugin): async def command_start(self, update: Update, context: CallbackContext) -> None: user = update.effective_user message = update.effective_message - args = get_all_args(context) + args = get_args(context) validate: Optional[str] = None if len(args) >= 1: msg = None diff --git a/plugins/genshin/strategy.py b/plugins/genshin/strategy.py index c88c48f..de926bd 100644 --- a/plugins/genshin/strategy.py +++ b/plugins/genshin/strategy.py @@ -9,7 +9,7 @@ from core.baseplugin import BasePlugin from core.game.services import GameStrategyService from core.plugin import Plugin, handler from metadata.shortname import roleToName -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import url_to_file @@ -31,7 +31,7 @@ class StrategyPlugin(Plugin, BasePlugin): async def command_start(self, update: Update, context: CallbackContext) -> None: message = update.effective_message user = update.effective_user - args = get_all_args(context) + args = get_args(context) if len(args) >= 1: character_name = args[0] else: diff --git a/plugins/genshin/weapon.py b/plugins/genshin/weapon.py index 0c8b02b..e6c69c7 100644 --- a/plugins/genshin/weapon.py +++ b/plugins/genshin/weapon.py @@ -10,7 +10,7 @@ from core.wiki.services import WikiService from metadata.genshin import honey_id_to_game_id from metadata.shortname import weaponToName from modules.wiki.weapon import Weapon -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.error import error_callable from utils.decorators.restricts import restricts from utils.helpers import url_to_file @@ -39,7 +39,7 @@ class WeaponPlugin(Plugin, BasePlugin): async def command_start(self, update: Update, context: CallbackContext) -> None: message = update.effective_message user = update.effective_user - args = get_all_args(context) + args = get_args(context) if len(args) >= 1: weapon_name = args[0] else: diff --git a/plugins/system/get_chat.py b/plugins/system/get_chat.py index cb4d72d..ac4265a 100644 --- a/plugins/system/get_chat.py +++ b/plugins/system/get_chat.py @@ -12,7 +12,7 @@ from core.sign import SignServices from core.user import UserService from core.user.error import UserNotFoundError from modules.gacha_log.log import GachaLog -from utils.bot import get_all_args, get_chat as get_chat_with_cache +from utils.bot import get_args, get_chat as get_chat_with_cache from utils.decorators.admins import bot_admins_rights_check from utils.helpers import get_genshin_client from utils.log import logger @@ -111,7 +111,7 @@ class GetChat(Plugin): user = update.effective_user logger.info(f"用户 {user.full_name}[{user.id}] get_chat 命令请求") message = update.effective_message - args = get_all_args(context) + args = get_args(context) if not args: await message.reply_text("参数错误,请指定群 id !") return diff --git a/plugins/system/update.py b/plugins/system/update.py index 40ff430..55fa181 100644 --- a/plugins/system/update.py +++ b/plugins/system/update.py @@ -10,7 +10,7 @@ from telegram.ext import CallbackContext, CommandHandler from core.bot import bot from core.plugin import handler, Plugin -from utils.bot import get_all_args +from utils.bot import get_args from utils.decorators.admins import bot_admins_rights_check from utils.helpers import execute from utils.log import logger @@ -42,7 +42,7 @@ class UpdatePlugin(Plugin): async def update(self, update: Update, context: CallbackContext): user = update.effective_user message = update.effective_message - args = get_all_args(context) + args = get_args(context) logger.info(f"用户 {user.full_name}[{user.id}] update命令请求") if self._lock.locked(): await message.reply_text("程序正在更新 请勿重复操作") diff --git a/utils/bot.py b/utils/bot.py index bdcef4e..c6f1f04 100644 --- a/utils/bot.py +++ b/utils/bot.py @@ -25,13 +25,21 @@ async def get_chat(chat_id: Union[str, int], ttl: int = 86400) -> Chat: return chat_info -def get_all_args(context: CallbackContext) -> List[str]: +def get_args(context: CallbackContext) -> List[str]: args = context.args match = context.match if args is None: if match is not None: groups = match.groups() - return list(groups) + command = groups[0] + if command: + temp = [] + command_parts = command.split(" ") + for command_part in command_parts: + if command_part: + temp.append(command_part) + return temp + return [] else: if len(args) >= 1: return args