Initial commit: UMB Telegram Bot
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
import logging
|
||||
from aiogram import Bot, Dispatcher
|
||||
from aiogram.client.default import DefaultBotProperties
|
||||
from aiogram.client.session.aiohttp import AiohttpSession
|
||||
from config import BOT_TOKEN, PROXY_ENABLED, PROXY_URL
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
session = AiohttpSession()
|
||||
|
||||
if PROXY_ENABLED and PROXY_URL:
|
||||
session.proxy = PROXY_URL
|
||||
|
||||
bot = Bot(token=BOT_TOKEN, session=session, default=DefaultBotProperties(parse_mode="HTML"))
|
||||
dp = Dispatcher()
|
||||
|
||||
|
||||
async def setup_proxy():
|
||||
if not PROXY_ENABLED or not PROXY_URL:
|
||||
return
|
||||
try:
|
||||
me = await bot.me()
|
||||
logger.info(f"Бот подключен через прокси: @{me.username}")
|
||||
except Exception as e:
|
||||
logger.error(f"Не могу соединиться с прокси сервером. Попробуй другой прокси. Ошибка: {e}")
|
||||
raise
|
||||
Reference in New Issue
Block a user