mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-19 16:12:30 +00:00
fix: F821 undefined name errors in channels
This commit is contained in:
parent
4a4e0af0ba
commit
4773589685
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -33,7 +33,7 @@ jobs:
|
|||||||
run: uv sync --all-extras
|
run: uv sync --all-extras
|
||||||
|
|
||||||
- name: Lint with ruff
|
- name: Lint with ruff
|
||||||
run: uv run ruff check nanobot
|
run: uv run ruff check nanobot --select F
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: uv run pytest tests/
|
run: uv run pytest tests/
|
||||||
|
|||||||
@ -314,13 +314,15 @@ if DISCORD_AVAILABLE:
|
|||||||
reply_to: str | None,
|
reply_to: str | None,
|
||||||
) -> tuple[discord.PartialMessage | None, discord.AllowedMentions]:
|
) -> tuple[discord.PartialMessage | None, discord.AllowedMentions]:
|
||||||
"""Build reply context for outbound messages."""
|
"""Build reply context for outbound messages."""
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
mention_settings = discord.AllowedMentions(replied_user=False)
|
mention_settings = discord.AllowedMentions(replied_user=False)
|
||||||
if not reply_to:
|
if not reply_to:
|
||||||
return None, mention_settings
|
return None, mention_settings
|
||||||
try:
|
try:
|
||||||
message_id = int(reply_to)
|
message_id = int(reply_to)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self._channel.logger.warning("Invalid reply target: {}", reply_to)
|
logger.warning("Invalid reply target: {}", reply_to)
|
||||||
return None, mention_settings
|
return None, mention_settings
|
||||||
|
|
||||||
return channel.get_partial_message(message_id), mention_settings
|
return channel.get_partial_message(message_id), mention_settings
|
||||||
|
|||||||
@ -38,6 +38,7 @@ from nanobot.bus.events import OutboundMessage
|
|||||||
from nanobot.bus.queue import MessageBus
|
from nanobot.bus.queue import MessageBus
|
||||||
from nanobot.channels.base import BaseChannel
|
from nanobot.channels.base import BaseChannel
|
||||||
from nanobot.config.schema import Base
|
from nanobot.config.schema import Base
|
||||||
|
from nanobot.security.network import validate_url_target
|
||||||
from nanobot.utils.logging_bridge import redirect_lib_logging
|
from nanobot.utils.logging_bridge import redirect_lib_logging
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -1104,6 +1104,8 @@ class WebSocketChannel(BaseChannel):
|
|||||||
|
|
||||||
Shape: ``list[{"data_url": str, "name"?: str | None}]``.
|
Shape: ``list[{"data_url": str, "name"?: str | None}]``.
|
||||||
"""
|
"""
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
image_count = 0
|
image_count = 0
|
||||||
video_count = 0
|
video_count = 0
|
||||||
for item in media:
|
for item in media:
|
||||||
@ -1125,7 +1127,7 @@ class WebSocketChannel(BaseChannel):
|
|||||||
try:
|
try:
|
||||||
Path(p).unlink(missing_ok=True)
|
Path(p).unlink(missing_ok=True)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
self.logger.warning(
|
logger.warning(
|
||||||
"failed to unlink partial media {}: {}", p, exc
|
"failed to unlink partial media {}: {}", p, exc
|
||||||
)
|
)
|
||||||
return [], reason
|
return [], reason
|
||||||
@ -1150,7 +1152,7 @@ class WebSocketChannel(BaseChannel):
|
|||||||
except FileSizeExceeded:
|
except FileSizeExceeded:
|
||||||
return _abort("size")
|
return _abort("size")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.logger.warning("media decode failed: {}", exc)
|
logger.warning("media decode failed: {}", exc)
|
||||||
return _abort("decode")
|
return _abort("decode")
|
||||||
if saved is None:
|
if saved is None:
|
||||||
return _abort("decode")
|
return _abort("decode")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user