🐛 Fix sb and ship error (#152)

* 🐛 修复 sb 和 ship 命令报错
This commit is contained in:
Xtao_dada 2021-12-05 16:54:25 +08:00 committed by GitHub
parent cca6d804dc
commit 5c339af0b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -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"),

View File

@ -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