mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-19 16:12:30 +00:00
simplify(pairing): deduplicate Slack pairing code — delegate to BaseChannel
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.
This commit is contained in:
parent
22a0df0c53
commit
ada11b38c4
@ -18,7 +18,7 @@ from nanobot.bus.queue import MessageBus
|
|||||||
from nanobot.channels.base import BaseChannel
|
from nanobot.channels.base import BaseChannel
|
||||||
from nanobot.config.paths import get_media_dir
|
from nanobot.config.paths import get_media_dir
|
||||||
from nanobot.config.schema import Base
|
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
|
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 not self._is_allowed(sender_id, chat_id, channel_type):
|
||||||
if channel_type == "im" and self.config.dm.enabled:
|
if channel_type == "im" and self.config.dm.enabled:
|
||||||
code = generate_code(self.name, sender_id)
|
await self._handle_message(
|
||||||
reply = format_pairing_reply(code)
|
sender_id=sender_id,
|
||||||
await self.send(
|
chat_id=chat_id,
|
||||||
OutboundMessage(
|
content="",
|
||||||
channel=self.name,
|
is_dm=True,
|
||||||
chat_id=chat_id,
|
|
||||||
content=reply,
|
|
||||||
metadata={PAIRING_CODE_META_KEY: code},
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user