django-telegrambot icon indicating copy to clipboard operation
django-telegrambot copied to clipboard

The bot is executed every time a command manage.py is run

Open drago-96 opened this issue 7 years ago • 8 comments

In my django installation it seems that when I run python manage.py my-command, the bot is started again: in fact, I see the log "Loading handlers for telegram bot". How is that possible?

drago-96 avatar Feb 19 '18 12:02 drago-96

This is normal in Django, manage.py reload every installed app included django-telegrambot.

JungDev avatar Feb 21 '18 14:02 JungDev

Well, maybe someone wants to execute a setup() only once... I solved by setting a cache/file to be checked every time.

drago-96 avatar Feb 21 '18 15:02 drago-96

I think can be nice. If you wanna share your solution send a pull request.

JungDev avatar Feb 28 '18 10:02 JungDev

Has there been any progress regarding that issue? I am facing the same problem.

alephyud avatar May 16 '18 17:05 alephyud

I don't call it issue. Why the django's modules reloading is a problem for you?

JungDev avatar May 17 '18 09:05 JungDev

The issue is that django-telegram sends webhook requests to the Telegram servers every time the module is started.

I don't want the app to fire setWebhook requests every time I execute a manage.py command (especially, if it is already running as a server in parallel).

Happy to comment in more detail if needed.

On Thu, 17 May 2018, 12:23 JungDev, [email protected] wrote:

I don't call it issue. Why the django's modules reloading is a problem for you?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JungDev/django-telegrambot/issues/14#issuecomment-389803234, or mute the thread https://github.com/notifications/unsubscribe-auth/AIYGn3IFLudJztkSxk_FuFrie1FHS194ks5tzUGFgaJpZM4SKfJb .

alephyud avatar May 17 '18 11:05 alephyud

Django operate a reload of all installed app, and I can't change this. I think that better way to not send a webhook setting request at every reload is add a check in code if something is changed in webhook state (url, certificate,timeout, max_connections and allowed_updates), but this means make anyway a getWebhookInfo request to telegram's server everytime and this method don't give back any info about timeout and which certificate is setted.
Do you think that is better than now?

JungDev avatar May 17 '18 12:05 JungDev

Hi all, any news about that?

rocchidavide avatar Dec 14 '22 10:12 rocchidavide