mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 05:31:52 +00:00
[v4.9.0] - fix(telegram): 增强 telegram 平台的插件可用性
This commit is contained in:
+4
-2
@@ -1,13 +1,15 @@
|
||||
# 更新日志 (CHANGELOG)
|
||||
|
||||
## [v4.8.9] - fix: 群相册严格模式修复 (#111),尝试解决下载用户头像和重试地狱的问题 (#107)
|
||||
|
||||
## [v4.9.0] - fix(telegram): 增强 telegram 平台的插件可用性
|
||||
* **🛠️ 健壮性增强**: Telegram 平台下 发送长图时触发 Photo_invalid_dimensions 报错提示图片长宽比例或总尺寸不合规时,尝试以文件形式发送
|
||||
|
||||
---
|
||||
|
||||
<details>
|
||||
<summary>📋 点击查看历史更新日志</summary>
|
||||
|
||||
## [v4.8.9] - fix: 群相册严格模式修复 (#111),尝试解决下载用户头像和重试地狱的问题 (#107)
|
||||
|
||||
## [v4.8.8] - feat(golden_quote): 重构金句分析匹配机制,尝试解决金句头像偶尔无法显示的问题,锐评中允许解析用户进行头像渲染
|
||||
* **✨ 解决金句头像无法显示**: 尝试解决金句头像无法显示的问题。通过将 Prompt 输入改为 [user_id] 标识符,实现 100% 准确的身份回填,彻底消除了由于 LLM 微调内容导致的匹配失败。
|
||||
* **✨ 报告发送优化**: 允许金句分析解析用户,渲染头像和名称,提升潜在的分析互动效果。
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# 群聊日常分析插件
|
||||
|
||||
[](https://github.com/SXP-Simon/astrbot-qq-group-daily-analysis)
|
||||
[](https://github.com/SXP-Simon/astrbot-qq-group-daily-analysis)
|
||||
[](https://github.com/AstrBotDevs/AstrBot)
|
||||
[](LICENSE)
|
||||
[-white?style=for-the-badge&color=76bad9&logo=qq&logoColor=76bad9)](https://qm.qq.com/q/oTzIrdDBIc)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: astrbot_plugin_qq_group_daily_analysis # 这是你的插件的唯一识别名。
|
||||
display_name: 群分析总结插件 # 插件的显示名称
|
||||
desc: "[多平台接入开发中] 群日常分析总结插件 - 支持 QQ (aiocqhttp)、Telegram、Discord;生成精美的群聊分析报告,支持话题分析、用户形象、群聊圣经等功能" # 插件简短描述
|
||||
version: v4.8.9 # 插件版本号。格式:v1.1.1 或者 v1.1
|
||||
version: v4.9.0 # 插件版本号。格式:v1.1.1 或者 v1.1
|
||||
author: SXP-Simon # 作者
|
||||
astrbot_version: ">=4.16.0"
|
||||
support_platforms:
|
||||
|
||||
@@ -6,6 +6,8 @@ Telegram 平台适配器
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import os
|
||||
from dataclasses import replace
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from io import BytesIO
|
||||
@@ -54,7 +56,7 @@ class TelegramAdapter(PlatformAdapter):
|
||||
|
||||
def __init__(self, bot_instance: Any, config: dict | None = None):
|
||||
super().__init__(bot_instance, config)
|
||||
self._cached_client: ExtBot | None = None
|
||||
self._cached_client: Any = None
|
||||
self._context: Context | None = None
|
||||
|
||||
# 机器人自身 ID(用于消息过滤)
|
||||
@@ -118,7 +120,7 @@ class TelegramAdapter(PlatformAdapter):
|
||||
return list(set(groups))
|
||||
|
||||
@property
|
||||
def _telegram_client(self) -> "ExtBot | None":
|
||||
def _telegram_client(self) -> Any:
|
||||
"""
|
||||
懒加载获取 Telegram 客户端
|
||||
|
||||
@@ -132,14 +134,14 @@ class TelegramAdapter(PlatformAdapter):
|
||||
return None
|
||||
|
||||
# 路径 A: bot 本身就是 ExtBot
|
||||
if isinstance(self.bot, ExtBot):
|
||||
if ExtBot is not None and isinstance(self.bot, ExtBot):
|
||||
self._cached_client = self.bot
|
||||
return self._cached_client
|
||||
|
||||
# 路径 B: bot.client
|
||||
if hasattr(self.bot, "client"):
|
||||
client = self.bot.client
|
||||
if isinstance(client, ExtBot):
|
||||
if ExtBot is not None and isinstance(client, ExtBot):
|
||||
self._cached_client = client
|
||||
return self._cached_client
|
||||
|
||||
@@ -159,9 +161,6 @@ class TelegramAdapter(PlatformAdapter):
|
||||
logger.warning("无法从 bot_instance 获取 Telegram 客户端")
|
||||
return None
|
||||
|
||||
def _init_capabilities(self) -> PlatformCapabilities:
|
||||
"""返回 Telegram 平台能力声明"""
|
||||
return TELEGRAM_CAPABILITIES
|
||||
|
||||
# ==================== IMessageRepository ====================
|
||||
|
||||
@@ -231,7 +230,8 @@ class TelegramAdapter(PlatformAdapter):
|
||||
for record in history_records:
|
||||
if before_id_int is not None:
|
||||
try:
|
||||
if int(record.id) >= before_id_int:
|
||||
rec_id = getattr(record, "id", None)
|
||||
if rec_id is not None and int(rec_id) >= before_id_int:
|
||||
continue
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
@@ -299,9 +299,9 @@ class TelegramAdapter(PlatformAdapter):
|
||||
# 尝试从 bot 实例获取
|
||||
if hasattr(self.bot, "meta") and callable(self.bot.meta):
|
||||
try:
|
||||
meta = self.bot.meta()
|
||||
meta = self.bot.meta() # type: ignore
|
||||
if hasattr(meta, "id"):
|
||||
return meta.id
|
||||
return str(getattr(meta, "id", "telegram"))
|
||||
except Exception:
|
||||
pass
|
||||
return "telegram"
|
||||
@@ -531,9 +531,6 @@ class TelegramAdapter(PlatformAdapter):
|
||||
kwargs["caption"] = caption
|
||||
|
||||
# 1. 统一处理输入源 (Base64 / URL / Local File)
|
||||
import base64
|
||||
import os
|
||||
from datetime import datetime
|
||||
if image_path.startswith("base64://"):
|
||||
data = base64.b64decode(image_path[len("base64://") :])
|
||||
file_obj = BytesIO(data)
|
||||
@@ -547,14 +544,17 @@ class TelegramAdapter(PlatformAdapter):
|
||||
elif image_path.startswith(("http://", "https://")):
|
||||
try:
|
||||
import aiohttp
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(image_path, timeout=aiohttp.ClientTimeout(total=30)) as resp:
|
||||
async with session.get(
|
||||
image_path, timeout=aiohttp.ClientTimeout(total=30)
|
||||
) as resp:
|
||||
if resp.status == 200:
|
||||
data = await resp.read()
|
||||
file_obj = BytesIO(data)
|
||||
is_temp_obj = True
|
||||
else:
|
||||
file_obj = image_path # 尝试直接发 URL
|
||||
file_obj = image_path # 尝试直接发 URL
|
||||
except Exception as e:
|
||||
logger.warning(f"[Telegram] 下载图片失败,尝试直接发送: {e}")
|
||||
file_obj = image_path
|
||||
@@ -579,7 +579,10 @@ class TelegramAdapter(PlatformAdapter):
|
||||
except Exception as e:
|
||||
err_msg = str(e)
|
||||
# Photo_invalid_dimensions: Telegram 报错提示图片长宽比例或总尺寸不合规
|
||||
if "Photo_invalid_dimensions" in err_msg or "Photo invalid dimensions" in err_msg:
|
||||
if (
|
||||
"Photo_invalid_dimensions" in err_msg
|
||||
or "Photo invalid dimensions" in err_msg
|
||||
):
|
||||
logger.warning("[Telegram] 图片尺寸超限,正在尝试以文件形式发送...")
|
||||
# 构造一个更有意义的文件名
|
||||
ts = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
@@ -602,10 +605,6 @@ class TelegramAdapter(PlatformAdapter):
|
||||
return False
|
||||
|
||||
try:
|
||||
import os
|
||||
import base64
|
||||
from io import BytesIO
|
||||
|
||||
chat_id, message_thread_id = self._parse_group_id(group_id)
|
||||
file_obj: Any = None
|
||||
is_temp_obj = False
|
||||
|
||||
Reference in New Issue
Block a user