V
V
Vadim Veyss2022-01-19 12:45:37
Django
Vadim Veyss, 2022-01-19 12:45:37

How to send news from your Django site to the Telegram channel?

I have my own simple website on Django framework and postgresql database. This site publishes some entries from time to time. Now I needed to make a telegram channel, to which the bot will add entries as they are published on the site.

I still can't figure out how to implement this. Googled on this issue, but everything leads either to simply creating a bot in BotFather, or writing some elementary things like an echo bot.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2022-01-19
@docLamer

  1. Create a bot (many articles)
  2. Add it to the channel
  3. Find out the channel ID (the bot receives it in its message, you can write it to the log, for example)
  4. Register the channel ID of the bot in the settings
  5. Write logic to the bot: check for new records in the database every N minutes. If there is - send a message to the channel with the given ID
  6. Ready

In point 5, you can implement other logic for notifying about articles, including subscribing to events, the sending of which can be configured in Django. At one time I did it through events, but my bot was "embedded" inside the server part of the application, so there were no problems with this in principle. As for you - I do not know, so I offer 2 options.

D
Danilich123, 2022-01-19
@Danilich123

Try this program through IFTTT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question