LANGUAGE/Python
Solution for the error, <coroutine object Bot.send_message at 0x000002E052140F20>.
Hogeony
2023. 2. 21. 15:49
This is caused by the update of python-telegram-bot library.
When using old version,
import telegram
bot, chat_id = telegram.Bot(token='<your token>'), '<your chat id>'
bot.sendMessage(chat_id=chat_id, text='<message>')
When using recent version to avoid the error, <coroutine object Bot.send_message at 0x000002E052140F20>,
import asyncio, telegram
async def sendMessage(msg):
bot, chat_id = telegram.Bot(token='<your token>'), '<your chat id>'
await bot.send_message(chat_id, msg)
asyncio.run(sendMessage('<message>'))