From 1989d615d25dff88a393b58118b10c10b7632c76 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 9 Mar 2025 17:48:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20style:=20format=20codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/platform/manager.py | 4 +++- .../platform/sources/dingtalk/dingtalk_adapter.py | 5 +---- .../platform/sources/dingtalk/dingtalk_event.py | 14 ++++++-------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/astrbot/core/platform/manager.py b/astrbot/core/platform/manager.py index 7acbd5aad..9ca3b82d1 100644 --- a/astrbot/core/platform/manager.py +++ b/astrbot/core/platform/manager.py @@ -65,7 +65,9 @@ class PlatformManager: case "lark": from .sources.lark.lark_adapter import LarkPlatformAdapter # noqa: F401 case "dingtalk": - from .sources.dingtalk.dingtalk_adapter import DingtalkPlatformAdapter # noqa: F401 + from .sources.dingtalk.dingtalk_adapter import ( + DingtalkPlatformAdapter, # noqa: F401 + ) case "telegram": from .sources.telegram.tg_adapter import TelegramPlatformAdapter # noqa: F401 case "wecom": diff --git a/astrbot/core/platform/sources/dingtalk/dingtalk_adapter.py b/astrbot/core/platform/sources/dingtalk/dingtalk_adapter.py index fe9df8672..507b3bb50 100644 --- a/astrbot/core/platform/sources/dingtalk/dingtalk_adapter.py +++ b/astrbot/core/platform/sources/dingtalk/dingtalk_adapter.py @@ -2,7 +2,6 @@ import asyncio import uuid import aiohttp import dingtalk_stream -import logging from astrbot.api.platform import ( Platform, @@ -98,9 +97,7 @@ class DingtalkPlatformAdapter(Platform): if abm.type == MessageType.GROUP_MESSAGE: if message.is_in_at_list: - abm.message.append( - At(qq=abm.self_id) - ) + abm.message.append(At(qq=abm.self_id)) abm.group_id = message.conversation_id if self.unique_session: abm.session_id = abm.sender.user_id diff --git a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py index de35742b0..e865913e1 100644 --- a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py +++ b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py @@ -1,14 +1,8 @@ -import json -import uuid import asyncio -import aiohttp import dingtalk_stream import astrbot.api.message_components as Comp -from typing import List from astrbot.api.event import AstrMessageEvent, MessageChain -from astrbot.core.utils.io import download_image_by_url from astrbot import logger -from astrbot.core.utils.io import file_to_base64 class DingtalkMessageEvent(AstrMessageEvent): @@ -35,7 +29,9 @@ class DingtalkMessageEvent(AstrMessageEvent): elif isinstance(segment, Comp.Image): markdown_str = "" if segment.file and segment.file.startswith("file:///"): - logger.warning("dingtalk only support url image, not: " + segment.file) + logger.warning( + "dingtalk only support url image, not: " + segment.file + ) continue elif segment.file and segment.file.startswith("http"): markdown_str += f"![image]({segment.file})\n\n" @@ -43,7 +39,9 @@ class DingtalkMessageEvent(AstrMessageEvent): logger.warning("dingtalk only support url image, not base64") continue else: - logger.warning("dingtalk only support url image, not: " + segment.file) + logger.warning( + "dingtalk only support url image, not: " + segment.file + ) continue ret = await asyncio.get_event_loop().run_in_executor(