☺️ 获取音频时可以添加描述方便查找,补全翻译
This commit is contained in:
parent
f26b6805e7
commit
6517f8d9a0
@ -187,31 +187,32 @@ async def profile(context):
|
||||
await context.edit("出错了呜呜呜 ~ 指定的 UserID 已超出整数限制,您确定输对了?")
|
||||
return
|
||||
raise exception
|
||||
user_type = "Bot" if target_user.user.bot else "User"
|
||||
user_type = "Bot" if target_user.user.bot else "用户"
|
||||
username_system = f"@{target_user.user.username}" if target_user.user.username is not None else (
|
||||
"This user have not yet defined their username.")
|
||||
"喵喵喵 ~ 好像没有设置")
|
||||
first_name = target_user.user.first_name.replace("\u2060", "")
|
||||
last_name = target_user.user.last_name.replace("\u2060", "") if target_user.user.last_name is not None else (
|
||||
"This user did not define a last name."
|
||||
"喵喵喵 ~ 好像没有设置"
|
||||
)
|
||||
biography = target_user.about if target_user.about is not None else "This user did not define a biography string."
|
||||
caption = f"**Profile:** \n" \
|
||||
f"Username: {username_system} \n" \
|
||||
f"UserID: {target_user.user.id} \n" \
|
||||
f"First Name: {first_name} \n" \
|
||||
f"Last Name: {last_name} \n" \
|
||||
f"Biography: {biography} \n" \
|
||||
f"Common Groups: {target_user.common_chats_count} \n" \
|
||||
f"Verified: {target_user.user.verified} \n" \
|
||||
f"Restricted: {target_user.user.restricted} \n" \
|
||||
f"Type: {user_type} \n" \
|
||||
f"Permanent Link: [{first_name}](tg://user?id={target_user.user.id})"
|
||||
biography = target_user.about if target_user.about is not None else "没有公开的情报"
|
||||
caption = f"**用户简介:** \n" \
|
||||
f"道纹: {username_system} \n" \
|
||||
f"ID: {target_user.user.id} \n" \
|
||||
f"名字: {first_name} \n" \
|
||||
f"姓氏: {last_name} \n" \
|
||||
f"目前已知的情报: {biography} \n" \
|
||||
f"共同裙: {target_user.common_chats_count} \n" \
|
||||
f"官方认证: {target_user.user.verified} \n" \
|
||||
f"受限制: {target_user.user.restricted} \n" \
|
||||
f"类型: {user_type} \n" \
|
||||
f"[{first_name}](tg://user?id={target_user.user.id})"
|
||||
reply_to = context.message.reply_to_msg_id
|
||||
photo = await context.client.download_profile_photo(
|
||||
target_user.user.id,
|
||||
"./" + str(target_user.user.id) + ".jpg",
|
||||
download_big=True
|
||||
)
|
||||
target_user.user.id,
|
||||
"./" + str(target_user.user.id) + ".jpg",
|
||||
download_big=True
|
||||
)
|
||||
|
||||
if not reply_to:
|
||||
reply_to = None
|
||||
try:
|
||||
@ -226,7 +227,7 @@ async def profile(context):
|
||||
if not photo.startswith("http"):
|
||||
remove(photo)
|
||||
await context.delete()
|
||||
remove(photo)
|
||||
return
|
||||
except TypeError:
|
||||
await context.edit(caption)
|
||||
remove(photo)
|
||||
await context.edit(caption)
|
@ -42,7 +42,7 @@ async def translate(context):
|
||||
|
||||
source_lang = LANGUAGES[f'{result.src.lower()}']
|
||||
trans_lang = LANGUAGES[f'{result.dest.lower()}']
|
||||
result = f"**Translated** from {source_lang.title()}:\n{result.text}"
|
||||
result = f"**文本翻译** 源语言 {source_lang.title()}:\n{result.text}"
|
||||
|
||||
if len(result) > 4096:
|
||||
await context.edit("出错了呜呜呜 ~ 输出超出 TG 限制,正在附加文件。")
|
||||
@ -50,9 +50,9 @@ async def translate(context):
|
||||
return
|
||||
await context.edit(result)
|
||||
if len(result) <= 4096:
|
||||
await log(f"Translated `{message}` from {source_lang} to {trans_lang}.")
|
||||
await log(f"把 `{message}` 从 {source_lang} 翻译到了 {trans_lang}")
|
||||
else:
|
||||
await log(f"Translated message from {source_lang} to {trans_lang}.")
|
||||
await log(f"把一条消息从 {source_lang} 翻译到了 {trans_lang}.")
|
||||
|
||||
|
||||
@listener(outgoing=True, command="tts",
|
||||
@ -130,10 +130,18 @@ async def google(context):
|
||||
|
||||
@listener(outgoing=True, command="fetchaudio",
|
||||
description="从多个平台获取音频文件。",
|
||||
parameters="<url>")
|
||||
parameters="<url>,<string>")
|
||||
async def fetchaudio(context):
|
||||
if context.arguments:
|
||||
if ',' in context.arguments:
|
||||
url, string_2 = context.arguments.split(',', 1)
|
||||
else:
|
||||
url = context.arguments
|
||||
string_2 = "#audio "
|
||||
else:
|
||||
await context.edit("出错了呜呜呜 ~ 错误的语法。")
|
||||
return
|
||||
""" Fetches audio from provided URL. """
|
||||
url = context.arguments
|
||||
reply = await context.get_reply_message()
|
||||
reply_id = None
|
||||
await context.edit("拉取音频中 . . .")
|
||||
@ -144,7 +152,7 @@ async def fetchaudio(context):
|
||||
return
|
||||
youtube_pattern = regex_compile(r"^(http(s)?://)?((w){3}.)?youtu(be|.be)?(\.com)?/.+")
|
||||
if youtube_pattern.match(url):
|
||||
if not await fetch_youtube_audio(url, context.chat_id, reply_id):
|
||||
if not await fetch_youtube_audio(url, context.chat_id, reply_id, string_2):
|
||||
await context.edit("出错了呜呜呜 ~ 原声带下载失败。")
|
||||
await log(f"从链接中获取了一条音频,链接: {url}.")
|
||||
|
||||
|
@ -78,7 +78,7 @@ async def random_gen(selection, length=64):
|
||||
return await execute(f"head -c 65536 /dev/urandom | tr -dc {selection} | head -c {length} ; echo \'\'")
|
||||
|
||||
|
||||
async def fetch_youtube_audio(url, chat_id, reply_id):
|
||||
async def fetch_youtube_audio(url, chat_id, reply_id, string_2):
|
||||
""" Extracts and uploads audio from YouTube video. """
|
||||
youtube_dl_options = {
|
||||
'format': 'bestaudio/best',
|
||||
@ -95,7 +95,8 @@ async def fetch_youtube_audio(url, chat_id, reply_id):
|
||||
await bot.send_file(
|
||||
chat_id,
|
||||
"audio.mp3",
|
||||
reply_to=reply_id
|
||||
reply_to=reply_id,
|
||||
caption=str(string_2)
|
||||
)
|
||||
remove("audio.mp3")
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user