Compare commits
7 Commits
1315cb294f
...
ef24032b68
| Author | SHA1 | Date | |
|---|---|---|---|
|
ef24032b68
|
|||
|
74bfe6c116
|
|||
|
930919bbae
|
|||
|
7e5a6c35e0
|
|||
|
c1854cc893
|
|||
|
933ab384e1
|
|||
|
41f1160fc3
|
@@ -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
|
||||||
|
|
||||||
|
|
||||||
@@ -321,7 +322,10 @@ async def breaks(interaction: discord.Interaction, days: int = 365) -> None:
|
|||||||
delete_invalidate()
|
delete_invalidate()
|
||||||
cleanup_invalidate()
|
cleanup_invalidate()
|
||||||
await interaction.response.defer(thinking=True)
|
await interaction.response.defer(thinking=True)
|
||||||
await interaction.response.send_message(str(DATABASE_CONN.query_breaks()))
|
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()
|
||||||
|
|||||||
@@ -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,6 +139,7 @@ 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)
|
||||||
@@ -184,6 +187,59 @@ class DBHelper():
|
|||||||
return
|
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 += "END 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