journal-bot/bot/main.py
Lia Schöneweiß dc14eb0aec
All checks were successful
continuous-integration/drone/push Build is passing
upsiwupsi
2023-11-25 15:07:39 +01:00

43 lines
1.3 KiB
Python

import os
from telegram.ext import Application
import logging
import models
from commands import journal, status, turtle, memory, advent
from commands.list import list
from cronjob import chat_photo, random_memory
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO
)
logging.getLogger("httpx").setLevel(logging.WARNING)
logger = logging.getLogger(__name__)
def main() -> None:
"""Run the bot."""
token = os.getenv("BOT_TOKEN")
db_path = os.getenv("DB_PATH")
models.set_db(db_path)
application = Application.builder().token(token).build()
application.add_handler(journal.JournalHandler("journal").handler)
application.add_handler(list.ListHandler("list").handler)
application.add_handler(status.StatusHandler("status").handler)
application.add_handler(turtle.TurtleHandler().handler)
application.add_handler(memory.MemoryHandler("memory").handler)
application.add_handler(advent.AdventsHandler("advent").handler)
random_memory.RandomMemoryJob(application.bot, application.job_queue)
chat_photo.SetChatPhotoJob(application.bot, application.job_queue)
# Run the bot until the user presses Ctrl-C
application.run_polling()
if __name__ == "__main__":
main()