fix: 승인 메시지 중복 전송 수정 - in-memory sent tracking
This commit is contained in:
6
bot.py
6
bot.py
@@ -126,6 +126,7 @@ class GravityBot(commands.Bot):
|
||||
self.session_status_messages: dict[str, int] = {}
|
||||
self.session_names: dict[str, str] = {}
|
||||
self._channel_create_lock = asyncio.Lock() # SINGLE global lock
|
||||
self._sent_approval_ids: set[str] = set() # Track sent approvals
|
||||
self.bridge = BridgeProtocol()
|
||||
self.session_category: discord.CategoryChannel | None = None
|
||||
self.guild: discord.Guild | None = None
|
||||
@@ -347,8 +348,10 @@ class GravityBot(commands.Bot):
|
||||
try:
|
||||
requests = self.bridge.get_pending_requests()
|
||||
for req in requests:
|
||||
if req.discord_message_id != 0:
|
||||
if req.request_id in self._sent_approval_ids:
|
||||
continue # Already sent
|
||||
if req.discord_message_id != 0:
|
||||
continue
|
||||
|
||||
channel = self.session_channels.get(req.conversation_id)
|
||||
if not channel:
|
||||
@@ -360,6 +363,7 @@ class GravityBot(commands.Bot):
|
||||
)
|
||||
|
||||
if channel:
|
||||
self._sent_approval_ids.add(req.request_id)
|
||||
await self._send_approval_request(channel, req)
|
||||
except Exception as e:
|
||||
logger.error(f"Error scanning approvals: {e}")
|
||||
|
||||
Reference in New Issue
Block a user