R
R
rolandDiskeyn2022-02-17 15:42:30
Django
rolandDiskeyn, 2022-02-17 15:42:30

How to send a message from a bot to a group chat?

I need to write a bot that would run on a schedule and send a message to the chat immediately after launch.
Sending messages to message_handler doesn't work for me as I need the bot to send the message first.
Now I have this code

from aiogram import Bot, Dispatcher, executor, types
import asyncio

loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop)
dp = Dispatcher(bot)

async def send_file(chat_id):
    await bot.send_document(chat_id, open('test.log', 'r'))

if __name__ == '__main__':
    loop.create_task(send_file(chat_id='1826262178'))
    executor.start_polling(dp, skip_updates=False)


I don't want to use a chordcoded id, is it possible to get it somehow not from message? Or maybe there is another way to send messages from the bot?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman Kitaev, 2016-03-06
Sushkov

In the Meta class write verbose_name and verbose_name_plural

S
Sergey Gornostaev, 2016-03-06
@sergey-gornostaev

As Roman Kitaev already wrote , in the model meta-class, you can define the name of the model in Russian or localized, and the name of the application can be defined in AppConfig .

O
Oscar Django, 2016-03-06
@winordie

Read the relevant documentation section
djbook.ru/rel1.8/topics/i18n/translation.html#how-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question