JavaScript
x
20
20
1
from aiogram import Bot, Dispatcher, types
2
from aiogram.utils import executor
3
4
bot: Bot = Bot(token='TOKEN')
5
dp = Dispatcher(bot)
6
7
8
@dp.message_handler()
9
async def get_message(message: types.Message):
10
chat_id = message.chat.id
11
text = "shiz ?"
12
13
14
sent_message = await bot.send_message(chat_id=chat_id, text=text)
15
16
print(sent_message.to_python())
17
18
19
executor.start_polling(dp)
20
#local variable “chat_id” value is not used #local variable “text” value is not used
Advertisement
Answer
You should fix your function to be as such:
JavaScript
1
7
1
@dp.message_handler()
2
async def get_message(message: types.Message):
3
chat_id = message.chat.id
4
text = "shiz ?"
5
sent_message = await bot.send_message(chat_id=chat_id, text=text)
6
print(sent_message.to_python())
7
Placing the send_message and print inside the get_message in order to make use of the chat_id and text