F
F
From Prog2021-07-07 21:25:54
Python
From Prog, 2021-07-07 21:25:54

Why is Dispather needed in Aiogram?

The code:

bot = Bot(token = TOKEN)
mybot = Dispatcher(bot) 

@mybot.message_handler(commands = 'start')
async def greetings(message: types.Message):
  stick = open('settings\\Greetings_from_Steve_Jobs_for_users_of_my_second_python_bot_for_telegram.webp', 'rb')
  await bot.send_sticker(message.chat.id, stick)
  stick.close()

What is the Dispatcher for, if sending is done like this: await bot.send_sticker(message.chat.id, stick)?

Also, why open a file in binary mode?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bl4ckm45k, 2021-07-07
@FromProg

It is not necessary to go so deep at this stage of studying the library.
In short Dispatcher accepts all updates and processes them.
You can send messages as you like, even await mybot.bot.send_sticker or await bot.send_sticker, as long as everything is imported correctly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question