30 lines
878 B
Python
30 lines
878 B
Python
from .config import Config, load_config
|
|
from .logger import create_logger
|
|
from .bot import get_bot
|
|
from .i18n import I18N
|
|
from .database import get_engine
|
|
from .states import get_state_storage
|
|
from .middlewares import setup_middlewares
|
|
from .filters import add_custom_filters
|
|
|
|
|
|
def create_bot(config: Config, i18n: I18N):
|
|
state_storage = get_state_storage(config.states)
|
|
bot = get_bot(config.bot, state_storage)
|
|
setup_middlewares(bot, i18n)
|
|
add_custom_filters(bot, config)
|
|
return bot
|
|
|
|
|
|
def main():
|
|
config = load_config()
|
|
# logger = create_logger("mybot", config.log_level)
|
|
i18n = I18N(config.i18n)
|
|
# engine = get_engine(config.database)
|
|
bot = create_bot(config, i18n)
|
|
bot.infinity_polling(
|
|
timeout=config.bot.timeout,
|
|
long_polling_timeout=config.bot.polling_timeout,
|
|
skip_pending=config.bot.skip_pending
|
|
)
|