为了不再重新下载该文件,我想发送从先前发送的消息中获取的文件id
file_id在telethon中如何使用bot(而不是客户端)发送文件:
async def main():
t_client = TelegramClient(TG_APP_TITLE, TG_APP_ID, TG_API_HASH)
await t_client.connect()
if not await t_client.is_user_authorized():
await t_client.send_code_request(TG_PHONE)
await t_client.sign_in(code=input('Get code:'))
t_bot = TelegramClient(f'{TG_APP_TITLE}Bot', TG_APP_ID, TG_API_HASH)
a_bot = aiogram.Bot(TG_BOT_API_TOKEN)
await t_client.start()
await t_bot.start(bot_token=TG_BOT_API_TOKEN)
r = await t_client.send_file(TG_BOT, 'podcasts/gnj2_SB0MOM.100.96.mp3')
file_id = pack_bot_file_id(r.media)
await t_client.send_file(TG_CHAT_ID, file_id) # Correct
await a_bot.send_audio(TG_CHAT_ID, file_id) # Correct
await t_bot.send_file(TG_CHAT_ID, file_id) # Error
当我试图通过bot发送文件\u id时
await t_bot.send_file(TG_USER, file_id)
Traceback (most recent call last):
File "C:/Users/Alexo/PycharmProjects/personal/TGVideoToPodcastBot/temp.py", line 76, in main
await t_bot.send_file(TG_CHAT_ID, file_id) # Error
File "C:\Python39\lib\site-packages\telethon\client\uploads.py", line 381, in send_file
return self._get_response_message(request, await self(request), entity)
File "C:\Python39\lib\site-packages\telethon\client\users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
File "C:\Python39\lib\site-packages\telethon\client\users.py", line 79, in _call
result = await future
telethon.errors.rpcerrorlist.MediaEmptyError: The provided media object is invalid or the current account may not be able to send it (such as games as users) (caused by SendMediaRequest)
如果我通过botapi(Bot)或客户端(t客户端)发送文件id,那么一切都正常
目前没有回答
相关问题 更多 >
编程相关推荐