新增消息类型:语音,视频

This commit is contained in:
liuwei
2025-06-12 11:37:20 +08:00
parent 0e198c7c09
commit 0e2169f295
4 changed files with 154 additions and 15 deletions

View File

@@ -35,7 +35,7 @@ class MessagePushTask(MessagePluginInterface):
@property
def description(self) -> str:
return "提供消息推送功能,支持定时推送群发消息"
return "提供消息推送功能,支持定时推送群发消息、语音消息和视频消息"
@property
def author(self) -> str:
@@ -124,6 +124,8 @@ class MessagePushTask(MessagePluginInterface):
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
return False, "没有权限"
return False, None
def _get_execution_key(self, task_id: str, hour: int, minute: int) -> str:
"""生成任务执行记录的唯一键"""
now = datetime.now()
@@ -192,11 +194,8 @@ class MessagePushTask(MessagePluginInterface):
content_image = task.get('content_image')
content_link = task.get('content_link')
content_miniprogram = task.get('content_miniprogram')
groups = task.get('groups', [])
try:
groups = json.loads(groups)
except json.JSONDecodeError:
raise Exception("无发送清单")
content_voice = task.get('content_voice') # 语音消息
content_video = task.get('content_video') # 视频消息
# 记录任务开始执行
self.db.log_task_action({
@@ -230,6 +229,12 @@ class MessagePushTask(MessagePluginInterface):
success_count = 0
fail_count = 0
groups = task.get('groups', [])
try:
groups = json.loads(groups)
except json.JSONDecodeError:
raise Exception("无发送清单")
for group_id in groups:
try:
# 发送文本消息
@@ -251,6 +256,14 @@ class MessagePushTask(MessagePluginInterface):
)
await self.bot.send_link_xml_message(xml_content, group_id)
# 发送语音消息
if content_voice:
await self.bot.send_voice_message(group_id, Path(content_voice))
# 发送视频消息
if content_video:
await self.bot.send_video_message(group_id, Path(content_video))
success_count += 1
except Exception as e: