Skip to content

Commit

Permalink
Sub Rosa Tracker (#529)
Browse files Browse the repository at this point in the history
* Food War style Sub Rosa tracker

* finishing up

* share the assets

* add additional stats

* tweaks, final
  • Loading branch information
zmattingly committed May 26, 2024
1 parent db81a0d commit 7fe5bf2
Show file tree
Hide file tree
Showing 80 changed files with 405 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ images/ep*
images/food_war/*.gif
images/food_war/*.png
images/slot_results/*.png
images/sub_rosa/*.gif
images/sub_rosa/*.png
images/tongo/*.png
images/trades/*.png
images/scrap/*.gif
Expand Down
4 changes: 2 additions & 2 deletions charts/agimus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: agimus
description: A helm chart for a discord bot that also runs a mysql db
type: application
version: v2.8.6
appVersion: v2.8.6
version: v2.8.7
appVersion: v2.8.7
43 changes: 38 additions & 5 deletions commands/food_war.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async def reset(ctx:discord.ApplicationContext, reason:str):
await ctx.defer()

previous_reset = await db_get_previous_reset()
stats = await db_get_food_war_stats()

embed = discord.Embed(
title="Resetting Days Since Last FoD Food War...",
Expand Down Expand Up @@ -53,6 +54,17 @@ async def reset(ctx:discord.ApplicationContext, reason:str):
name=f"Previous Reason",
value=previous_reset['reason'],
)

embed.add_field(
name="Total Number of Food Wars",
value=stats['total_wars'],
inline=False
)
embed.add_field(
name="Average Days Between Food Wars",
value=int(stats['average_days']),
inline=False
)
else:
days = 0

Expand Down Expand Up @@ -83,6 +95,7 @@ async def check(ctx:discord.ApplicationContext):
return

await ctx.defer()
stats = await db_get_food_war_stats()

pst_tz = pytz.timezone('America/Los_Angeles')
raw_now = datetime.utcnow().replace(tzinfo=pytz.utc)
Expand All @@ -104,15 +117,15 @@ async def check(ctx:discord.ApplicationContext):
value=f"{previous_reset['days']} {'Day' if previous_reset['days'] == 1 else 'Days'}",
)
embed.add_field(
name=f"Previous Reason",
name="Previous Reason",
value=previous_reset['reason'],
)

longest_reset = await db_get_longest_reset()
if previous_reset['id'] == longest_reset['id']:
embed.add_field(
name="All-Time Longest Streak Was The Previous!",
value=f"Holy Guacamole! 🥑",
value="Holy Guacamole! 🥑",
inline=False
)
else:
Expand All @@ -122,11 +135,22 @@ async def check(ctx:discord.ApplicationContext):
inline=False
)
embed.add_field(
name=f"All-Time Longest Streak Reason",
name="All-Time Longest Streak Reason",
value=longest_reset['reason'],
inline=False
)

embed.add_field(
name="Total Number of Food Wars",
value=stats['total_wars'],
inline=False
)
embed.add_field(
name="Average Days Between Food Wars",
value=int(stats['average_days']),
inline=False
)

png = await generate_food_war_check_png(days)
embed.set_image(url=f"attachment://{png.filename}")
embed.set_footer(text="We can only hope it shall last longer... 🥑 ⚔️ 🙏")
Expand Down Expand Up @@ -181,7 +205,7 @@ def generate_food_war_reset_gif(days):
# Eraser Wipe
for n in range(0, 54):
frame = base_text_frame.copy()
wipe_frame = Image.open(f"./images/templates/food_war/wipe/{'{:02d}'.format(n)}.png").convert('RGBA')
wipe_frame = Image.open(f"./images/templates/shared/warning_signs/wipe/{'{:02d}'.format(n)}.png").convert('RGBA')
frame.paste(wipe_frame, (110, 85), wipe_frame)
frames.append(frame)

Expand All @@ -192,7 +216,7 @@ def generate_food_war_reset_gif(days):
# Draw Zero
for n in range(0, 13):
frame = blank_frame.copy()
draw_frame = Image.open(f"./images/templates/food_war/draw/{'{:02d}'.format(n)}.png").convert('RGBA')
draw_frame = Image.open(f"./images/templates/shared/warning_signs/draw/{'{:02d}'.format(n)}.png").convert('RGBA')
frame.paste(draw_frame, (110, 85), draw_frame)
frames.append(frame)

Expand Down Expand Up @@ -251,3 +275,12 @@ async def db_get_longest_reset():
await query.execute(sql)
longest_reset = await query.fetchone()
return longest_reset

async def db_get_food_war_stats():
async with AgimusDB(dictionary=True) as query:
sql = '''
SELECT AVG(days) AS average_days, count(*) as total_wars FROM food_war;
'''
await query.execute(sql)
stats = await query.fetchone()
return stats
31 changes: 31 additions & 0 deletions commands/nuke_maquis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from common import *
from utils.check_role_access import role_check

@bot.command()
@commands.check(role_check)
async def nuke_maquis(ctx):
await ctx.message.delete()
enabled = config["commands"]["nuke_maquis"]["enabled"]
if not enabled:
return

channel_id = get_channel_id("maquis-officers-club")
if not channel_id:
return

channel = bot.get_channel(channel_id)

# Just nuke the entire channel history
await channel.purge(limit=1500, oldest_first=True, reason="Manual Purge")

self_destruct_embed = discord.Embed(
title="Channel Nuked From Orbit! 💥",
color=discord.Color.dark_red()
)
self_destruct_embed.set_image(url="https://i.imgur.com/8W40YCG.gif")
self_destruct_embed.set_footer(text="This message will self-destruct in 5 minutes... 💣")
self_destruct_message = await channel.send(embed=self_destruct_embed)

await asyncio.sleep(300)
await self_destruct_message.delete()

Loading

0 comments on commit 7fe5bf2

Please sign in to comment.