Compare commits

...
Author SHA1 Message Date
imcompiling 8ff53d9a13 Grammar corrections.
build_develop / build (push) Has been cancelled
2023-10-05 14:26:15 -04:00
imcompiling 9609837b1d Control user reactions in election channel. 2023-10-05 14:24:33 -04:00
imcompiling 8cf66351dd Allow clan members to send messages to new channel.
build_develop / build (push) Has been cancelled
2023-09-20 20:14:32 -04:00
imcompiling a4c02b2f77 Change develop build to make a branch specific image.
build_latest / build (push) Successful in 1m27s
build_release / build (push) Successful in 45s
build_develop / build (push) Successful in 45s
2023-09-15 09:53:45 -04:00
imcompiling 8d8af9ab35 Change cakeday to be put in general channel. 2023-09-15 09:42:58 -04:00
imcompiling f70a7989ae Updated election_cycle init docstring.
build_develop / build (push) Successful in 1m24s
build_latest / build (push) Successful in 43s
2023-09-14 11:55:08 -04:00
imcompiling fb909c009a Quick bugfix for finding next election. Wouldn't happen in live, but better than hard coding. 2023-09-14 11:52:33 -04:00
imcompiling bdefa035ff Merge branch '25-cakeday'
build_latest / build (push) Successful in 44s
build_develop / build (push) Successful in 45s
build_release / build (push) Successful in 43s
2023-09-14 11:34:14 -04:00
imcompiling 85eb52d2e1 add word to message string.
build_develop / build (push) Successful in 1m31s
2023-09-14 11:33:27 -04:00
imcompiling 7d1b2f7cac Create cakedays function. 2023-09-14 11:24:25 -04:00
imcompiling c5c79015a9 Correct spelling. 2023-09-14 11:22:53 -04:00
imcompiling 7b335efbe6 Merge branch '22-daily-loop-not-starting-election'
build_latest / build (push) Successful in 44s
build_release / build (push) Successful in 43s
build_develop / build (push) Successful in 45s
2023-09-13 10:52:08 -04:00
imcompiling e686cf88e5 Be inclusive when checkign for an election cycle.
build_develop / build (push) Has been cancelled
2023-09-13 10:51:16 -04:00
imcompiling 117dea48c4 Standardize variable name of dates. 2023-09-13 10:42:01 -04:00
imcompiling 62e4417ce8 Use correct action on voting start. 2023-09-13 10:32:59 -04:00
imcompiling 672df41f19 Make the configs and timeline more clear. 2023-09-13 10:16:50 -04:00
imcompiling 328f3fea78 Merge branch 'main' into 22-daily-loop-not-starting-election 2023-09-13 09:31:53 -04:00
7 changed files with 76 additions and 38 deletions
+9 -3
View File
@@ -1,6 +1,10 @@
name: build_develop name: build_develop
on: [push] on:
push:
branches:
- '*'
- '!main'
jobs: jobs:
build: build:
@@ -18,7 +22,9 @@ jobs:
registry: gitea.cheezers.org registry: gitea.cheezers.org
username: imcompiling username: imcompiling
password: ${{ secrets.PASSWORD }} password: ${{ secrets.PASSWORD }}
- name: set env
run: echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
- name: Build Docker Image - name: Build Docker Image
run: docker build -t gitea.cheezers.org/imcompiling/dakiny-bot:develop . run: docker build -t gitea.cheezers.org/imcompiling/dakiny-bot:${{env.GIT_BRANCH}} .
- name: Push Docker Image - name: Push Docker Image
run: docker push gitea.cheezers.org/imcompiling/dakiny-bot:develop run: docker push gitea.cheezers.org/imcompiling/dakiny-bot:${{env.GIT_BRANCH}}
+8 -8
View File
@@ -34,16 +34,16 @@ The Clan Council will be denoted by the Discord ranks of <@&{clan_council_id}> a
<:Rank_Owner:479008325137072155> Clan Leader <:Rank_Owner:479008325137072155> Clan Leader
---message_break--- ---message_break---
__Here's the timeline:__ __Here's the timeline:__
Election begins: {election_start_date} Election begins: {election_start}
Term: {term_start_date} - {term_end_date} Term: {term_start} - {term_end}
**{election_start_date}**: Post here to announce candidacy **{election_start}**: Post here to announce candidacy
**{voting_start_date}**: Voting begins **{voting_start}**: Voting begins
**{voting_end_date}**: Votes are tallied and winners are announced **{voting_end}**: Votes are tallied and winners are announced
**{highcouncil_election_date}**: The new Clan Council votes who among them shall receive the two High Council positions of: Clan Leader and Discord Server Manager. **{highcouncil_election}**: The new Clan Council votes who among them shall receive the two High Council positions of: Clan Leader and Discord Server Manager.
**{term_start_date}**: The new Clan Council is officially inaugurated and a drop party (or a giveaway event) begins to commemorate the new leadership. **{term_start}**: The new Clan Council is officially inaugurated and a drop party (or a giveaway event) begins to commemorate the new leadership.
This process will begin again next quarter on {next_election_start_date} with the inauguration scheduled for {term_end_date}. This process will begin again next quarter on {next_election_start} with the inauguration scheduled for {term_end}.
---message_break--- ---message_break---
**You may now announce your candidacy for a seat on the Dakiny Clan Council! **You may now announce your candidacy for a seat on the Dakiny Clan Council!
** **
+2 -2
View File
@@ -8,6 +8,6 @@ From {highcouncil_election_announce} to {highcouncil_election_start}, you will b
Discord Server Manager Discord Server Manager
Each member of the CCE can cast one for each category by using the emotes: <:Rank_Owner:479008325137072155> for Clan Leader and <:Rank_Deputy:479008295319896064> for Discord Server Manager. Each member of the CCE can cast one for each category by using the emotes: <:Rank_Owner:479008325137072155> for Clan Leader and <:Rank_Deputy:479008295319896064> for Discord Server Manager.
If needed, the icon 🤷 can be used to abstain to vote in any or both categories and it should be apply to all candidates of that category. If needed, the icon 🤷 can be used to abstain to vote in any or both categories and it should be applied to all candidates of that category.
Votes can be cast until the {highcouncil_election_end}, so we can announce and have everyone set up to start the term by {term_start}. Votes can be cast until {highcouncil_election_end}, so we can announce and have everyone set up to start the term by {term_start}.
+1 -1
View File
@@ -2,7 +2,7 @@
<@&{clan_member_id}>, it's time to vote for clan council. <@&{clan_member_id}>, it's time to vote for clan council.
React with <{voting_emote_id}> to vote. React with <{voting_emote_id}> to vote.
Voting ends next {voting_end_day}, {voting_end_date}. Voting ends next {voting_end_day}, {voting_end}.
Results will then be announced. Results will then be announced.
After a candidate receives 3 votes, their spot is secured in the new council, but you can still vote for them to show your support. After a candidate receives 3 votes, their spot is secured in the new council, but you can still vote for them to show your support.
+28 -22
View File
@@ -2,7 +2,7 @@
Contains the election cycle class Contains the election cycle class
""" """
from datetime import datetime, timedelta from datetime import datetime
import nextcord import nextcord
from sqlalchemy import select from sqlalchemy import select
@@ -21,14 +21,14 @@ class ElectionCycle:
def __init__(self, cycle: int, config: DakinyConfig, guild: nextcord.Guild) -> None: def __init__(self, cycle: int, config: DakinyConfig, guild: nextcord.Guild) -> None:
""" """
Generates all dates relevant to the election cycle from input election start, term start and end dates. Generates all dates relevant to the election cycle determined by the config and cycle.
Args: Args:
election_start (datetime): Date the election cycle starts. cycle (int): Which election cycle this cycle is.
term_start (datetime): Date the term being elected starts. config (DakinyConfig): The entire config object.
term_end (datetime): Date the term being elected ends. guild (nextcord.Guild): The guild that this election is running in.
bot: the discord bot instance
""" """
self.config: DakinyConfig = config self.config: DakinyConfig = config
self.cycle = cycle self.cycle = cycle
self.elecion_cycle = self.config.election_cycles[self.cycle] self.elecion_cycle = self.config.election_cycles[self.cycle]
@@ -37,9 +37,9 @@ class ElectionCycle:
self.term_end: datetime = get_datetime(self.elecion_cycle.term_end) self.term_end: datetime = get_datetime(self.elecion_cycle.term_end)
self.voting_start: datetime = get_datetime(self.elecion_cycle.voting_start) self.voting_start: datetime = get_datetime(self.elecion_cycle.voting_start)
self.voting_end: datetime = get_datetime(self.elecion_cycle.voting_end) self.voting_end: datetime = get_datetime(self.elecion_cycle.voting_end)
self.highcouncil_election_announce: datetime = self.voting_end + timedelta(days=1) self.highcouncil_election_announce: datetime = get_datetime(self.elecion_cycle.highcouncil_election_announce)
self.highcouncil_election_start: datetime = self.highcouncil_election_announce + timedelta(days=3) self.highcouncil_election_start: datetime = get_datetime(self.elecion_cycle.highcouncil_election_start)
self.highcouncil_election_end: datetime = self.term_start - timedelta(days=1) self.highcouncil_election_end: datetime = get_datetime(self.elecion_cycle.highcouncil_election_end)
self.guild: nextcord.Guild = guild self.guild: nextcord.Guild = guild
self.election_over: bool = False self.election_over: bool = False
@@ -55,18 +55,20 @@ class ElectionCycle:
with open("bot_messages/election_announcement.txt", mode="r", encoding="utf8") as file: with open("bot_messages/election_announcement.txt", mode="r", encoding="utf8") as file:
message = file.read() message = file.read()
next_election = get_datetime(self.config.election_cycles[(self.cycle + 1) % 4].election_start) next_election = get_datetime(
self.config.election_cycles[(self.cycle + 1) % len(self.config.election_cycles)].election_start
)
message = message.format( message = message.format(
clan_council_id=self.config.params.clan_council_role_id, clan_council_id=self.config.params.clan_council_role_id,
high_council_id=self.config.params.high_council_role_id, high_council_id=self.config.params.high_council_role_id,
election_start_date=self.election_start.strftime("%B %d"), election_start=self.election_start.strftime("%B %d"),
term_start_date=self.term_start.strftime("%B %d"), term_start=self.term_start.strftime("%B %d"),
term_end_date=self.term_end.strftime("%B %d"), term_end=self.term_end.strftime("%B %d"),
voting_start_date=self.voting_start.strftime("%B %d"), voting_start=self.voting_start.strftime("%B %d"),
voting_end_date=self.voting_end.strftime("%B %d"), voting_end=self.voting_end.strftime("%B %d"),
highcouncil_election_date=self.highcouncil_election_start.strftime("%B %d"), highcouncil_election=self.highcouncil_election_start.strftime("%B %d"),
next_election_start_date=next_election.strftime("%B %d"), next_election_start=next_election.strftime("%B %d"),
) )
return message.split("---message_break---") return message.split("---message_break---")
@@ -87,7 +89,7 @@ class ElectionCycle:
highcouncil_election_announce=self.highcouncil_election_announce.strftime("%B %d"), highcouncil_election_announce=self.highcouncil_election_announce.strftime("%B %d"),
highcouncil_election_start=self.highcouncil_election_start.strftime("%B %d"), highcouncil_election_start=self.highcouncil_election_start.strftime("%B %d"),
highcouncil_election_end=self.highcouncil_election_end.strftime("%B %d"), highcouncil_election_end=self.highcouncil_election_end.strftime("%B %d"),
term_start_date=self.term_start.strftime("%B %d"), term_start=self.term_start.strftime("%B %d"),
) )
def build_highcouncil_vote_start(self) -> str: def build_highcouncil_vote_start(self) -> str:
@@ -103,7 +105,7 @@ class ElectionCycle:
return message.format( return message.format(
clan_council_elect_role_id=self.config.params.clan_council_elect_role_id, clan_council_elect_role_id=self.config.params.clan_council_elect_role_id,
term_start_date=self.term_start.strftime("%B %d"), term_start=self.term_start.strftime("%B %d"),
) )
def build_vote_start(self) -> str: def build_vote_start(self) -> str:
@@ -121,7 +123,7 @@ class ElectionCycle:
return message.format( return message.format(
clan_member_id=self.config.params.clan_member_role_id, clan_member_id=self.config.params.clan_member_role_id,
voting_emote_id=self.config.params.voting_emote_id, voting_emote_id=self.config.params.voting_emote_id,
voting_end_date=vote_end.strftime("%B %d"), voting_end=vote_end.strftime("%B %d"),
voting_end_day=vote_end.strftime("%A"), voting_end_day=vote_end.strftime("%A"),
) )
@@ -135,7 +137,7 @@ class ElectionCycle:
if today.date() == self.election_start.date(): if today.date() == self.election_start.date():
await self.election_start_action() await self.election_start_action()
elif today.date() == self.voting_start.date(): elif today.date() == self.voting_start.date():
await self.voting_end_action() await self.voting_start_action()
elif today.date() == self.voting_end.date(): elif today.date() == self.voting_end.date():
await self.voting_end_action() await self.voting_end_action()
elif today.date() == self.highcouncil_election_start.date(): elif today.date() == self.highcouncil_election_start.date():
@@ -153,6 +155,8 @@ class ElectionCycle:
# create new entry into database. # create new entry into database.
election_channel: nextcord.TextChannel = await category.create_text_channel(quarter_name) election_channel: nextcord.TextChannel = await category.create_text_channel(quarter_name)
clan_member_role: nextcord.Role = self.guild.get_role(self.config.params.clan_member_role_id)
await election_channel.set_permissions(clan_member_role, send_messages=True, add_reactions=True)
with Session(engine) as session: with Session(engine) as session:
new_cycle = ElectionInformation(ElectionCycle=quarter_name, ElectionChannel=election_channel.id) new_cycle = ElectionInformation(ElectionCycle=quarter_name, ElectionChannel=election_channel.id)
session.add(new_cycle) session.add(new_cycle)
@@ -184,8 +188,10 @@ class ElectionCycle:
message = self.build_highcouncil_election_announce() message = self.build_highcouncil_election_announce()
council_elect_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_elect_role_id) council_elect_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_elect_role_id)
election_channel: nextcord.TextChannel = self.guild.get_channel(self.get_election_info().ElectionChannel) election_channel: nextcord.TextChannel = self.guild.get_channel(self.get_election_info().ElectionChannel)
clan_member_role: nextcord.Role = self.guild.get_role(self.config.params.clan_member_role_id)
await election_channel.send(message) await election_channel.send(message)
await election_channel.set_permissions(council_elect_role, send_messages=True) await election_channel.set_permissions(council_elect_role, send_messages=True, add_reactions=True)
await election_channel.set_permissions(clan_member_role, add_reactions=False)
async def highcouncil_election_start_action(self) -> None: async def highcouncil_election_start_action(self) -> None:
""" """
+23 -1
View File
@@ -54,6 +54,8 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
kandy: nextcord.User = await self.bot.fetch_user(239547993106284544) kandy: nextcord.User = await self.bot.fetch_user(239547993106284544)
await kandy.send('Happy "Birthday"!') await kandy.send('Happy "Birthday"!')
await self.cakedays()
@daily_loop.before_loop @daily_loop.before_loop
async def before_loop(self): async def before_loop(self):
""" """
@@ -81,7 +83,7 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
for cycle, election in enumerate(config.election_cycles): for cycle, election in enumerate(config.election_cycles):
if ( if (
today.date() >= get_datetime(election.election_start).date() today.date() >= get_datetime(election.election_start).date()
and today.date() < get_datetime(election.term_start).date() and today.date() <= get_datetime(election.term_start).date()
): ):
current_election = ElectionCycle(cycle, config, self.bot.get_guild(config.params.guild_id)) current_election = ElectionCycle(cycle, config, self.bot.get_guild(config.params.guild_id))
@@ -104,3 +106,23 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
with Session(engine) as session: with Session(engine) as session:
to_add = session.scalars(stmt) to_add = session.scalars(stmt)
birthday_list.extend(to_add.all()) birthday_list.extend(to_add.all())
async def cakedays(self) -> None:
"""
Loops through the guild's humans checking for joined_at dates that match today's date. Sends a message
saying happy cakeday.
"""
today = datetime.today()
guild: nextcord.Guild = self.bot.get_guild(self.bot.config.params.guild_id)
announce_channel: nextcord.TextChannel = guild.get_channel(self.bot.config.params.general_channel_id)
cakedays: list[nextcord.Member] = [
human for human in guild.humans if human.joined_at.month == today.month and human.joined_at.day == today.day
]
for member in cakedays:
years = today.year - member.joined_at.year
year_str = "years" if years > 1 else "year"
msg = f"Happy Cake day! <@{member.id}> joined the discord {years} {year_str} ago!"
await announce_channel.send(msg)
+5 -1
View File
@@ -12,13 +12,14 @@ class Params:
active_category_id: int active_category_id: int
admin_channel_id: int # might want to rename this... admin_channel_id: int # might want to rename this...
annoucement_category_id: int announcement_category_id: int
archive_channel_group_id: int archive_channel_group_id: int
clan_council_elect_role_id: int clan_council_elect_role_id: int
clan_council_role_id: int clan_council_role_id: int
clan_info_channel_id: int clan_info_channel_id: int
clan_member_role_id: int clan_member_role_id: int
discord_token: str discord_token: str
general_channel_id: int
guild_id: int guild_id: int
high_council_role_id: int high_council_role_id: int
voting_emote_id: str voting_emote_id: str
@@ -31,6 +32,9 @@ class ElectionCycle:
""" """
election_start: str election_start: str
highcouncil_election_announce: str
highcouncil_election_end: str
highcouncil_election_start: str
name: str name: str
term_end: str term_end: str
term_start: str term_start: str