Files
discord-reminder-bot/discord_reminder_bot/settings.py
2021-07-26 21:08:08 +02:00

32 lines
1.1 KiB
Python

"""
This file loads settings from environment. You can also use the .env file.
You need to fill out bot_token and config_timezone.
bot_token is from https://discord.com/developers/applications
config_timezone is TZ database name. https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
sqlite_location is where the database should be saved, default is /jobs.sqlite
log_level can be CRITICAL, ERROR, WARNING, INFO or DEBUG, default is INFO.
"""
import os
import pytz
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from dotenv import load_dotenv
load_dotenv(verbose=True)
sqlite_location = os.getenv("SQLITE_LOCATION", default="/jobs.sqlite")
config_timezone = os.getenv("TIMEZONE", default="Europe/Stockholm")
bot_token = os.getenv("BOT_TOKEN")
log_level = os.getenv(key="LOG_LEVEL", default="INFO")
# Advanced Python Scheduler
jobstores = {"default": SQLAlchemyJobStore(url=f"sqlite://{sqlite_location}")}
job_defaults = {"coalesce": True}
scheduler = AsyncIOScheduler(
jobstores=jobstores,
timezone=pytz.timezone(config_timezone),
job_defaults=job_defaults,
)