Compare commits
	
		
			2 Commits
		
	
	
		
			c1a80f5497
			...
			7a0022cb59
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					7a0022cb59 | ||
| 
						 | 
					8ad919cbce | 
							
								
								
									
										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': [],
 | 
			
		||||
                'pirates_list_posts': [],
 | 
			
		||||
                'spicepay_prefs': [],
 | 
			
		||||
                'nick_verified': [],
 | 
			
		||||
                'nick_claim_pending': [],
 | 
			
		||||
                'nick_reviews': [],
 | 
			
		||||
                'rr_msg_channels': [],
 | 
			
		||||
            }
 | 
			
		||||
            self._save(default)
 | 
			
		||||
            return default
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ services:
 | 
			
		||||
      # Persist your JSON data here
 | 
			
		||||
      - shaiwatcher-data:/app/data
 | 
			
		||||
      # Bind your server-side settings.conf into the container
 | 
			
		||||
      - /opt/shaiwatcher/settings.conf:/app/settings.conf
 | 
			
		||||
      - /opt/shaiwatcher/settings.conf:/app/settings.conf:ro
 | 
			
		||||
 | 
			
		||||
volumes:
 | 
			
		||||
  shaiwatcher-data:
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										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 mod_perms import is_moderator_userid
 | 
			
		||||
from modules.common.emoji_accept import is_accept
 | 
			
		||||
 | 
			
		||||
CHECK = '✅'          # approved/verified
 | 
			
		||||
CROSS = '❌'          # reject / no
 | 
			
		||||
@ -172,7 +173,7 @@ class NickNudgeCog(commands.Cog):
 | 
			
		||||
    @commands.Cog.listener()
 | 
			
		||||
    async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):
 | 
			
		||||
        # 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)
 | 
			
		||||
            if not entry:
 | 
			
		||||
                return
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
import discord
 | 
			
		||||
from discord.ext import commands
 | 
			
		||||
from modules.common.emoji_accept import is_accept
 | 
			
		||||
 | 
			
		||||
CHECKMARK = '✅'
 | 
			
		||||
ACCEPT = {CHECKMARK, '🫡'}
 | 
			
		||||
@ -110,7 +111,7 @@ class ReactionRoleCog(commands.Cog):
 | 
			
		||||
    # ---- listeners ----
 | 
			
		||||
    @commands.Cog.listener()
 | 
			
		||||
    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
 | 
			
		||||
        guild = self.bot.get_guild(payload.guild_id)
 | 
			
		||||
        member = await self._get_member(guild, payload.user_id)
 | 
			
		||||
@ -157,7 +158,7 @@ class ReactionRoleCog(commands.Cog):
 | 
			
		||||
 | 
			
		||||
    @commands.Cog.listener()
 | 
			
		||||
    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
 | 
			
		||||
        guild = self.bot.get_guild(payload.guild_id)
 | 
			
		||||
        member = await self._get_member(guild, payload.user_id)
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ import time
 | 
			
		||||
from typing import Optional, Set, Tuple
 | 
			
		||||
import discord
 | 
			
		||||
from discord.ext import commands
 | 
			
		||||
from modules.common.emoji_accept import is_accept
 | 
			
		||||
 | 
			
		||||
CHECK = '✅'          # verified
 | 
			
		||||
CROSS = '❌'          # not done
 | 
			
		||||
@ -270,7 +271,7 @@ class UserCardsCog(commands.Cog):
 | 
			
		||||
        if not message:
 | 
			
		||||
            return ids
 | 
			
		||||
        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):
 | 
			
		||||
                    if not u.bot:
 | 
			
		||||
                        ids.add(u.id)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user