60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
import functools
|
|
|
|
import telebot
|
|
from sqlalchemy.future import Engine
|
|
|
|
from . import handlers
|
|
|
|
__all__ = ["handlers"]
|
|
|
|
|
|
def create_bot(token: str, engine: Engine) -> telebot.TeleBot:
|
|
bot = telebot.TeleBot(token)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.set_master_password, bot, engine),
|
|
commands=["set_master_pass"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.get_account, bot, engine),
|
|
commands=["get_account"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.get_accounts, bot, engine),
|
|
commands=["get_accounts"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.add_account, bot, engine),
|
|
commands=["add_account"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.delete_all, bot, engine),
|
|
commands=["delete_all"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.reset_master_pass, bot, engine),
|
|
commands=["reset_master_pass"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.delete_account, bot, engine),
|
|
commands=["delete_account"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.help_command, bot),
|
|
commands=["help", "start"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.cancel, bot), commands=["cancel"]
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.export, bot, engine), commands=["export"]
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.import_accounts, bot, engine),
|
|
commands=["import"],
|
|
)
|
|
bot.register_message_handler(
|
|
functools.partial(handlers.gen_password, bot),
|
|
commands=["gen_password"],
|
|
)
|
|
return bot
|