From 5c339af0b6c6677a087e10c978e52e4e1f283ba4 Mon Sep 17 00:00:00 2001 From: Xtao_dada Date: Sun, 5 Dec 2021 16:54:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20sb=20and=20ship=20error=20?= =?UTF-8?q?(#152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 修复 sb 和 ship 命令报错 --- pagermaid/modules/fun.py | 9 ++++++--- pagermaid/modules/sb.py | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pagermaid/modules/fun.py b/pagermaid/modules/fun.py index 668f7e9..0e6a906 100644 --- a/pagermaid/modules/fun.py +++ b/pagermaid/modules/fun.py @@ -194,9 +194,12 @@ async def ship(context): else: await context.edit(lang('arg_error')) return - await context.edit(f"**{lang('ship_hint')}(((**\n" - f"[{target_1.first_name}](tg://user?id={target_1.id}) + " - f"[{target_2.first_name}](tg://user?id={target_2.id}) = ❤️") + try: + await context.edit(f"**{lang('ship_hint')}(((**\n" + f"[{target_1.first_name}](tg://user?id={target_1.id}) + " + f"[{target_2.first_name}](tg://user?id={target_2.id}) = ❤️") + except AttributeError: + await context.edit(lang('ship_BaseException')) @listener(is_plugin=False, outgoing=True, command=alias_command("rng"), diff --git a/pagermaid/modules/sb.py b/pagermaid/modules/sb.py index 6e2b70d..24799a1 100644 --- a/pagermaid/modules/sb.py +++ b/pagermaid/modules/sb.py @@ -5,7 +5,7 @@ from struct import error as StructError from telethon.tl.functions.messages import GetCommonChatsRequest from telethon.tl.functions.users import GetFullUserRequest from telethon.tl.functions.channels import DeleteUserHistoryRequest -from telethon.tl.types import MessageEntityMentionName, ChannelParticipantsAdmins, MessageEntityPhone +from telethon.tl.types import MessageEntityMentionName, ChannelParticipantsAdmins, MessageEntityPhone, PeerChannel from telethon.errors.rpcerrorlist import UserAdminInvalidError, ChatAdminRequiredError, FloodWaitError from asyncio import sleep from random import uniform @@ -48,12 +48,18 @@ async def span_ban(context): else: await context.edit(lang('arg_error')) return + if isinstance(user, PeerChannel): + return await context.edit(lang('arg_error')) + elif not user: + return await context.edit(lang('arg_error')) target_user = await context.client(GetFullUserRequest(user)) else: if len(context.parameter) == 1: user = context.parameter[0] if user.isnumeric(): user = int(user) + if user < 0: + return await context.edit(lang('arg_error')) else: await context.edit(lang('arg_error')) return