-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
46 lines (34 loc) · 1.16 KB
/
Copy pathrun.py
File metadata and controls
46 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Run script for the UTeM Student Assistant Bot."""
import logging
import sys
from telegram.ext import Application
from src.config import config, Config
from src.database.models import init_db
from src.bot.handlers import register_handlers
# Configure logging
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO
)
logger = logging.getLogger(__name__)
def main() -> None:
"""Initialize and run the bot."""
# Validate configuration
missing = Config.validate()
if missing:
logger.error(f"Missing required configuration: {', '.join(missing)}")
logger.error("Please check your .env file")
sys.exit(1)
# Initialize database
logger.info(f"Initializing database at {config.DATABASE_PATH}")
init_db(config.DATABASE_PATH)
# Create the Application
logger.info("Starting bot...")
application = Application.builder().token(config.TELEGRAM_TOKEN).build()
# Register handlers
register_handlers(application)
# Run the bot until Ctrl+C
logger.info("Bot is running. Press Ctrl+C to stop.")
application.run_polling()
if __name__ == "__main__":
main()