Compare commits

...
Author SHA1 Message Date
imcompiling 24ffb02869 Update CouncilMembers database with high council winners.
build_develop / build (push) Successful in 59s
2024-05-16 14:41:03 -04:00
imcompiling cb3eb4b09b Merge branch 'main' of https://gitea.cheezers.org/imcompiling/dakiny-bot
build_latest / build (push) Successful in 22s
build_release / build (push) Successful in 17s
build_develop / build (push) Successful in 22s
2024-05-16 09:19:11 -04:00
imcompiling c39e2c137b Merge branch '6-add-clan-rules' 2024-05-16 09:18:35 -04:00
imcompiling eedaf1c71f Don't need to refresh messages on bot start.
build_develop / build (push) Successful in 1m11s
2024-05-16 09:13:34 -04:00
imcompiling 70e4a84db3 Set uvicorn to listen on all addresses.
build_develop / build (push) Successful in 57s
2024-05-15 23:16:12 -04:00
imcompiling 443b92dfd3 Revert "Add expose to see if that fixes issue."
build_develop / build (push) Successful in 21s
This reverts commit e1be3218b3.
2024-05-15 20:43:19 -04:00
imcompiling 094a22f5e7 Update README.md
build_latest / build (push) Successful in 23s
2024-05-15 17:13:45 -04:00
4 changed files with 27 additions and 8 deletions
-3
View File
@@ -20,7 +20,4 @@ COPY database_setup database_setup/
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
# Expose to outside of container
EXPOSE 5000
CMD ["python3", "-u", "./main.py"] CMD ["python3", "-u", "./main.py"]
+5 -1
View File
@@ -1,5 +1,9 @@
# Dakiny Bot # Dakiny Bot
Bot assumes that it always did the step before it. If the step before an action didn't happen, behavior is undefined. Dakiny clan's own discord bot!
### Assumptions
- For Elections: Bot assumes that it always did the step before it. If the step before an action didn't happen, behavior is undefined.
Object creation in the middle of a cycle is only there for restarting the bot. All relevant information should already Object creation in the middle of a cycle is only there for restarting the bot. All relevant information should already
exist in the database. exist in the database.
+21 -2
View File
@@ -6,7 +6,7 @@ import collections
from datetime import datetime, timedelta from datetime import datetime, timedelta
import nextcord import nextcord
from sqlalchemy import select, true from sqlalchemy import select, true, update
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from classes.nominate_highcouncil_views import NominateHighCouncilView from classes.nominate_highcouncil_views import NominateHighCouncilView
@@ -388,15 +388,32 @@ class ElectionCycle:
stmt = select(Votes.VotedForId).where(Votes.ElectionCycle == cl_election) stmt = select(Votes.VotedForId).where(Votes.ElectionCycle == cl_election)
cl_votes = collections.Counter(session.scalars(stmt)) cl_votes = collections.Counter(session.scalars(stmt))
election_cycle = get_election_cycle_name(self.config)
try: try:
dm_winner = max(dm_votes, key=dm_votes.get) dm_winner = max(dm_votes, key=dm_votes.get)
stmt = (
update(CouncilMembers)
.where(CouncilMembers.ElectionCycle == election_cycle)
.where(CouncilMembers.MemberId == dm_winner)
.values(DiscordManager=True)
)
session.execute(stmt)
except ValueError: except ValueError:
dm_winner = "No winner" dm_winner = "No winner"
try: try:
cl_winner = max(cl_votes, key=cl_votes.get) cl_winner = max(cl_votes, key=cl_votes.get)
stmt = (
update(CouncilMembers)
.where(CouncilMembers.ElectionCycle == election_cycle)
.where(CouncilMembers.MemberId == cl_winner)
.values(ClanLeader=True)
)
session.execute(stmt)
except ValueError: except ValueError:
cl_winner = "No winner" cl_winner = "No winner"
session.commit()
election_thread: nextcord.Thread = self.guild.get_thread( election_thread: nextcord.Thread = self.guild.get_thread(
self.get_election_info().ThreadId self.get_election_info().ThreadId
) )
@@ -409,7 +426,9 @@ class ElectionCycle:
vote_msg: nextcord.Message = await election_thread.fetch_message(vote_msg_id) vote_msg: nextcord.Message = await election_thread.fetch_message(vote_msg_id)
await vote_msg.edit(view=None) await vote_msg.edit(view=None)
highcouncil_msg: str = f"Congratulations for our high council members!\n Clan Leader: <@{cl_winner}>\n" highcouncil_msg: str = (
f"Congratulations for our high council members!\n Clan Leader: <@{cl_winner}>\n"
)
highcouncil_msg += f"Discord Manager: <@{dm_winner}>" highcouncil_msg += f"Discord Manager: <@{dm_winner}>"
await election_thread.send(highcouncil_msg) await election_thread.send(highcouncil_msg)
+1 -2
View File
@@ -33,9 +33,8 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
""" """
Triggers when the bot is in ready state. Adds the webhook listener to FastAPI and serves. Triggers when the bot is in ready state. Adds the webhook listener to FastAPI and serves.
""" """
await self.update_messages()
app.add_api_route("/messages/", self.update_messages, methods=["POST"]) app.add_api_route("/messages/", self.update_messages, methods=["POST"])
config = uvicorn.Config(app=app, port=5000, log_level="info") config = uvicorn.Config(app=app, host="0.0.0.0", port=5000, log_level="info")
server = uvicorn.Server(config) server = uvicorn.Server(config)
await server.serve() await server.serve()