Compare commits
28 Commits
contributi
...
67c4b01424
| Author | SHA1 | Date | |
|---|---|---|---|
| 67c4b01424 | |||
| a8a8f81cb3 | |||
|
4a8a947de5
|
|||
|
45401614d5
|
|||
|
1212821d92
|
|||
|
4bb8c26c6c
|
|||
|
6918f36f1a
|
|||
| 733563d243 | |||
| a32eb42998 | |||
|
bbe1c0aec6
|
|||
| 16d760f2f4 | |||
|
33e5df4dfe
|
|||
|
ef24032b68
|
|||
|
74bfe6c116
|
|||
|
930919bbae
|
|||
|
7e5a6c35e0
|
|||
|
c1854cc893
|
|||
|
933ab384e1
|
|||
|
41f1160fc3
|
|||
|
1315cb294f
|
|||
|
090d370ce1
|
|||
|
97a3ae22fa
|
|||
|
9b7c70576b
|
|||
|
aca7358af8
|
|||
|
6b2421e55c
|
|||
|
5b58c6e8ea
|
|||
|
26276b0989
|
|||
|
a928fa54d4
|
25
.github/workflows/deploy.yaml
vendored
25
.github/workflows/deploy.yaml
vendored
@@ -10,28 +10,19 @@ jobs:
|
|||||||
# test locally on the runner, using miniconda
|
# test locally on the runner, using miniconda
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
defaults:
|
||||||
matrix:
|
run:
|
||||||
python-version: [3.11.5]
|
shell: bash -el {0}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: https://github.com/actions/checkout@v4.1.1
|
- uses: https://github.com/actions/checkout@v4.1.1
|
||||||
- name: Set up conda /w python version 3.11.5
|
|
||||||
uses: https://github.com/conda-incubator/setup-miniconda@v3.0.2
|
- name: Setup Poetry
|
||||||
with:
|
uses: Gr1N/setup-poetry@v9
|
||||||
miniconda-version: "latest"
|
|
||||||
activate-environment: raid-callouts
|
|
||||||
environment-file: environment.yml
|
|
||||||
python-version: 3.11.5
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
shell: bash -l {0}
|
shell: bash -l {0}
|
||||||
run: |
|
run: |
|
||||||
conda env create --file environment.yml -n test-helper-module
|
poetry instsall
|
||||||
conda init
|
|
||||||
conda activate test-helper-module
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
- name: add database.ini
|
- name: add database.ini
|
||||||
shell: bash -l {0}
|
shell: bash -l {0}
|
||||||
@@ -44,7 +35,7 @@ jobs:
|
|||||||
shell: bash -l {0}
|
shell: bash -l {0}
|
||||||
run: |
|
run: |
|
||||||
conda activate test-helper-module
|
conda activate test-helper-module
|
||||||
python -m pytest src/py/db_helper_tests.py
|
poetry run python -m pytest src/py/db_helper_tests.py
|
||||||
|
|
||||||
# Checkout the repo, add the dependency files, push to host, build + run (via docker compose up)
|
# Checkout the repo, add the dependency files, push to host, build + run (via docker compose up)
|
||||||
push-and-build:
|
push-and-build:
|
||||||
|
|||||||
22
.github/workflows/test.yaml
vendored
22
.github/workflows/test.yaml
vendored
@@ -15,29 +15,16 @@ jobs:
|
|||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash -el {0}
|
shell: bash -el {0}
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: [3.11.5]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: https://github.com/actions/checkout@v4.1.1
|
- uses: https://github.com/actions/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Set up conda /w python version 3.11.5
|
- name: Setup Poetry
|
||||||
uses: https://github.com/conda-incubator/setup-miniconda@v3.0.4
|
uses: Gr1N/setup-poetry@v9
|
||||||
with:
|
|
||||||
miniconda-version: "latest"
|
|
||||||
activate-environment: raid-callouts
|
|
||||||
environment-file: environment.yml
|
|
||||||
python-version: 3.11.5
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
shell: bash -l {0}
|
shell: bash -l {0}
|
||||||
run: |
|
run: |
|
||||||
conda env create --file environment.yml -n test-helper-module
|
poetry install
|
||||||
conda init
|
|
||||||
conda activate test-helper-module
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
- name: add database.ini
|
- name: add database.ini
|
||||||
shell: bash -l {0}
|
shell: bash -l {0}
|
||||||
@@ -50,5 +37,4 @@ jobs:
|
|||||||
shell: bash -l {0}
|
shell: bash -l {0}
|
||||||
run: |
|
run: |
|
||||||
cd $GITHUB_WORKSPACE
|
cd $GITHUB_WORKSPACE
|
||||||
conda activate test-helper-module
|
poetry run python -m pytest ./src/py/db_helper_tests.py
|
||||||
python -m pytest ./src/py/db_helper_tests.py
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
|
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
|
||||||
|
|
||||||
ARG PYTHON_VERSION=3.11.5
|
ARG PYTHON_VERSION=3.11.5
|
||||||
FROM python:${PYTHON_VERSION}-slim as base
|
FROM ubuntu:latest AS base
|
||||||
|
|
||||||
# Prevents Python from writing pyc files.
|
# Prevents Python from writing pyc files.
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
@@ -21,33 +21,20 @@ ENV TZ="America/Detroit"
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create a non-privileged user that the app will run under.
|
# update package list
|
||||||
# See https://docs.docker.com/go/dockerfile-user-best-practices/
|
RUN apt-get update
|
||||||
ARG UID=10001
|
|
||||||
RUN adduser \
|
|
||||||
--disabled-password \
|
|
||||||
--gecos "" \
|
|
||||||
--home "/nonexistent" \
|
|
||||||
--shell "/sbin/nologin" \
|
|
||||||
--no-create-home \
|
|
||||||
--uid "${UID}" \
|
|
||||||
appuser
|
|
||||||
|
|
||||||
# Download dependencies as a separate step to take advantage of Docker's caching.
|
# install python, pipx
|
||||||
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
RUN apt-get install -y wget python3 pipx
|
||||||
# Leverage a bind mount to requirements.txt to avoid having to copy them into
|
|
||||||
# into this layer.
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
||||||
--mount=type=bind,source=requirements.txt,target=requirements.txt \
|
|
||||||
python -m pip install -r requirements.txt
|
|
||||||
|
|
||||||
# Switch to the non-privileged user to run the application.
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
# Copy the source code into the container.
|
# Copy the source code into the container.
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# install poetry via pipx
|
||||||
|
RUN pipx install poetry && pipx ensurepath
|
||||||
|
RUN ~/.local/bin/poetry install
|
||||||
|
|
||||||
# Expose the port that the application listens on.
|
# Expose the port that the application listens on.
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
CMD ["python3", "src/py/bot_aux.py", "xiv-database.ini", "xiv-discord.token", "865781604881530940", "888844785274724362"]
|
CMD ~/.local/bin/poetry run python3 src/py/bot_aux.py xiv-database.ini xiv-discord.token 865781604881530940 888844785274724362
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
|
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
|
||||||
|
|
||||||
ARG PYTHON_VERSION=3.11.5
|
ARG PYTHON_VERSION=3.11.5
|
||||||
FROM python:${PYTHON_VERSION}-slim as base
|
FROM ubuntu:latest AS base
|
||||||
|
|
||||||
# Prevents Python from writing pyc files.
|
# Prevents Python from writing pyc files.
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
@@ -21,33 +21,20 @@ ENV TZ="America/Detroit"
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create a non-privileged user that the app will run under.
|
# update package list
|
||||||
# See https://docs.docker.com/go/dockerfile-user-best-practices/
|
RUN apt-get update
|
||||||
ARG UID=10001
|
|
||||||
RUN adduser \
|
|
||||||
--disabled-password \
|
|
||||||
--gecos "" \
|
|
||||||
--home "/nonexistent" \
|
|
||||||
--shell "/sbin/nologin" \
|
|
||||||
--no-create-home \
|
|
||||||
--uid "${UID}" \
|
|
||||||
appuser
|
|
||||||
|
|
||||||
# Download dependencies as a separate step to take advantage of Docker's caching.
|
# install python, pipx
|
||||||
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
RUN apt-get install -y wget python3 pipx
|
||||||
# Leverage a bind mount to requirements.txt to avoid having to copy them into
|
|
||||||
# into this layer.
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
||||||
--mount=type=bind,source=requirements.txt,target=requirements.txt \
|
|
||||||
python -m pip install -r requirements.txt
|
|
||||||
|
|
||||||
# Switch to the non-privileged user to run the application.
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
# Copy the source code into the container.
|
# Copy the source code into the container.
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# install poetry via pipx
|
||||||
|
RUN pipx install poetry && pipx ensurepath
|
||||||
|
RUN ~/.local/bin/poetry install
|
||||||
|
|
||||||
# Expose the port that the application listens on.
|
# Expose the port that the application listens on.
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
CMD ["python3", "src/py/bot_core.py", "xiv-database.ini", "xiv-discord.token", "865781604881530940", "888844785274724362"]
|
CMD ["poetry", "run", "python3", "src/py/bot_core.py", "xiv-database.ini", "xiv-discord.token", "865781604881530940", "888844785274724362"]
|
||||||
|
|||||||
1248
poetry.lock
generated
Normal file
1248
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
pyproject.toml
Normal file
24
pyproject.toml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
package-mode = false
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "raid-callouts"
|
||||||
|
version = "0.3.2"
|
||||||
|
description = ""
|
||||||
|
authors = [
|
||||||
|
{name = "Gabriella Agathon",email = "gstimac@msudenver.edu"}
|
||||||
|
]
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.11.5"
|
||||||
|
dependencies = [
|
||||||
|
"psycopg2-binary (==2.9.11)",
|
||||||
|
"discord.py (==2.4.0)",
|
||||||
|
"pytest (==8.2.2)",
|
||||||
|
"pylint (==3.2.6)",
|
||||||
|
"requests (==2.32.5)"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
@@ -6,7 +6,6 @@ This automation will be run on a daily basis, through a cron job + docker.
|
|||||||
@author: Gabriella 'contrastellar' Agathon
|
@author: Gabriella 'contrastellar' Agathon
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
|
||||||
import discord
|
import discord
|
||||||
import helper.db_helper
|
import helper.db_helper
|
||||||
|
|
||||||
@@ -37,11 +36,22 @@ async def on_ready():
|
|||||||
|
|
||||||
print(f'{client.user} has connected.')
|
print(f'{client.user} has connected.')
|
||||||
print(args.guild_id)
|
print(args.guild_id)
|
||||||
|
|
||||||
guild: discord.Guild = client.get_guild(args.guild_id)
|
guild: discord.Guild = client.get_guild(args.guild_id)
|
||||||
channel: discord.TextChannel = guild.get_channel(args.channel_id)
|
channel: discord.TextChannel = guild.get_channel(args.channel_id)
|
||||||
|
|
||||||
callouts = DATABASE_CONN.query_callouts(NUMBER_OF_DAYS)
|
callouts = DATABASE_CONN.query_callouts(NUMBER_OF_DAYS)
|
||||||
formatted_callouts = DATABASE_CONN.formatted_list_of_callouts(callouts)
|
formatted_callouts = DATABASE_CONN.formatted_list_of_callouts(callouts)
|
||||||
output = f'Callouts for the next {NUMBER_OF_DAYS} days:\n' + formatted_callouts
|
output = f'Callouts for the next {NUMBER_OF_DAYS} days:\n' + formatted_callouts
|
||||||
|
output += '\n\n'
|
||||||
|
|
||||||
|
output += f'Breaks for the next {NUMBER_OF_DAYS} days:\n'
|
||||||
|
|
||||||
|
breaks: str = DATABASE_CONN.query_breaks(NUMBER_OF_DAYS)
|
||||||
|
formatted_breaks: str = DATABASE_CONN.formatted_list_of_breaks(breaks)
|
||||||
|
|
||||||
|
output += formatted_breaks
|
||||||
|
|
||||||
await channel.send(output)
|
await channel.send(output)
|
||||||
await client.close() # Another way to exit, a little bit cleaner than exit(0)
|
await client.close() # Another way to exit, a little bit cleaner than exit(0)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ async def ping(interaction: discord.Interaction) -> None:
|
|||||||
delete_invalidate()
|
delete_invalidate()
|
||||||
cleanup_invalidate()
|
cleanup_invalidate()
|
||||||
user_id = interaction.user.id
|
user_id = interaction.user.id
|
||||||
await interaction.response.send_message(f'Pong! {user_id} -- the bot is active, please message contrastellar with issues!')
|
charname = DATABASE_CONN.return_char_name(uid=user_id)
|
||||||
|
await interaction.response.send_message(f'Pong! {charname} -- the bot is active, please message contrastellar with issues!')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@@ -287,6 +288,24 @@ async def remove_callout(interaction: discord.Interaction, day: int, month: int,
|
|||||||
await interaction.response.send_message(f'{user_char_name} removed a callout for {callout_date}')
|
await interaction.response.send_message(f'{user_char_name} removed a callout for {callout_date}')
|
||||||
|
|
||||||
|
|
||||||
|
@client.tree.command()
|
||||||
|
async def remove_break(interaction: discord.Interaction, day: int, month: int, year: int) -> None:
|
||||||
|
delete_invalidate()
|
||||||
|
cleanup_invalidate()
|
||||||
|
user_id = interaction.user.id
|
||||||
|
user_char_name = DATABASE_CONN.return_char_name(user_id)
|
||||||
|
break_date: datetime.date = datetime.date(year=year, month=month, day=day)
|
||||||
|
|
||||||
|
try:
|
||||||
|
DATABASE_CONN.remove_break(user_id=user_id, break_date=break_date)
|
||||||
|
except psycopg2.Error:
|
||||||
|
await interaction.response.send_message(f'{user_char_name} -- no break was added for {break_date}')
|
||||||
|
else:
|
||||||
|
await interaction.response.send_message(f'{user_char_name} -- you removed the break starting on {break_date}')
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
@client.tree.command()
|
@client.tree.command()
|
||||||
async def schedule(interaction: discord.Interaction, days: int = DAYS_FOR_CALLOUTS) -> None:
|
async def schedule(interaction: discord.Interaction, days: int = DAYS_FOR_CALLOUTS) -> None:
|
||||||
delete_invalidate()
|
delete_invalidate()
|
||||||
@@ -297,6 +316,18 @@ async def schedule(interaction: discord.Interaction, days: int = DAYS_FOR_CALLOU
|
|||||||
await interaction.followup.send(f'Callouts for the next {days} days:\n{callouts}')
|
await interaction.followup.send(f'Callouts for the next {days} days:\n{callouts}')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@client.tree.command()
|
||||||
|
async def breaks(interaction: discord.Interaction, days: int = 365) -> None:
|
||||||
|
delete_invalidate()
|
||||||
|
cleanup_invalidate()
|
||||||
|
await interaction.response.defer(thinking=True)
|
||||||
|
breaks: list = DATABASE_CONN.query_breaks(days=days)
|
||||||
|
break_output: str = DATABASE_CONN.format_list_of_breaks(breaks=breaks)
|
||||||
|
await interaction.followup.send(f'Breaks for the next {days} days:\n{break_output}')
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
@client.tree.command()
|
@client.tree.command()
|
||||||
async def self_callouts(interaction: discord.Interaction, days: int = 365) -> None:
|
async def self_callouts(interaction: discord.Interaction, days: int = 365) -> None:
|
||||||
delete_invalidate()
|
delete_invalidate()
|
||||||
|
|||||||
@@ -58,4 +58,12 @@ class TestClass():
|
|||||||
formatted_callouts = self.DATABASE_CONN.format_list_of_callouts(callouts=callouts)
|
formatted_callouts = self.DATABASE_CONN.format_list_of_callouts(callouts=callouts)
|
||||||
assert formatted_callouts.__class__ is str
|
assert formatted_callouts.__class__ is str
|
||||||
|
|
||||||
# TODO write tests for the break addition/removal
|
def test_add_break(self) -> None:
|
||||||
|
today: datetime.date = datetime.date.today()
|
||||||
|
new_break = self.DATABASE_CONN.add_break(user_id=1, break_start=today, break_end=today)
|
||||||
|
assert new_break is None
|
||||||
|
|
||||||
|
def test_remove_break(self) -> None:
|
||||||
|
today: datetime.date = datetime.date.today()
|
||||||
|
remove_break = self.DATABASE_CONN.remove_break(user_id=1, start_date=today)
|
||||||
|
assert remove_break is None
|
||||||
|
|||||||
@@ -100,15 +100,17 @@ class DBHelper():
|
|||||||
|
|
||||||
return cursor.fetchall()
|
return cursor.fetchall()
|
||||||
|
|
||||||
def query_breaks(self) -> list:
|
|
||||||
|
def query_breaks(self, days) -> list:
|
||||||
self.__CONN = connect_config(self._config)
|
self.__CONN = connect_config(self._config)
|
||||||
self.__CONN.autocommit = True
|
self.__CONN.autocommit = True
|
||||||
cursor = self.__CONN.cursor()
|
cursor = self.__CONN.cursor()
|
||||||
cursor.execute(f"SELECT * FROM breaks")
|
cursor.execute(f"SELECT * FROM breaks WHERE open_range >= NOW() - INTERVAL '1 day' and open_range <= NOW() + interval '{days} days' ORDER BY open_range ASC;")
|
||||||
self.__CONN.commit()
|
self.__CONN.commit()
|
||||||
|
|
||||||
return cursor.fetchall()
|
return cursor.fetchall()
|
||||||
|
|
||||||
|
|
||||||
def query_self_callouts(self, user_id: int, days: int = 365):
|
def query_self_callouts(self, user_id: int, days: int = 365):
|
||||||
self.__CONN = connect_config(self._config)
|
self.__CONN = connect_config(self._config)
|
||||||
self.__CONN.autocommit = True
|
self.__CONN.autocommit = True
|
||||||
@@ -137,16 +139,18 @@ class DBHelper():
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def add_break(self, user_id: int, break_start: datetime.date, break_end: datetime.date) -> None:
|
def add_break(self, user_id: int, break_start: datetime.date, break_end: datetime.date) -> None:
|
||||||
|
|
||||||
self.__CONN = connect_config(self._config)
|
self.__CONN = connect_config(self._config)
|
||||||
self.__CONN.autocommit = True
|
self.__CONN.autocommit = True
|
||||||
cursor = self.__CONN.cursor()
|
cursor = self.__CONN.cursor()
|
||||||
is_range: int = 1
|
is_range: bool = True
|
||||||
if break_start == break_end:
|
if break_start == break_end:
|
||||||
is_range = 0
|
is_range = False
|
||||||
cursor.execute("INSERT INTO breaks (created_user, is_range, open_range, close_range) VALUES (%s, %s, %s, %s)", (user_id, is_range, break_start, break_end))
|
cursor.execute("INSERT INTO breaks (created_user, is_range, open_range, close_range) VALUES (%s, %s, %s, %s)", (user_id, is_range, break_start, break_end))
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def remove_callout(self, user_id: int, callout: datetime.date) -> None:
|
def remove_callout(self, user_id: int, callout: datetime.date) -> None:
|
||||||
@@ -166,6 +170,76 @@ class DBHelper():
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def remove_break(self, user_id: int, start_date: datetime.date) -> None:
|
||||||
|
"""Remove a callout based on user + date, which form the primary key in the db
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (int): The Discord UUID of the user removing something from the db
|
||||||
|
callout (datetime.datetime): The date of the callout
|
||||||
|
"""
|
||||||
|
self.__CONN = connect_config(self._config)
|
||||||
|
self.__CONN.autocommit = True
|
||||||
|
cursor = self.__CONN.cursor()
|
||||||
|
|
||||||
|
cursor.execute("DELETE FROM breaks WHERE created_user = %s AND open_range = %s", (user_id, start_date))
|
||||||
|
self.__CONN.commit()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def formatted_list_of_breaks(self, breaks: list) -> str:
|
||||||
|
"""Format the python list of breaks.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
breaks (list): The list that needs to be formatted
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: the list as an outputtable string
|
||||||
|
"""
|
||||||
|
length = len(breaks)
|
||||||
|
output: str = ''
|
||||||
|
|
||||||
|
if length == 0:
|
||||||
|
return 'No breaks have been scheduled!'
|
||||||
|
|
||||||
|
for entry in breaks:
|
||||||
|
|
||||||
|
for item in range(4):
|
||||||
|
if item == 0:
|
||||||
|
output += f"Break submitted by: {self.return_char_name(entry[0])}"
|
||||||
|
|
||||||
|
if item == 1:
|
||||||
|
# is_range boolean
|
||||||
|
if entry[1] == True:
|
||||||
|
# if it is a range, format as a range
|
||||||
|
output += f' • Break from: {entry[2]} until... '
|
||||||
|
|
||||||
|
else:
|
||||||
|
# if it is not a range, format as a single date
|
||||||
|
output += f' • We are taking a break on: {entry[2]}'
|
||||||
|
|
||||||
|
if item == 2:
|
||||||
|
if entry[1] == True:
|
||||||
|
output += f'{entry[3]}.\n'
|
||||||
|
else:
|
||||||
|
output += '\n'
|
||||||
|
|
||||||
|
output += "\nEND OF MESSAGE"
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
def format_list_of_breaks(self, breaks: list) -> str:
|
||||||
|
"""Format the list of breaks
|
||||||
|
|
||||||
|
Args:
|
||||||
|
breaks (list): The list that needs to be formatted
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: The formatted list to the bot_core or bot_aux
|
||||||
|
"""
|
||||||
|
return self.formatted_list_of_breaks(breaks=breaks)
|
||||||
|
|
||||||
|
|
||||||
def formatted_list_of_callouts(self, callouts: list) -> str:
|
def formatted_list_of_callouts(self, callouts: list) -> str:
|
||||||
"""Format the python list of callouts.
|
"""Format the python list of callouts.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user