Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge staging onto master #278

Merged
merged 161 commits into from
Dec 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
f0c8e78
Added initial joyboard commit
Snaacky Nov 18, 2022
3f645b9
Missed a few instances of star
Snaacky Nov 18, 2022
6b4355e
added database migrations
Snaacky Nov 18, 2022
f15f66d
fixed tuple not being a tuple anymore
Snaacky Nov 18, 2022
3e3c51c
More 😂 support
Kapppa Dec 4, 2022
a30b03a
Support custom joys
Kapppa Dec 14, 2022
1b3a5b9
Fix the use of Emoji class, can happen if the message.Reactions method
Kapppa Dec 16, 2022
dd634ac
Add wildcard support for joy_
Kapppa Dec 16, 2022
b754464
Support str emojis
Kapppa Dec 16, 2022
c31d4c5
Implemented /hl command
Snaacky Dec 16, 2022
b9271f7
Fixed class naming and async cog loading
Snaacky Dec 16, 2022
82435fc
actually made the hl listener async
Snaacky Dec 16, 2022
5d71895
fix command describe using wrong parent
Snaacky Dec 16, 2022
8a95572
more miscellaneous oopsies fixes
Snaacky Dec 16, 2022
45f2c61
switched ctx.author to ctx.user
Snaacky Dec 16, 2022
e392652
fixed cog name schema
Snaacky Dec 16, 2022
c6b7b69
i regret testing this this way
Snaacky Dec 16, 2022
7340347
removed unnecessary await
Snaacky Dec 16, 2022
a59bd12
command invokes are now ephemeral to avoid spam
Snaacky Dec 16, 2022
0b37726
Fix ReDoS and fix is_user_active
Kapppa Dec 17, 2022
2cb03f9
Fix using the wrong message
Kapppa Dec 17, 2022
e10777e
Fix the wrong message being used
Kapppa Dec 17, 2022
853cb0f
Change to aiohttp, reduce trackerstatus requests
Kapppa Dec 30, 2022
aaebdb2
Merge remote-tracking branch 'origin/highlights-2022' into staging
Snaacky Jan 25, 2023
5f649fa
Merge remote-tracking branch 'origin/trackerstatus-shard-fix' into st…
Snaacky Jan 25, 2023
a450c00
Fixed missing await statement on tracker.do_refresh
Snaacky Jan 25, 2023
259bdf2
Merge branch 'trackerstatus-shard-fix' into staging
Snaacky Jan 25, 2023
568fd7a
Merge branch 'joyboard' of https://github.com/Snaacky/chiya into joyb…
Kapppa Jan 25, 2023
b899217
Merge remote-tracking branch 'origin/joyboard' into staging
Snaacky Jan 25, 2023
6c301d3
Add checks for missing hl member
Kapppa Jan 25, 2023
62ad192
Merge remote-tracking branch 'origin/highlights-2022' into staging
Snaacky Jan 26, 2023
f8b2060
Bumped to 3.11, bumped library dependencies, testing new Poetry install
Snaacky Jan 26, 2023
a1a61e0
Attempting to fix Docker build errors
Snaacky Jan 26, 2023
3bda685
Removed legacy extras, switched discord.py version over to extras
Snaacky Jan 26, 2023
94ef791
Merge branch '3.11-bump' into staging
Snaacky Jan 26, 2023
0a159ab
Updated poetry.lock for Python 3.11 bump
Snaacky Jan 26, 2023
3586b9e
Merge branch '3.11-bump' into staging
Snaacky Jan 26, 2023
91d0e31
Fixed database collation check so it doesn't run every bot start
Snaacky Jan 26, 2023
a6f4dac
Fixed str/int concatenate mis-match
Snaacky Jan 26, 2023
034aa02
Merge branch 'highlights-2022' into staging
Snaacky Jan 26, 2023
e965d57
Merge branch 'delete-legacy-automod' into staging
Snaacky Jan 26, 2023
686d871
Change joyboard to a task to prevent rate limit
Kapppa Jan 28, 2023
48dabe5
fix deletion error in loop
Kapppa Jan 30, 2023
701252d
remove unused message_id parameter
R3D4CTED Jan 30, 2023
db6c314
Bumped dataset to 1.6.0
Snaacky Feb 3, 2023
6540de1
Merge branch 'dataset-1.6.0' into staging
Snaacky Feb 3, 2023
580b30b
Move db.close after iteration of data
Kapppa Feb 3, 2023
387435b
Merge branch 'joyboard' into staging
Snaacky Feb 3, 2023
90f6f12
Merge branch 'search-changes' into staging
Snaacky Feb 3, 2023
1b397d5
Fix channel rate limit and flake8 issue
Kapppa Feb 3, 2023
e47408c
Merge remote-tracking branch 'origin/joyboard' into staging
Snaacky Feb 4, 2023
5de52e4
wrap joyboard task in try except.
Kapppa Feb 7, 2023
4d93fdd
Merge remote-tracking branch 'origin/joyboard' into staging
Snaacky Feb 7, 2023
55cc1da
Adjusted tracker status error log level and message
Snaacky Feb 20, 2023
bdc4d05
Merge branch 'trackerstatus-error-fix' into staging
Snaacky Feb 20, 2023
09176e7
Added autoresponder traceback discord.User hotfix
Snaacky Feb 20, 2023
8666f6b
Merge branch 'autoresponder-traceback-fix' into staging
Snaacky Feb 20, 2023
acbfa00
Fixed traceback exception that would occur when users DM the bot
Snaacky Feb 20, 2023
d6792e5
Mod actions are now ephemeral and logged to a channel, misc. changes
Snaacky Mar 7, 2023
3960659
Merge branch 'ephermal-and-misc-fixes' into staging
Snaacky Mar 7, 2023
7a98ae8
Mirroring logs to both #moderation and #chiya
Snaacky Mar 7, 2023
14998f8
Merge branch 'ephermal-and-misc-fixes' into staging
Snaacky Mar 7, 2023
c1dbb2a
Change pagination support
Kapppa Mar 10, 2023
d118fec
Add proper try catches for reminders
Kapppa Mar 18, 2023
3c024aa
remove extra equal
Kapppa Mar 18, 2023
d37b899
Revert = remove
Kapppa Mar 18, 2023
272a4e4
Fixed unmute's mod_embed and user_embed being mixmatched
Snaacky Apr 4, 2023
9dca00d
Merge branch 'ephermal-and-misc-fixes' into staging
Snaacky Apr 4, 2023
2b6955d
Merge remote-tracking branch 'origin/staging' into staging
Snaacky Apr 4, 2023
0764d63
Fixed improper timeout usage for /unmute, leaking mod name during action
Snaacky Apr 4, 2023
86a0692
Merge branch 'ephermal-and-misc-fixes' into staging
Snaacky Apr 4, 2023
25e13d5
updated dependencies, added discord-ext-menus
Snaacky Apr 4, 2023
74a566a
Merge branch 'pagination' into staging
Snaacky Apr 4, 2023
fe72ee3
Fix emoji and an interaction issue
Kapppa Apr 4, 2023
9a9fef8
Merge remote-tracking branch 'origin/pagination' into staging
Snaacky Apr 5, 2023
f8c1ca6
Fix interaction and add page number
Kapppa Apr 5, 2023
984a210
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
1817ed9
handle interaction further
Kapppa Apr 5, 2023
beb32d6
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
8477655
use followup if already had response.
Kapppa Apr 5, 2023
f435886
await for page details
Kapppa Apr 5, 2023
b3501ef
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
3e9daf1
await followup
Kapppa Apr 5, 2023
c435c29
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
2d1eef2
swap parameters.
Kapppa Apr 5, 2023
6769730
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
d53744e
check for follow up
Kapppa Apr 5, 2023
7618b46
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
de98b56
change interaction check and invalid page handle
Kapppa Apr 5, 2023
f917ab3
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
8c27334
handle function correctly
Kapppa Apr 5, 2023
50b3683
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
4d54398
defer response
Kapppa Apr 5, 2023
3523d4e
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
bd30369
Change interaction handing.
Kapppa Apr 5, 2023
342c5c0
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
932dfc2
Add debug logging and revert change
Kapppa Apr 5, 2023
9b63ba3
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
3c7a996
Migrated coloredlogs to loguru, added /bot console and /bot log
Snaacky Apr 5, 2023
04b3cad
Merge branch 'loguru-bot-console' into staging
Snaacky Apr 5, 2023
d5f23b5
Updated discord.py to 2.2.2
Snaacky Apr 5, 2023
81c4351
Updated imports to accommodate for new import scheme
Snaacky Apr 5, 2023
04ab717
Broke down functionality in main() into separate functions
Snaacky Apr 5, 2023
af08979
Updated poetry.lock for newest dependencies
Snaacky Apr 5, 2023
a6cc22d
Added updated poetry.lock for latest discord.py dependencies
Snaacky Apr 5, 2023
c9526ef
Merge branch 'loguru-bot-console' into staging
Snaacky Apr 5, 2023
b556cb8
Manually removing administrator.py from staging due to desync
Snaacky Apr 5, 2023
fb33129
logs debugging info about page
Kapppa Apr 5, 2023
98d865c
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
b259a0d
more debugging
Kapppa Apr 5, 2023
4d45d82
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
cd09b23
Remove hard coded ephemeral, added more logs
Kapppa Apr 5, 2023
d967361
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
6d20108
Change logging
Kapppa Apr 5, 2023
fb53148
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
2552eeb
Remove logging and add another bad response
Kapppa Apr 5, 2023
b2d0ac3
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
99e44a3
Wrap options and add checks to reminder
Kapppa Apr 5, 2023
fa87fc1
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
3745fbb
Fix conditional error
Kapppa Apr 5, 2023
ec13e77
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
7caefa6
add custom emojis and change style
Kapppa Apr 5, 2023
fd62839
Merge branch 'pagination' into staging
Kapppa Apr 5, 2023
7ce781c
fix mutes and bans failing because can_action_member wasn't awaited
R3D4CTED Apr 7, 2023
db3e197
revert can_action_member to async
R3D4CTED Apr 7, 2023
a9e0515
Staging fix for import being broken
Snaacky Apr 8, 2023
98ad2fc
convert reminder clear to buttons
Kapppa Apr 11, 2023
7bb1cde
Change to edit_original_response
Kapppa May 11, 2023
ec3a322
Merge branch 'pagination' into staging
Kapppa May 11, 2023
9f9da5d
fix: prevent missing channels from breaking embeds
Snaacky Jun 18, 2023
00fd5ba
fix mute/ban
Kapppa Jun 22, 2023
20dfc8e
Remove positional values for required
Kapppa Jun 30, 2023
0e3b064
remove index in note
Kapppa Jul 18, 2023
3294423
Remove use of task
Kapppa Sep 8, 2023
d4daf95
prevent cache getting stuck.
Kapppa Sep 8, 2023
91092c8
fix: Purge now includes last message sent (#260)
qLunar Sep 22, 2023
e795829
Remove unused task
Kapppa Sep 22, 2023
e0a1ba3
Merge branch 'Joyboard-task' into staging
Kapppa Sep 22, 2023
0335055
fix: revert earlier commit (#261)
qLunar Sep 22, 2023
5b0b4fa
Fix potential issue with joyboard
Kapppa Sep 25, 2023
6909433
Merge branch 'Joyboard-task' into staging
Kapppa Sep 25, 2023
d26ed54
fix: close report button not working after the bot restart (#264)
pingu6 Sep 29, 2023
82fea26
fix: reports can now be cancelled (#266)
qLunar Sep 29, 2023
2e9d8f7
fix: now clears cache on joyboard update (#269)
qLunar Oct 13, 2023
711c171
Refactor Highlights
Kapppa Oct 15, 2023
55880b0
Better optimisation for history
Kapppa Oct 15, 2023
c22c3a5
close database after refresh
Kapppa Oct 15, 2023
2ab6d9e
feat: Logs the user and message to console when an old message is rea…
qLunar Oct 22, 2023
f283d41
fix: added self on function call, added support for edge case
qLunar Oct 24, 2023
8924b3e
joylog fixes (#272)
qLunar Oct 26, 2023
5e5b0bb
Spoiler detection for joyboard
Kapppa Nov 5, 2023
c085446
feat: add mention outside embed on nitro boost/deboost
Snaacky Dec 22, 2023
2d70ff0
fix: Changed broken imgur link (#274)
JohnTitor998 Jan 24, 2024
1bc27a4
Use correct var
Kapppa Mar 14, 2024
ea17f85
fix emojis in tracker status
Kapppa Apr 27, 2024
1196ee5
fix: loguru now handles discord.py logs and exceptions (#276)
qLunar Apr 30, 2024
cdc93f4
fix: disable backtrace in exception logging
qLunar May 18, 2024
3227583
add NBL support
Kapppa Jun 2, 2024
063fda8
Support image embeds
Kapppa Sep 30, 2024
1ee5770
feat: Readd move questions command.
qLunar Nov 18, 2024
3345624
fix: Remove NSFW check on joyboard
Kapppa Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support custom joys
  • Loading branch information
Kapppa committed Dec 14, 2022
commit a30b03aadc7189beff67212c7ca069626e388d7e
35 changes: 24 additions & 11 deletions chiya/cogs/listeners/joyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

class Joyboard(commands.Cog):

JOYS = ("😂", "😹", ":joy_pride:984917004928569355", ":joy_tone1:984912210172194906", ":joy_tone5:974633464655654922", ":joy_logga:1028828971384709171")
JOYS = ("😂", "😹", "joy_pride", "joy_tone1", "joy_tone5", "joy_logga")

def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
self.cache = {"add": set(), "remove": set()}


def generate_color(self, joy_count: int) -> int:
"""
Hue, saturation, and value is divided by 360, 100, 100 respectively because it is using the fourth coordinate group
described in https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Color/Normalized_Color_Coordinates#HSV_coordinates.
Hue, saturation, and value is divided by 360, 100, 100 respectively because it is using the
fourth coordinate group described in
https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Color/Normalized_Color_Coordinates#HSV_coordinates.
"""
if joy_count <= 5:
saturation = 0.4
Expand All @@ -37,10 +37,10 @@ def generate_color(self, joy_count: int) -> int:

return discord.Color.from_hsv(48 / 360, saturation, 1).value

async def get_joy_count(self, message: discord.Message, joys: tuple) -> int:
async def get_joy_count(self, message: discord.Message) -> int:
unique_users = set()
for reaction in message.reactions:
if reaction.emoji not in joys:
if not self.check_emoji(reaction.emoji, message.guild.id):
continue

async for user in reaction.users():
Expand All @@ -49,6 +49,19 @@ async def get_joy_count(self, message: discord.Message, joys: tuple) -> int:

return len(unique_users)

def check_emoji(self, emoji: discord.PartialEmoji, guild_id: int):

if emoji.is_custom_emoji():
guild = self.bot.get_guild(guild_id)
if not guild:
return False

global_emoji = discord.utils.get(guild.emojis, id=emoji.id)
if not global_emoji:
return False

return emoji.name in self.JOYS

@commands.Cog.listener()
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) -> None:
"""
Expand All @@ -58,12 +71,12 @@ async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) ->
Implements a cache to prevent race condition where if multiple joys were reacted on a message after it hits the
joy threshold and the IDs were not written to the database quickly enough, a duplicated joy embed would be sent.
"""
if payload.emoji.name not in self.JOYS:
if not self.check_emoji(payload.emoji, payload.guild_id):
return

channel = self.bot.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
joy_count = await self.get_joy_count(message, self.JOYS)
joy_count = await self.get_joy_count(message)
cache_data = (payload.message_id, payload.channel_id)

if (
Expand Down Expand Up @@ -158,12 +171,12 @@ async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent) ->
@commands.Cog.listener()
async def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent) -> None:
"""
Update the joy count in the embed if the joys were reacted. Delete joy embed if the joy count is below threshold.
Update the joy count in the embed if the joys were reacted. Delete joy embed if the joy count is below threshold
"""
cache_data = (payload.message_id, payload.channel_id)

if (
payload.emoji.name not in self.JOYS
not self.check_emoji(payload.emoji, payload.guild_id)
or cache_data in self.cache["remove"]
):
return
Expand All @@ -187,7 +200,7 @@ async def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent)
self.cache["remove"].remove(cache_data)
return db.close()

joy_count = await self.get_joy_count(message, self.JOYS)
joy_count = await self.get_joy_count(message)

if joy_count < config["channels"]["joyboard"]["joy_limit"]:
db["joyboard"].delete(channel_id=payload.channel_id, message_id=payload.message_id)
Expand Down