I developed a basic Telegram bot utilizing Telethon and encountered an issue when trying to run it. Here’s my code:
from telethon import TelegramClient, events
from settings import *
bot_client = TelegramClient('bot_session', api_id=api_id, api_hash=api_hash)
@bot_client.on(events.NewMessage(pattern=r'/start'))
async def on_start(event):
await bot_client.send_message(entity=event.chat_id, message='Hello')
bot_client.start()
bot_client.run_until_disconnected()
However, I keep receiving a TimeoutError after executing the bot. I’ve tried using both VPS and VPN as well as a proxy, but the problem persists. Can someone provide assistance who has experience with this issue?
Error messages include:
Connection attempt 1 failed: TimeoutError:
Connection attempt 2 failed: TimeoutError:
... (up to attempt 6)
ConnectionError: Unable to connect to Telegram after multiple attempts.