Adjustments to reaction emoji acceptance
This commit is contained in:
parent
8ad919cbce
commit
7a0022cb59
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.git
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
.env
|
||||||
|
settings.conf
|
||||||
|
data.json
|
||||||
|
data.json.bak
|
||||||
|
example/
|
@ -30,6 +30,10 @@ class DataManager:
|
|||||||
'user_cards': [],
|
'user_cards': [],
|
||||||
'pirates_list_posts': [],
|
'pirates_list_posts': [],
|
||||||
'spicepay_prefs': [],
|
'spicepay_prefs': [],
|
||||||
|
'nick_verified': [],
|
||||||
|
'nick_claim_pending': [],
|
||||||
|
'nick_reviews': [],
|
||||||
|
'rr_msg_channels': [],
|
||||||
}
|
}
|
||||||
self._save(default)
|
self._save(default)
|
||||||
return default
|
return default
|
||||||
|
24
modules/common/emoji_accept.py
Normal file
24
modules/common/emoji_accept.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Accept/approve emoji set used across the bot.
|
||||||
|
# Works for both unicode and custom server emoji.
|
||||||
|
|
||||||
|
# Unicode emoji that should count as "accept"
|
||||||
|
ACCEPT_UNICODE = {"✅", "🫡", "❤️"}
|
||||||
|
|
||||||
|
# Custom emoji short names that should count as "accept"
|
||||||
|
# Add names (not the <:name:id> literal) for any server emoji you want.
|
||||||
|
ACCEPT_CUSTOM_NAMES = {"diverOK"}
|
||||||
|
|
||||||
|
def is_accept(emoji) -> bool:
|
||||||
|
"""
|
||||||
|
Return True if the given emoji should count as an 'accept' reaction.
|
||||||
|
Compatible with Reaction.emoji and RawReactionActionEvent.emoji.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
# unicode path
|
||||||
|
if str(emoji) in ACCEPT_UNICODE:
|
||||||
|
return True
|
||||||
|
# custom emoji path (has a .name)
|
||||||
|
name = getattr(emoji, "name", None)
|
||||||
|
return name in ACCEPT_CUSTOM_NAMES
|
||||||
|
except Exception:
|
||||||
|
return False
|
@ -6,6 +6,7 @@ from discord.ext import commands
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
|
|
||||||
from mod_perms import is_moderator_userid
|
from mod_perms import is_moderator_userid
|
||||||
|
from modules.common.emoji_accept import is_accept
|
||||||
|
|
||||||
CHECK = '✅' # approved/verified
|
CHECK = '✅' # approved/verified
|
||||||
CROSS = '❌' # reject / no
|
CROSS = '❌' # reject / no
|
||||||
@ -172,7 +173,7 @@ class NickNudgeCog(commands.Cog):
|
|||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):
|
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):
|
||||||
# 1) Handle DM nudge confirmations (user reacts ✅ in DM)
|
# 1) Handle DM nudge confirmations (user reacts ✅ in DM)
|
||||||
if payload.guild_id is None and str(payload.emoji) in ACCEPT and payload.user_id != self.bot.user.id:
|
if payload.guild_id is None and is_accept(payload.emoji) and payload.user_id != self.bot.user.id:
|
||||||
entry = next((m for m in self.bot.data_manager.get('nick_dm_map') if m['message_id'] == payload.message_id), None)
|
entry = next((m for m in self.bot.data_manager.get('nick_dm_map') if m['message_id'] == payload.message_id), None)
|
||||||
if not entry:
|
if not entry:
|
||||||
return
|
return
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from modules.common.emoji_accept import is_accept
|
||||||
|
|
||||||
CHECKMARK = '✅'
|
CHECKMARK = '✅'
|
||||||
ACCEPT = {CHECKMARK, '🫡'}
|
ACCEPT = {CHECKMARK, '🫡'}
|
||||||
@ -110,7 +111,7 @@ class ReactionRoleCog(commands.Cog):
|
|||||||
# ---- listeners ----
|
# ---- listeners ----
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):
|
async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):
|
||||||
if str(payload.emoji) not in ACCEPT or not payload.guild_id:
|
if not payload.guild_id or not is_accept(payload.emoji):
|
||||||
return
|
return
|
||||||
guild = self.bot.get_guild(payload.guild_id)
|
guild = self.bot.get_guild(payload.guild_id)
|
||||||
member = await self._get_member(guild, payload.user_id)
|
member = await self._get_member(guild, payload.user_id)
|
||||||
@ -157,7 +158,7 @@ class ReactionRoleCog(commands.Cog):
|
|||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent):
|
async def on_raw_reaction_remove(self, payload: discord.RawReactionActionEvent):
|
||||||
if str(payload.emoji) not in ACCEPT or not payload.guild_id:
|
if not payload.guild_id or not is_accept(payload.emoji):
|
||||||
return
|
return
|
||||||
guild = self.bot.get_guild(payload.guild_id)
|
guild = self.bot.get_guild(payload.guild_id)
|
||||||
member = await self._get_member(guild, payload.user_id)
|
member = await self._get_member(guild, payload.user_id)
|
||||||
|
@ -3,6 +3,7 @@ import time
|
|||||||
from typing import Optional, Set, Tuple
|
from typing import Optional, Set, Tuple
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from modules.common.emoji_accept import is_accept
|
||||||
|
|
||||||
CHECK = '✅' # verified
|
CHECK = '✅' # verified
|
||||||
CROSS = '❌' # not done
|
CROSS = '❌' # not done
|
||||||
@ -270,7 +271,7 @@ class UserCardsCog(commands.Cog):
|
|||||||
if not message:
|
if not message:
|
||||||
return ids
|
return ids
|
||||||
for rxn in message.reactions:
|
for rxn in message.reactions:
|
||||||
if str(rxn.emoji) in ACCEPT: # <-- was == CHECK
|
if is_accept(rxn.emoji):
|
||||||
async for u in rxn.users(limit=None):
|
async for u in rxn.users(limit=None):
|
||||||
if not u.bot:
|
if not u.bot:
|
||||||
ids.add(u.id)
|
ids.add(u.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user