from telegram import Bot
import asyncio
TOKEN = "blah"
CHAT_ID = 1
async def send_message_async():
message = "This is a test update from the bot!"
bot = Bot(token=TOKEN)
await bot.send_message(chat_id=CHAT_ID, text=message)
print("Message sent successfully!")
async def main():
print("Before sending message...")
await send_message_async()
print("After sending message...") # I don't want this to be blocked until the message is sent
if __name__ == "__main__":
asyncio.run(main())
I’m trying to send message without blocking whole thread, but I’m struggling to avoid it. Is there any way?