🐛 Fix sb cannot recognize formatted text and add support MessageMediaUnsupported for s. (#161)
🐛 修复 sb 无法识别格式化文本的问题 🐛 修复 s 遇到 MessageMediaUnsupported 时报错
This commit is contained in:
parent
12320e2a59
commit
babbc1c44c
@ -6,7 +6,7 @@ from telethon.tl.functions.messages import GetCommonChatsRequest
|
||||
from telethon.tl.functions.users import GetFullUserRequest
|
||||
from telethon.tl.functions.channels import DeleteUserHistoryRequest, EditBannedRequest
|
||||
from telethon.tl.types import MessageEntityMentionName, ChannelParticipantsAdmins, MessageEntityPhone, PeerChannel, \
|
||||
ChatBannedRights
|
||||
ChatBannedRights, MessageEntityCode
|
||||
from telethon.errors.rpcerrorlist import UserAdminInvalidError, ChatAdminRequiredError, FloodWaitError
|
||||
from asyncio import sleep
|
||||
from random import uniform
|
||||
@ -68,22 +68,22 @@ async def span_ban(context):
|
||||
target_user = await context.client(GetFullUserRequest(user))
|
||||
else:
|
||||
if len(context.parameter) == 1:
|
||||
user = context.parameter[0]
|
||||
user = context.parameter[0].strip("`")
|
||||
if user.isnumeric():
|
||||
user = int(user)
|
||||
if user < 0:
|
||||
return await context.edit(lang('arg_error'))
|
||||
else:
|
||||
await context.edit(lang('arg_error'))
|
||||
return
|
||||
return await context.edit(lang('arg_error'))
|
||||
if context.message.entities is not None:
|
||||
if isinstance(context.message.entities[0], MessageEntityMentionName):
|
||||
user = context.message.entities[0].user_id
|
||||
elif isinstance(context.message.entities[0], MessageEntityPhone):
|
||||
user = int(context.parameter[0])
|
||||
elif isinstance(context.message.entities[0], MessageEntityCode):
|
||||
pass
|
||||
else:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
return await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
try:
|
||||
user_object = await context.client.get_entity(user)
|
||||
target_user = await context.client(GetFullUserRequest(user_object.id))
|
||||
|
@ -4,7 +4,8 @@ from bs4 import BeautifulSoup
|
||||
from asyncio import sleep
|
||||
from os import remove
|
||||
from io import BytesIO
|
||||
from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto, MessageMediaWebPage, MessageMediaDice
|
||||
from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto, MessageMediaWebPage, MessageMediaDice, \
|
||||
MessageMediaUnsupported
|
||||
from telethon.tl.functions.contacts import UnblockRequest
|
||||
from telethon.errors.common import AlreadyInConversationError
|
||||
from PIL import Image, ImageOps
|
||||
@ -214,6 +215,12 @@ async def single_sticker(animated, context, custom_emoji, emoji, message, pic_ro
|
||||
except:
|
||||
pass
|
||||
return
|
||||
elif isinstance(message.media, MessageMediaUnsupported):
|
||||
try:
|
||||
await context.edit(lang('sticker_type_not_support'))
|
||||
except:
|
||||
pass
|
||||
return
|
||||
elif "image" in message.media.document.mime_type.split('/'):
|
||||
photo = BytesIO()
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user