minor updates
Build Docs / changes (push) Successful in 4s
Build Docs / build-docs (push) Has been skipped
Build Docs / deploy-docs (push) Has been skipped

This commit is contained in:
Alexander Kalinovsky committed 2025-03-20 18:30:18 +07:00
1 parent 8d99e6f5d5
commit 66a6de8b20
2 files changed
+26 -7

No files matched your search

+21 -1
View File
@@ -26,7 +26,27 @@ class Config(BaseSettings):
API_PORT: int = 8000 API_PORT: int = 8000
TELEGRAM_WEBHOOK_URL: str = "http://localhost:8000" TELEGRAM_WEBHOOK_DOMAIN: str = "localhost"
TELEGRAM_WEBHOOK_SHEME: str = "https"
TELEGRAM_WEBHOOK_PORT: int = 443
@property
def TELEGRAM_WEBHOOK_URL(self) -> str:
return f"{self.TELEGRAM_WEBHOOK_SHEME}://{self.TELEGRAM_WEBHOOK_DOMAIN}{
f':{self.TELEGRAM_WEBHOOK_PORT}'
if (
(
self.TELEGRAM_WEBHOOK_PORT != 80
and self.TELEGRAM_WEBHOOK_SHEME == 'http'
)
or (
self.TELEGRAM_WEBHOOK_PORT != 443
and self.TELEGRAM_WEBHOOK_SHEME == 'https'
)
)
else ''
}"
TELEGRAM_BOT_SERVER: str = "https://api.telegram.org" TELEGRAM_BOT_SERVER: str = "https://api.telegram.org"
TELEGRAM_BOT_SERVER_IS_LOCAL: bool = False TELEGRAM_BOT_SERVER_IS_LOCAL: bool = False
TELEGRAM_BOT_TOKEN: str = "changethis" TELEGRAM_BOT_TOKEN: str = "changethis"
+5 -6
View File
@@ -1,4 +1,3 @@
from asyncio import sleep
from contextlib import asynccontextmanager from contextlib import asynccontextmanager
from typing import Callable, Any from typing import Callable, Any
from aiogram import Bot, Dispatcher from aiogram import Bot, Dispatcher
@@ -196,11 +195,11 @@ class QBotApp[UserType: UserBase](FastAPI):
) )
await self.bot.set_webhook( await self.bot.set_webhook(
url=f"{self.config.TELEGRAM_WEBHOOK_URL}/telegram/webhook", url=f"{self.config.TELEGRAM_WEBHOOK_URL}/telegram/webhook",
drop_pending_updates=True, drop_pending_updates=True,
allowed_updates=self.allowed_updates, allowed_updates=self.allowed_updates,
secret_token=self.bot_auth_token, secret_token=self.bot_auth_token,
) )
async def bot_close(self): async def bot_close(self):
await self.bot.delete_webhook() await self.bot.delete_webhook()