fix(channels): restore bound logger in discord and websocket

PR introduced module-level logger in static methods, which drops
the channel context bound by BaseChannel.__init__. Revert to
self._channel.logger / self.logger to preserve log labels.

Also remove @staticmethod since these methods legitimately need
instance access (F821 was the real issue, not the logger source).
This commit is contained in:
chengyongru
2026-05-07 13:07:22 +08:00
committed by Xubin Ren
parent a2f5de6838
commit 536c456e5e
2 changed files with 5 additions and 6 deletions
+2 -3
View File
@@ -10,7 +10,6 @@ from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal
from loguru import logger
from pydantic import Field
from nanobot.bus.events import OutboundMessage
@@ -309,8 +308,8 @@ if DISCORD_AVAILABLE:
fallback = "\n".join(f"[attachment: {name} - send failed]" for name in failed_media)
return split_message(fallback, MAX_MESSAGE_LEN)
@staticmethod
def _build_reply_context(
self,
channel: Messageable,
reply_to: str | None,
) -> tuple[discord.PartialMessage | None, discord.AllowedMentions]:
@@ -321,7 +320,7 @@ if DISCORD_AVAILABLE:
try:
message_id = int(reply_to)
except ValueError:
logger.warning("Invalid reply target: {}", reply_to)
self._channel.logger.warning("Invalid reply target: {}", reply_to)
return None, mention_settings
return channel.get_partial_message(message_id), mention_settings