mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-25 00:04:32 +00:00
autocaption 支持语音\语音
This commit is contained in:
parent
166c628ed7
commit
27927b480a
@ -1,7 +1,8 @@
|
|||||||
from pagermaid import version
|
from pagermaid import version
|
||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
from telethon.tl.custom.message import Message
|
from telethon.tl.custom.message import Message
|
||||||
from telethon.tl.types import MessageMediaDocument, DocumentAttributeFilename, DocumentAttributeImageSize
|
from telethon.tl.types import MessageMediaDocument, DocumentAttributeFilename, DocumentAttributeImageSize, \
|
||||||
|
DocumentAttributeAudio
|
||||||
|
|
||||||
|
|
||||||
def unit_convert(byte):
|
def unit_convert(byte):
|
||||||
@ -19,6 +20,15 @@ def unit_convert(byte):
|
|||||||
return f"{round(byte, 2)} {units[zero]}"
|
return f"{round(byte, 2)} {units[zero]}"
|
||||||
|
|
||||||
|
|
||||||
|
def duration_convert(duration: int):
|
||||||
|
""" Converts duration into readable formats. """
|
||||||
|
minutes = duration // 60
|
||||||
|
seconds = duration % 60
|
||||||
|
hours = minutes // 60
|
||||||
|
minutes %= 60
|
||||||
|
return f"{hours:02d}:{minutes:02d}:{seconds:02d}"
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=True, outgoing=True, incoming=False, ignore_edited=True)
|
@listener(is_plugin=True, outgoing=True, incoming=False, ignore_edited=True)
|
||||||
async def auto_caption_file(context: Message):
|
async def auto_caption_file(context: Message):
|
||||||
if not context.media:
|
if not context.media:
|
||||||
@ -36,6 +46,16 @@ async def auto_caption_file(context: Message):
|
|||||||
# 图片尺寸
|
# 图片尺寸
|
||||||
if isinstance(i, DocumentAttributeImageSize):
|
if isinstance(i, DocumentAttributeImageSize):
|
||||||
text += f"`图片尺寸:{i.w}x{i.h}`\n"
|
text += f"`图片尺寸:{i.w}x{i.h}`\n"
|
||||||
|
# 音乐时长、歌手、歌曲名
|
||||||
|
if isinstance(i, DocumentAttributeAudio):
|
||||||
|
if i.title:
|
||||||
|
text += f"`歌曲名:{i.title}`\n"
|
||||||
|
if i.performer:
|
||||||
|
text += f"`歌手:{i.performer}`\n"
|
||||||
|
if not i.voice:
|
||||||
|
text += f"`音乐时长:{duration_convert(i.duration)}`\n"
|
||||||
|
else:
|
||||||
|
text += f"`语音时长:{duration_convert(i.duration)}`\n"
|
||||||
# 文件类型
|
# 文件类型
|
||||||
text += f"`文件类型:{context.media.document.mime_type}`\n"
|
text += f"`文件类型:{context.media.document.mime_type}`\n"
|
||||||
# 文件大小
|
# 文件大小
|
||||||
|
@ -852,10 +852,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "autocaption",
|
"name": "autocaption",
|
||||||
"version": "1.0",
|
"version": "1.001",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "xtaodada",
|
"maintainer": "xtaodada",
|
||||||
"size": "1.47 kb",
|
"size": "2.2 kb",
|
||||||
"supported": true,
|
"supported": true,
|
||||||
"des-short": "自动获取所发送文件的信息。",
|
"des-short": "自动获取所发送文件的信息。",
|
||||||
"des": "自动获取所发送文件的信息。"
|
"des": "自动获取所发送文件的信息。"
|
||||||
|
Loading…
Reference in New Issue
Block a user