My bot hangs right at the beginning of the .start(), and hangs until I manually kill the process. I am trying to host it on a raspberry pi. None of these issues came up when I ran it locally on my computer, so I am kinda confused on what went wrong. I get this output and then it hangs:
beginning of main
INFO:telethon.network.mtprotosender:Connecting to 149.154.167.51:443/TcpFull…
INFO:telethon.network.mtprotosender:Connection to 149.154.167.51:443/TcpFull complete!
Any help would be greatly appreciated!
import asyncio
import os
import logging
from dotenv import load_dotenv
from telethon import TelegramClient, events
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Load environment variables
load_dotenv()
api_id = os.environ.get("API_ID", None)
api_hash = os.environ.get("API_HASH", None)
bot = TelegramClient("session_name", api_id=int(api_id), api_hash=api_hash)
async def on_startup():
logger.info("Sending startup messages...")
logger.info("Startup messages sent")
async def main():
print("beginning of main")
await bot.start()
logger.info("After start() call")
print("bot started")
await on_startup()
logger.info("Starting the bot...")
await bot.run_until_disconnected()
if __name__ == "__main__":
asyncio.run(main())
I tried updating all my packages, but they were all already up to date. I’m still sort of a python noob so please take it easy on me 🙂
dumb whale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.