parent
7f936d68d0
commit
e0e7d631b8
@ -131,7 +131,8 @@ parseqr_log: Parsed QR Code with content
|
||||
convert_des: Reply to an attachment message and convert it to image output
|
||||
convert_process: Converting...
|
||||
convert_no_file: Something went wrong. There seems to be no attachment in the reply message.
|
||||
convert_error: Something went wrong, woooo~ An error occurred during the conversion.
|
||||
convert_error: Something went wrong, woooo ~ An error occurred during the conversion.
|
||||
convert_invalid: Something went wrong, woooo ~ The photo dimensions are invalid.
|
||||
# caption
|
||||
caption_des: Add two lines of captions to the reply picture. The captions will be added to the top and bottom respectively. The captions need to be separated by commas.
|
||||
caption_process: The image is being rendered...
|
||||
|
@ -139,6 +139,7 @@ convert_des: 回复某条附件消息然后转换为图片输出
|
||||
convert_process: 正在转换中 . . .
|
||||
convert_no_file: 出错了呜呜呜 ~ 回复的消息中好像没有附件。
|
||||
convert_error: 出错了呜呜呜 ~ 转换期间发生了错误。
|
||||
convert_invalid: 出错了呜呜呜 ~ 图片尺寸无效。
|
||||
## caption
|
||||
caption_des: 将两行字幕添加到回复的图片中,字幕将分别添加到顶部和底部,字幕需要以逗号分隔。
|
||||
caption_process: 正在渲染图像中 . . .
|
||||
|
@ -127,6 +127,7 @@ convert_des: 回覆附件訊息並轉換為圖片
|
||||
convert_process: 正在轉換……
|
||||
convert_no_file: Error!回覆的消息沒有附件。
|
||||
convert_error: Error!轉換期間發生錯誤!
|
||||
convert_invalid: Error!圖片尺寸無效!
|
||||
# caption
|
||||
caption_des: 將兩行字幕添加到回覆的照片中,分別位於底部和頂部,請以逗號分割兩句。
|
||||
caption_process: 正在渲染照片…
|
||||
|
@ -5,6 +5,8 @@ from magic import Magic
|
||||
from pygments import highlight as syntax_highlight
|
||||
from pygments.formatters import img
|
||||
from pygments.lexers import guess_lexer
|
||||
from telethon.errors import PhotoInvalidDimensionsError
|
||||
|
||||
from pagermaid import log, module_dir
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import execute, upload_attachment, lang, alias_command
|
||||
@ -33,11 +35,15 @@ async def convert(context):
|
||||
await context.edit(lang('convert_error'))
|
||||
return
|
||||
if not result:
|
||||
await handle_failure(context, target_file_path)
|
||||
await handle_failure(context, target_file_path, 'convert_error')
|
||||
return
|
||||
if not await upload_attachment("result.png", context.chat_id, reply_id):
|
||||
await context.edit(lang('convert_error'))
|
||||
remove(target_file_path)
|
||||
try:
|
||||
if not await upload_attachment("result.png", context.chat_id, reply_id):
|
||||
await context.edit(lang('convert_error'))
|
||||
remove(target_file_path)
|
||||
return
|
||||
except PhotoInvalidDimensionsError:
|
||||
await handle_failure(context, target_file_path, 'convert_invalid')
|
||||
return
|
||||
await context.delete()
|
||||
remove(target_file_path)
|
||||
@ -80,11 +86,15 @@ async def caption(context):
|
||||
f"\"{str(string_1)}\" \"{str(string_2)}\"")
|
||||
result_file = "result.gif"
|
||||
if not result:
|
||||
await handle_failure(context, target_file_path)
|
||||
await handle_failure(context, target_file_path, 'convert_error')
|
||||
return
|
||||
if not await upload_attachment(result_file, context.chat_id, reply_id):
|
||||
await context.edit(lang('caption_error'))
|
||||
remove(target_file_path)
|
||||
try:
|
||||
if not await upload_attachment(result_file, context.chat_id, reply_id):
|
||||
await context.edit(lang('caption_error'))
|
||||
remove(target_file_path)
|
||||
return
|
||||
except PhotoInvalidDimensionsError:
|
||||
await handle_failure(context, target_file_path, 'convert_invalid')
|
||||
return
|
||||
await context.delete()
|
||||
if string_2 != " ":
|
||||
@ -188,8 +198,8 @@ async def highlight(context):
|
||||
await context.delete()
|
||||
|
||||
|
||||
async def handle_failure(context, target_file_path):
|
||||
await context.edit(lang('handle_failure_error'))
|
||||
async def handle_failure(context, target_file_path, name):
|
||||
await context.edit(lang(name))
|
||||
try:
|
||||
remove("result.png")
|
||||
remove(target_file_path)
|
||||
|
Loading…
Reference in New Issue
Block a user