42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
# aiogram
|
|
from aiogram import Bot, Dispatcher
|
|
from aiogram.client.default import DefaultBotProperties
|
|
from aiogram.enums import ParseMode
|
|
from aiogram.fsm.storage.redis import RedisStorage, DefaultKeyBuilder, StorageKey
|
|
from aiogram.types import BotCommand
|
|
|
|
# cfg
|
|
from decouple import config
|
|
|
|
# db
|
|
from database.orm import ORM
|
|
|
|
# utils
|
|
from utils.proxy import build_bot_session
|
|
|
|
# another
|
|
import logging, pytz
|
|
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
redis_url = config("REDIS_URL")
|
|
bot_session = build_bot_session()
|
|
bot = Bot(
|
|
token=config("TOKEN"),
|
|
session=bot_session,
|
|
default=DefaultBotProperties(
|
|
parse_mode=ParseMode.HTML,
|
|
link_preview_is_disabled=True,
|
|
),
|
|
)
|
|
storage = RedisStorage.from_url(redis_url)
|
|
storage.key_builder = DefaultKeyBuilder(with_bot_id=True)
|
|
dp = Dispatcher(storage=storage)
|
|
|
|
start_command = [BotCommand(command="/start", description="🔄 Перезапустить бота")]
|
|
tz = pytz.timezone(config("TIMEZONE"))
|
|
orm = ORM()
|