From 7b71a72bdef58f107c786b334b89c141d161560b Mon Sep 17 00:00:00 2001 From: Olegt0rr Date: Sun, 18 Mar 2018 14:41:34 +0300 Subject: [PATCH 1/2] Split WEBHOOK and WEBAPP settings --- examples/webhook_example.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/webhook_example.py b/examples/webhook_example.py index 6a5317cf..1a4b8198 100644 --- a/examples/webhook_example.py +++ b/examples/webhook_example.py @@ -25,6 +25,12 @@ WEBHOOK_SSL_PRIV = './webhook_pkey.pem' # Path to the ssl private key WEBHOOK_URL = f"https://{WEBHOOK_HOST}:{WEBHOOK_PORT}{WEBHOOK_URL_PATH}" +# Web app settings: +# Use LAN address to listen webhooks +# User any available port in range from 1024 to 49151 if you're using proxy, or WEBHOOK_PORT if you're using direct webhook handling +WEBAPP_HOST = 'localhost' +WEBAPP_PORT = 3001 + BAD_CONTENT = ContentType.PHOTO & ContentType.DOCUMENT & ContentType.STICKER & ContentType.AUDIO loop = asyncio.get_event_loop() @@ -160,7 +166,7 @@ if __name__ == '__main__': context.load_cert_chain(WEBHOOK_SSL_CERT, WEBHOOK_SSL_PRIV) # Start web-application. - web.run_app(app, host=WEBHOOK_HOST, port=WEBHOOK_PORT, ssl_context=context) + web.run_app(app, host=WEBAPP_HOST, port=WEBAPP_PORT, ssl_context=context) # Note: # If you start your bot using nginx or Apache web server, SSL context is not required. # Otherwise you need to set `ssl_context` parameter. From 23fc14a7a42f453dfce9f409adc8ce22e5039367 Mon Sep 17 00:00:00 2001 From: Olegt0rr Date: Sun, 18 Mar 2018 23:54:52 +0300 Subject: [PATCH 2/2] web.run_app doesn't wait for loop kwarg Fix error: run_app() got an unexpected keyword argument 'loop' --- aiogram/utils/executor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiogram/utils/executor.py b/aiogram/utils/executor.py index ed8947eb..13f9fdf9 100644 --- a/aiogram/utils/executor.py +++ b/aiogram/utils/executor.py @@ -87,5 +87,5 @@ def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None, app.on_startup.append(_wh_startup) app.on_shutdown.append(_wh_shutdown) - web.run_app(app, loop=loop, **kwargs) + web.run_app(app, **kwargs) return app