2020-06-05 14:53:21 +02:00
|
|
|
import logging
|
2020-06-15 14:15:50 +02:00
|
|
|
from pyrogram import CallbackQueryHandler
|
2020-06-05 14:53:21 +02:00
|
|
|
from pyrogram.session import Session
|
|
|
|
import importlib
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-06-05 21:22:17 +02:00
|
|
|
MODULE_NAME = "BotBase" # Change this to match the FOLDER name that contains the config.py file
|
2020-06-06 19:28:12 +02:00
|
|
|
conf = importlib.import_module(f"{MODULE_NAME}.config")
|
2020-06-15 14:15:50 +02:00
|
|
|
bot = conf.bot
|
2020-06-11 10:58:50 +02:00
|
|
|
antiflood = importlib.import_module(f"{MODULE_NAME}.modules.antiflood")
|
2020-06-06 19:28:12 +02:00
|
|
|
dbmodule = importlib.import_module(f"{MODULE_NAME}.database.query")
|
2020-06-05 14:53:21 +02:00
|
|
|
logging.basicConfig(format=conf.LOGGING_FORMAT, datefmt=conf.DATE_FORMAT, level=conf.LOGGING_LEVEL)
|
2020-06-11 10:58:50 +02:00
|
|
|
bot.add_handler(CallbackQueryHandler(antiflood.anti_flood, ~antiflood.BYPASS_USERS), group=-1)
|
2020-06-05 14:53:21 +02:00
|
|
|
Session.notice_displayed = True
|
|
|
|
try:
|
|
|
|
logging.warning("Running create_database()")
|
2020-06-06 19:28:12 +02:00
|
|
|
dbmodule.create_database(conf.DB_PATH, conf.DB_CREATE)
|
2020-06-05 14:53:21 +02:00
|
|
|
logging.warning("Database interaction complete")
|
|
|
|
logging.warning("Starting bot")
|
|
|
|
bot.start()
|
|
|
|
logging.warning("Bot started")
|
2020-06-05 21:22:17 +02:00
|
|
|
except Exception as e:
|
|
|
|
logging.warning(f"Stopping bot due to a {type(e).__name__}: {e}")
|
2020-06-05 14:53:21 +02:00
|
|
|
bot.stop()
|