Add Dockerfile
This commit is contained in:
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
FROM archlinux
|
||||||
|
|
||||||
|
# Update Arch and install gcc, python and pip and remove cache
|
||||||
|
RUN pacman -Syu --noconfirm && pacman --noconfirm -S gcc python python-pip git && yes | pacman -Scc
|
||||||
|
|
||||||
|
# Copy requirements for the bot and install them
|
||||||
|
COPY requirements.txt /tmp/
|
||||||
|
RUN pip install --disable-pip-version-check --no-cache-dir --requirement /tmp/requirements.txt
|
||||||
|
|
||||||
|
# Create user
|
||||||
|
RUN useradd --create-home botuser
|
||||||
|
WORKDIR /home/botuser
|
||||||
|
USER botuser
|
||||||
|
|
||||||
|
RUN mkdir -p ~/data
|
||||||
|
|
||||||
|
# Copy bot and run
|
||||||
|
COPY main.py .
|
||||||
|
CMD ["python", "./main.py"]
|
6
Pipfile.lock
generated
6
Pipfile.lock
generated
@ -131,10 +131,10 @@
|
|||||||
},
|
},
|
||||||
"pytz": {
|
"pytz": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:3e6b7dd2d1e0a59084bcee14a17af60c5c562cdc16d828e8eba2e683d3a7e268",
|
"sha256:16962c5fb8db4a8f63a26646d8886e9d769b6c511543557bc84e9569fb9a9cb4",
|
||||||
"sha256:5c55e189b682d420be27c6995ba6edce0c0a77dd67bfbe2ae6607134d5851ffd"
|
"sha256:180befebb1927b16f6b57101720075a984c019ac16b1b7575673bea42c6c3da5"
|
||||||
],
|
],
|
||||||
"version": "==2020.4"
|
"version": "==2020.5"
|
||||||
},
|
},
|
||||||
"regex": {
|
"regex": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
18
docker-compose.yml
Normal file
18
docker-compose.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
discord-reminder-bot:
|
||||||
|
#image: thelovinator/discord-reminder-bot
|
||||||
|
build: .
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
container_name: discord-reminder-bot
|
||||||
|
environment:
|
||||||
|
- BOT_TOKEN=${BOT_TOKEN}
|
||||||
|
- TIMEZONE=${TIMEZONE}
|
||||||
|
- LOG_LEVEL=${LOG_LEVEL}
|
||||||
|
- SQLITE_LOCATION=/data/jobs.sqlite
|
||||||
|
# restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- data_folder:/home/botuser/data/
|
||||||
|
volumes:
|
||||||
|
data_folder:
|
19
main.py
19
main.py
@ -18,7 +18,6 @@ bot = commands.Bot(
|
|||||||
description="Reminder bot for Discord by TheLovinator#9276",
|
description="Reminder bot for Discord by TheLovinator#9276",
|
||||||
intents=intents,
|
intents=intents,
|
||||||
)
|
)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
@ -70,11 +69,12 @@ async def remind(ctx, message_date: str, message_reason: str):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
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 = f"Hello {ctx.message.author.name}, I will notify you at:\n" \
|
message = (
|
||||||
f"**{remove_timezone_from_date}**\n" \
|
f"Hello {ctx.message.author.name}, I will notify you at:\n"
|
||||||
f"With message:\n**{message_reason}**. "
|
f"**{remove_timezone_from_date}**\n"
|
||||||
logging.debug(f"Message we sent back to user in Discord:\n"
|
f"With message:\n**{message_reason}**. "
|
||||||
f"{message}")
|
)
|
||||||
|
logging.debug(f"Message we sent back to user in Discord:\n" f"{message}")
|
||||||
await ctx.send(message)
|
await ctx.send(message)
|
||||||
|
|
||||||
|
|
||||||
@ -91,6 +91,13 @@ if __name__ == "__main__":
|
|||||||
bot_token = os.getenv("BOT_TOKEN")
|
bot_token = os.getenv("BOT_TOKEN")
|
||||||
log_level = os.getenv(key="LOG_LEVEL", default="INFO")
|
log_level = os.getenv(key="LOG_LEVEL", default="INFO")
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.getLevelName(log_level))
|
||||||
|
|
||||||
|
logging.info(
|
||||||
|
f"\nsqlite_location = {sqlite_location}\nconfig_timezone = {config_timezone}\n"
|
||||||
|
f"bot_token = {bot_token}\nlog_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}
|
||||||
|
25
requirements.txt
Normal file
25
requirements.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#
|
||||||
|
# These requirements were autogenerated by pipenv
|
||||||
|
# To regenerate from the project's Pipfile, run:
|
||||||
|
#
|
||||||
|
# pipenv lock --requirements
|
||||||
|
#
|
||||||
|
|
||||||
|
-i https://pypi.org/simple
|
||||||
|
aiohttp==3.6.3; python_full_version >= '3.5.3'
|
||||||
|
apscheduler==3.6.3
|
||||||
|
async-timeout==3.0.1; python_full_version >= '3.5.3'
|
||||||
|
attrs==20.3.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||||
|
chardet==3.0.4
|
||||||
|
dateparser==1.0.0
|
||||||
|
discord.py==1.5.1
|
||||||
|
idna==2.10; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||||
|
multidict==4.7.6; python_version >= '3.5'
|
||||||
|
python-dateutil==2.8.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||||
|
python-dotenv==0.15.0
|
||||||
|
pytz==2020.5
|
||||||
|
regex==2020.11.13
|
||||||
|
six==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
|
||||||
|
sqlalchemy==1.3.22
|
||||||
|
tzlocal==2.1
|
||||||
|
yarl==1.5.1; python_version >= '3.5'
|
Reference in New Issue
Block a user