sorry for my weak English. I apologize for any mistakes. I'm using the Telethon library to bypass the upload restrictions for videos on Telegram. However, when the bot uploads multiple videos, I receive the following error message in the console:
telethon.errors.rpcerrorlist.FloodWaitError: A wait of 1301 seconds is required (caused by ImportBotAuthorizationRequest)
Here is the code I used for uploading files:
python
class Telethon:
def __init__(self):
self.bot = TelegramClient('bot', API_ID, API_HASH)
async def uploadVideo(self, chatID: str, messageID: str, videoPath: str, duration: int, width: int, height: int, thumbnailPath: str, caption: str, str_progressBar: str, video_name: str, thumbnail_name: str):
if not os.path.exists('bot.session'):
await self.bot.connect()
await self.bot.start(bot_token=TOKEN)
videoAttributes = [
DocumentAttributeVideo(
duration=duration, w=width, h=height, supports_streaming=True)
]
video = await fast_upload(self.bot, videoPath, progress_bar_function=self.progress_callback, reply="Uploading ...", name=video_name)
image = await fast_upload(self.bot, thumbnailPath, progress_bar_function=self.progress_callback, reply="Uploading ...", name=thumbnail_name)
media = InputMediaUploadedDocument(
file=video,
mime_type='video/mp4',
attributes=videoAttributes,
thumb=image
)
await self.bot.delete_messages(chatID, messageID)
self.removeFiles([videoPath, thumbnailPath])
await self.bot.send_file(chatID, media, caption=caption)
await self.bot.disconnect()
I'm using a Windows server, and my Python version is 3.8 The Telethon version I'm using is 1.28.5.
I would appreciate it if you could help me.
I tried almost everything on the internet.
This is unrelated to video uploading. the cause of the error "ImportBotAuthorization" request. you're setting up your TelegramClient('session_name', ...) wrong. "session_name.session" file shouldn't be deleted, Telegram api will recently restrict you if you import bot token too much, you need to keep the .session file and let the library use that. bot_token in start() should only be used rarely.
you can try to revoke your current bot_token through @BotFather and try again.