From ada11b38c4a9e718f315c679c6c7a2f2bdf8dcf7 Mon Sep 17 00:00:00 2001 From: chengyongru Date: Fri, 15 May 2026 14:29:57 +0800 Subject: [PATCH] =?UTF-8?q?simplify(pairing):=20deduplicate=20Slack=20pair?= =?UTF-8?q?ing=20code=20=E2=80=94=20delegate=20to=20BaseChannel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Slack hand-rolled the same generate_code + format_pairing_reply + send sequence already in BaseChannel._handle_message. Replace with delegation to _handle_message(is_dm=True), matching Feishu's pattern. Removes 3 unused imports (generate_code, format_pairing_reply, PAIRING_CODE_META_KEY) from slack.py. --- nanobot/channels/slack.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/nanobot/channels/slack.py b/nanobot/channels/slack.py index c6cc79736..5bb5d40a5 100644 --- a/nanobot/channels/slack.py +++ b/nanobot/channels/slack.py @@ -18,7 +18,7 @@ from nanobot.bus.queue import MessageBus from nanobot.channels.base import BaseChannel from nanobot.config.paths import get_media_dir from nanobot.config.schema import Base -from nanobot.pairing import PAIRING_CODE_META_KEY, format_pairing_reply, generate_code, is_approved +from nanobot.pairing import is_approved from nanobot.utils.helpers import safe_filename, split_message @@ -344,15 +344,11 @@ class SlackChannel(BaseChannel): if not self._is_allowed(sender_id, chat_id, channel_type): if channel_type == "im" and self.config.dm.enabled: - code = generate_code(self.name, sender_id) - reply = format_pairing_reply(code) - await self.send( - OutboundMessage( - channel=self.name, - chat_id=chat_id, - content=reply, - metadata={PAIRING_CODE_META_KEY: code}, - ) + await self._handle_message( + sender_id=sender_id, + chat_id=chat_id, + content="", + is_dm=True, ) return