Fill out more of the update message method.

This commit is contained in:
2024-05-14 18:15:58 -04:00
parent 9ab4d9e339
commit a1f955abbe
+13 -5
View File
@@ -31,9 +31,8 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
await server.serve()
async def hello(self):
print("we did a webhook")
await self.update_messages()
return {"message": "webhook get"}
return
async def update_messages(self):
"""
@@ -46,15 +45,24 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
# posting involves checking if there is a message for that particular file then editing it or creating a
# new one. the message could be deleted, which would cause a new message to be sent and database updated.
dirs = [
f"{MESSAGES_DIR}/{dir_name}"
dir_name
for dir_name in os.listdir(MESSAGES_DIR)
if os.path.isdir(f"{MESSAGES_DIR}/{dir_name}")
]
for dir_name in dirs:
dir_path = f"{MESSAGES_DIR}/{dir_name}"
sorted_files = sorted(
os.listdir(dir_name), key=lambda filename: int(filename.split(".")[0])
os.listdir(dir_path), key=lambda filename: int(filename.split(".")[0])
)
print(sorted_files)
for file_name in sorted_files:
file_path = f"{dir_path}/{file_name}"
with open(file_path, "r", encoding="utf8") as reader:
print(reader.read(2000))
# get the channel from dir_name
# if doesn't exist, make one
# write or edit message
# save message id if written
def repo_setup(self):
"""