def handle_message(bot: Client, msg: Message): check(msg.from_user) admin = get_admin(msg.chat.id) if msg.text and msg.text.startswith('/start '): file_id = msg.text.split()[-1] media = get_media(file_id) if not media: bot.send_message(msg.chat.id, 'Invalid link') return decode = decode_file_id(file_id) media_type = BaseClient.MEDIA_TYPE_ID[decode[0]] try: bot.__getattribute__(f'send_{media_type}')(msg.chat.id, file_id, caption=media[1]) except AttributeError: bot.send_message(msg.chat.id, "Can't send file") elif admin: if msg.text == '/st': bot.send_message(msg.chat.id, statistics()) return if msg.document: file_id = msg.document.file_id elif msg.video: file_id = msg.video.file_id elif msg.photo: file_id = msg.photo.file_id elif msg.audio: file_id = msg.audio.file_id elif msg.voice: file_id = msg.voice.file_id elif msg.text: if admin[1]: set_caption(admin, msg.text) bot.send_message(msg.chat.id, 'Caption set successfully') else: bot.send_message(msg.chat.id, 'First, send a file') return else: bot.send_message(msg.chat.id, 'Send a valid file!') return set_file_id(admin[0], file_id) bot.send_message(msg.chat.id, f't.me/{BOT_USERNAME}/?start={file_id}') else: bot.send_message(msg.chat.id, 'Please use file links')