mirror of
https://github.com/Balshgit/mosgortrans.git
synced 2026-02-03 11:20:56 +03:00
reworked to docker and selenoid
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
API_TOKEN=
|
||||
TELEGRAM_API_TOKEN=
|
||||
|
||||
# webhook settings
|
||||
WEBHOOK_HOST=
|
||||
WEBHOOK_PATH=
|
||||
|
||||
# webserver settings
|
||||
WEBAPP_HOST= # or ip
|
||||
WEBAPP_PORT=
|
||||
WEBAPP_HOST=127.0.0.1
|
||||
WEBAPP_PORT=8084
|
||||
|
||||
# set to 1 to start with webhook. Else bot will start on polling method
|
||||
START_WITH_WEBHOOK=
|
||||
|
||||
@@ -5,9 +5,9 @@ from aiogram.contrib.middlewares.logging import LoggingMiddleware
|
||||
from aiogram.dispatcher import Dispatcher
|
||||
from aiogram.utils.callback_data import CallbackData
|
||||
from app.core.parse_web import get_driver, parse_site
|
||||
from app.settings import API_TOKEN
|
||||
from app.settings import TELEGRAM_API_TOKEN
|
||||
|
||||
bot = Bot(token=API_TOKEN)
|
||||
bot = Bot(token=TELEGRAM_API_TOKEN)
|
||||
dispatcher = Dispatcher(bot)
|
||||
dispatcher.middleware.setup(LoggingMiddleware())
|
||||
|
||||
|
||||
12
app/main.py
12
app/main.py
@@ -14,8 +14,8 @@ from app.core.bot import bot, dispatcher
|
||||
from app.core.logger import logger
|
||||
from app.core.scheduler import asyncio_schedule
|
||||
from app.settings import (
|
||||
API_TOKEN,
|
||||
START_WITH_WEBHOOK,
|
||||
TELEGRAM_API_TOKEN,
|
||||
WEBAPP_HOST,
|
||||
WEBAPP_PORT,
|
||||
WEBHOOK_PATH,
|
||||
@@ -30,7 +30,11 @@ async def on_startup(dp: Dispatcher) -> None:
|
||||
await bot.set_webhook(WEBHOOK_URL)
|
||||
loop = asyncio.get_running_loop()
|
||||
loop.create_task(get_updates_from_queue())
|
||||
logger.info(f'Webhook set to {WEBHOOK_URL}'.replace(API_TOKEN, '{BOT_API_TOKEN}'))
|
||||
logger.info(
|
||||
f'Webhook set to {WEBHOOK_URL}'.replace(
|
||||
TELEGRAM_API_TOKEN, '{TELEGRAM_API_TOKEN}'
|
||||
)
|
||||
)
|
||||
asyncio_schedule()
|
||||
|
||||
|
||||
@@ -80,7 +84,9 @@ async def get_updates_from_queue() -> None:
|
||||
|
||||
async def create_app() -> web.Application:
|
||||
application = web.Application()
|
||||
application.router.add_post(f'{WEBHOOK_PATH}/{API_TOKEN}', put_updates_on_queue)
|
||||
application.router.add_post(
|
||||
f'{WEBHOOK_PATH}/{TELEGRAM_API_TOKEN}', put_updates_on_queue
|
||||
)
|
||||
application.on_startup.append(on_startup)
|
||||
application.on_shutdown.append(on_shutdown)
|
||||
return application
|
||||
|
||||
@@ -15,12 +15,14 @@ config = AutoConfig(search_path=env_path)
|
||||
|
||||
GECKO_DRIVER_VERSION = config('GECKO_DRIVER_VERSION', default='0.31.0')
|
||||
|
||||
API_TOKEN = config('API_TOKEN', default='123456789:AABBCCDDEEFFaabbccddeeff-1234567890')
|
||||
TELEGRAM_API_TOKEN = config(
|
||||
'API_TOKEN', default='123456789:AABBCCDDEEFFaabbccddeeff-1234567890'
|
||||
)
|
||||
|
||||
# webhook settings
|
||||
WEBHOOK_HOST = config('WEBHOOK_HOST', default='')
|
||||
WEBHOOK_PATH = config('WEBHOOK_PATH', default='')
|
||||
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}/{API_TOKEN}"
|
||||
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}/{TELEGRAM_API_TOKEN}"
|
||||
|
||||
# webserver settings
|
||||
WEBAPP_HOST = config('WEBAPP_HOST', default='127.0.0.1') # or ip
|
||||
|
||||
Reference in New Issue
Block a user