Skip to content

Commit 01a3067

Browse files
committed
fix(telegram): resolve video sending issue
1 parent 5530a22 commit 01a3067

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

astrbot/core/platform/sources/telegram/tg_event.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Plain,
1919
Record,
2020
Reply,
21+
Video,
2122
)
2223
from astrbot.api.platform import AstrBotMessage, MessageType, PlatformMetadata
2324

@@ -36,6 +37,7 @@ class TelegramPlatformEvent(AstrMessageEvent):
3637
# 消息类型到 chat action 的映射,用于优先级判断
3738
ACTION_BY_TYPE: dict[type, str] = {
3839
Record: ChatAction.UPLOAD_VOICE,
40+
Video: ChatAction.UPLOAD_VIDEO,
3941
File: ChatAction.UPLOAD_DOCUMENT,
4042
Image: ChatAction.UPLOAD_PHOTO,
4143
Plain: ChatAction.TYPING,
@@ -278,6 +280,9 @@ async def send_with_client(
278280
caption=i.text or None,
279281
use_media_action=False,
280282
)
283+
elif isinstance(i, Video):
284+
path = await i.convert_to_file_path()
285+
await client.send_video(video=path, **cast(Any, payload))
281286

282287
async def send(self, message: MessageChain) -> None:
283288
if self.get_message_type() == MessageType.GROUP_MESSAGE:
@@ -333,7 +338,7 @@ async def send_streaming(self, generator, use_fallback: bool = False):
333338
"chat_id": user_name,
334339
}
335340
if message_thread_id:
336-
payload["reply_to_message_id"] = message_thread_id
341+
payload["message_thread_id"] = message_thread_id
337342

338343
delta = ""
339344
current_content = ""
@@ -406,6 +411,18 @@ async def send_streaming(self, generator, use_fallback: bool = False):
406411
use_media_action=True,
407412
)
408413
continue
414+
elif isinstance(i, Video):
415+
path = await i.convert_to_file_path()
416+
await self._send_media_with_action(
417+
self.client,
418+
ChatAction.UPLOAD_VIDEO,
419+
self.client.send_video,
420+
user_name=user_name,
421+
message_thread_id=message_thread_id,
422+
video=path,
423+
**cast(Any, payload),
424+
)
425+
continue
409426
else:
410427
logger.warning(f"不支持的消息类型: {type(i)}")
411428
continue

0 commit comments

Comments
 (0)