JungDev / django-telegrambot

Simple app for Telegram bot in Django
BSD 3-Clause "New" or "Revised" License
237 stars 88 forks source link

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

Open drago-96 opened 6 years ago

drago-96 commented 6 years ago

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?

JungDev commented 6 years ago

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

drago-96 commented 6 years ago

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

JungDev commented 6 years ago

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

alephyud commented 6 years ago

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

JungDev commented 6 years ago

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

alephyud commented 6 years ago

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, notifications@github.com 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 .

JungDev commented 6 years ago

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?

rocchidavide commented 1 year ago

Hi all, any news about that?