mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Clearer error on send_file(chat, invalid type)
This commit is contained in:
parent
f540c4e089
commit
6db60627e6
|
@ -184,6 +184,10 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
|||
The `telethon.tl.custom.message.Message` (or messages) containing
|
||||
the sent file, or messages if a list of them was passed.
|
||||
"""
|
||||
# i.e. ``None`` was used
|
||||
if not file:
|
||||
raise TypeError('Cannot use {!r} as file'.format(file))
|
||||
|
||||
if not caption:
|
||||
caption = ''
|
||||
|
||||
|
@ -243,6 +247,10 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
|||
supports_streaming=supports_streaming
|
||||
)
|
||||
|
||||
# e.g. invalid cast from :tl:`MessageMediaWebPage`
|
||||
if not media:
|
||||
raise TypeError('Cannot use {!r} as file'.format(file))
|
||||
|
||||
markup = self.build_reply_markup(buttons)
|
||||
request = functions.messages.SendMediaRequest(
|
||||
entity, media, reply_to_msg_id=reply_to, message=caption,
|
||||
|
|
|
@ -313,7 +313,7 @@ async def handler(event):
|
|||
text = 'Available commands:\n'
|
||||
for callback, handler in bot.list_event_handlers():
|
||||
if isinstance(handler, events.NewMessage) and callback.__doc__:
|
||||
text += f'\n{callback.__doc__}'
|
||||
text += f'\n{callback.__doc__.strip()}'
|
||||
text += '\n\nYou can suggest new commands [here](https://docs.google.com/'\
|
||||
'spreadsheets/d/12yWwixUu_vB426_toLBAiajXxYKvR2J1DD6yZtQz9l4/edit).'
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user