BotBase/bot.py

21 lines
762 B
Python
Raw Permalink Normal View History

2020-06-05 14:53:21 +02:00
import logging
2020-06-25 17:30:30 +02:00
from pyrogram import Client
2020-06-05 14:53:21 +02:00
from pyrogram.session import Session
2020-06-25 17:30:30 +02:00
from BotBase.config import bot, LOGGING_LEVEL, LOGGING_FORMAT, DATE_FORMAT, DB_PATH, DB_CREATE
from BotBase.database.query import create_database
2020-06-05 14:53:21 +02:00
if __name__ == "__main__":
2020-06-25 17:30:30 +02:00
logging.basicConfig(format=LOGGING_FORMAT, datefmt=DATE_FORMAT, level=LOGGING_LEVEL)
2020-06-05 14:53:21 +02:00
Session.notice_displayed = True
try:
logging.warning("Running create_database()")
2020-06-25 17:30:30 +02:00
create_database(DB_PATH, 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")
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()