webhook to start pooling, removed env variables for app url and port

Author:    miloszowi <miloszweb@gmail.com>

Author:    miloszowi <miloszweb@gmail.com>
This commit is contained in:
miloszowi 2021-09-25 16:49:11 +02:00
parent c22338b7c1
commit c29b0dabc5
4 changed files with 2 additions and 17 deletions

View File

@ -4,5 +4,3 @@ firebase_authDomain=
firebase_databaseURL=
firebase_projectId=
firebase_storageBucket=
app_url=
PORT=

View File

@ -33,8 +33,6 @@ cp .env.local .env
and then fulfill copied `.env` file with required values
- `bot_token` - your telegram bot token from [BotFather](https://telegram.me/BotFather)
- `firebase_*` - all of those values you can find in firebase console
- `app_url` - your app url for retrieving webhooks
- `PORT` - port for your app
### Commands
#### `/in`

View File

@ -1,4 +1,4 @@
from .config.credentials import bot_token, app_url, port
from .config.credentials import bot_token
from .config.handlers import handlers
from .handlers.handlerInterface import HandlerInterface
from telegram.ext.dispatcher import Dispatcher
@ -14,8 +14,7 @@ class App:
def run(self) -> None:
self.registerHandlers()
self.registerWebhook()
self.updater.start_polling()
self.updater.idle()
def registerHandlers(self) -> None:
@ -24,11 +23,3 @@ class App:
raise Exception('Invalid list of handlers provided. Handler must implement HandlerInterface')
self.updater.dispatcher.add_handler(handler.getBotHandler())
def registerWebhook(self) -> None:
self.updater.start_webhook(
listen="0.0.0.0",
port=int(port),
url_path=bot_token,
webhook_url=f'{app_url}/{bot_token}'
)

View File

@ -4,8 +4,6 @@ from dotenv import load_dotenv
load_dotenv()
bot_token = os.environ['bot_token']
app_url = os.environ['app_url']
port = os.environ['PORT']
firebaseConfig = {
"apiKey": os.environ['firebase_apiKey'],