Use container from dockerhub
This commit is contained in:
@ -1,8 +1,7 @@
|
|||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
discord-reminder-bot:
|
discord-reminder-bot:
|
||||||
#image: thelovinator/discord-reminder-bot
|
image: thelovinator/discord-reminder-bot
|
||||||
build: .
|
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
container_name: discord-reminder-bot
|
container_name: discord-reminder-bot
|
||||||
@ -11,7 +10,7 @@ services:
|
|||||||
- TIMEZONE=${TIMEZONE}
|
- TIMEZONE=${TIMEZONE}
|
||||||
- LOG_LEVEL=${LOG_LEVEL}
|
- LOG_LEVEL=${LOG_LEVEL}
|
||||||
- SQLITE_LOCATION=/data/jobs.sqlite
|
- SQLITE_LOCATION=/data/jobs.sqlite
|
||||||
# restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- data_folder:/home/botuser/data/
|
- data_folder:/home/botuser/data/
|
||||||
volumes:
|
volumes:
|
||||||
|
17
main.py
17
main.py
@ -46,7 +46,8 @@ async def remind(ctx, message_date: str, message_reason: str):
|
|||||||
f"{message_date}",
|
f"{message_date}",
|
||||||
settings={"PREFER_DATES_FROM": "future"},
|
settings={"PREFER_DATES_FROM": "future"},
|
||||||
)
|
)
|
||||||
convert_date_to_our_timezone = parsed_date.astimezone(timezone(config_timezone))
|
convert_date_to_our_timezone = parsed_date.astimezone(
|
||||||
|
timezone(config_timezone))
|
||||||
remove_timezone_from_date = convert_date_to_our_timezone.strftime(
|
remove_timezone_from_date = convert_date_to_our_timezone.strftime(
|
||||||
"%Y-%m-%d %H:%M:%S"
|
"%Y-%m-%d %H:%M:%S"
|
||||||
)
|
)
|
||||||
@ -68,13 +69,14 @@ async def remind(ctx, message_date: str, message_reason: str):
|
|||||||
"author_id": ctx.message.author.id,
|
"author_id": ctx.message.author.id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
logging.debug(f"Job id: '{job.id}', name: '{job.name}' and kwargs: '{job.kwargs}'")
|
logging.debug(
|
||||||
|
f"Job id: '{job.id}', name: '{job.name}' and kwargs: '{job.kwargs}'")
|
||||||
message = (
|
message = (
|
||||||
f"Hello {ctx.message.author.name}, I will notify you at:\n"
|
f"Hello {ctx.message.author.name}, I will notify you at:\n"
|
||||||
f"**{remove_timezone_from_date}**\n"
|
f"**{remove_timezone_from_date}**\n"
|
||||||
f"With message:\n**{message_reason}**. "
|
f"With message:\n**{message_reason}**. "
|
||||||
)
|
)
|
||||||
logging.debug(f"Message we sent back to user in Discord:\n" f"{message}")
|
logging.debug(f"Message we sent back to user in Discord:\n {message}")
|
||||||
await ctx.send(message)
|
await ctx.send(message)
|
||||||
|
|
||||||
|
|
||||||
@ -94,12 +96,15 @@ if __name__ == "__main__":
|
|||||||
logging.basicConfig(level=logging.getLevelName(log_level))
|
logging.basicConfig(level=logging.getLevelName(log_level))
|
||||||
|
|
||||||
logging.info(
|
logging.info(
|
||||||
f"\nsqlite_location = {sqlite_location}\nconfig_timezone = {config_timezone}\n"
|
f"\nsqlite_location = {sqlite_location}\n"
|
||||||
f"bot_token = {bot_token}\nlog_level = {log_level}"
|
f"config_timezone = {config_timezone}\n"
|
||||||
|
f"bot_token = {bot_token}\n"
|
||||||
|
f"log_level = {log_level}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Advanced Python Scheduler
|
# Advanced Python Scheduler
|
||||||
jobstores = {"default": SQLAlchemyJobStore(url=f"sqlite://{sqlite_location}")}
|
jobstores = {"default": SQLAlchemyJobStore(
|
||||||
|
url=f"sqlite://{sqlite_location}")}
|
||||||
job_defaults = {"coalesce": True}
|
job_defaults = {"coalesce": True}
|
||||||
scheduler = AsyncIOScheduler(
|
scheduler = AsyncIOScheduler(
|
||||||
jobstores=jobstores,
|
jobstores=jobstores,
|
||||||
|
Reference in New Issue
Block a user