Relative Content

Tag Archive for pythonpython-asynciotelegrampython-telegram-bot

How to send a telegram message without blocking main thread

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 […]