aahnik / run-py-bot

A telegram bot that runs python code. Evaluate pythonic expressions on the go, right from your chat.
MIT License
50 stars 36 forks source link

Could not deploy to heroku using webhook #15

Closed aahnik closed 4 years ago

aahnik commented 4 years ago

I have rewritten the bot and made it work in an asynchronous fashion. Currently (v0.1.0), the bot uses aiogram.

The bot is working fine when it is run via polling. I have tested the bot via polling mode both locally ✔️ and on Heroku ✔️

The start.py is the script to start the bot. You must have an environment variable named BOT_API_TOKEN. The value of this should be equal to the token you obtained from @BotFather.

Tip: Instead of setting the env variable you may create a file token.txt in the root of the project, with the value of the token.

To start the bot via polling simply run the script start.py.


To run the bot via webhook:

You have to set some additional environment variables: APP_NAME = subdomain ( the name of your Heroku project ) DOMAIN = domain ( like herokuapp )

            ( your URL will be https://{APP_NAME}.{DOMAIN}.com )

METHOD = 'webhook' ( start.py will start webhook, if this env variable is present )

While starting the bot via webhook, no errors are being shown, but the bot is not responding. For setting up webhook, I have followed this example given in the official repo of aiogram

aahnik commented 4 years ago

Certain things need to be taken care of .

More details here

https://stackoverflow.com/questions/65007838/failing-to-deploy-a-aiogram-python-bot-in-webhook-mode/65021176#65021176

aahnik commented 4 years ago

successfully deployed to heroku, via webhook mode after commit ecc0f647253288fabb78dcebba3d4efacf31bf3e