MissKatyPyro/misskaty/plugins/json.py
yasirarism f6f9b6c007
Changed base docker to alphine and add again pillow v10 (#179)
* Update chatbot_ai.py

* tes pake alpine

* add again pillow v10

* tes nulis in pil 10

* hmm

* style: format code with black and isort (#180)

Format code with black and isort

This commit fixes the style issues introduced in 41d4f24 according to the output
from Black and isort.

Details: https://app.deepsource.com/gh/yasirarism/MissKatyPyro/transform/ba70f1a7-7e6f-4f79-8251-c9db81fe86c5/

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>

---------

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2023-07-12 13:44:08 +07:00

50 lines
1.5 KiB
Python

"""
* @author yasir <yasiramunandar@gmail.com>
* @date 2022-12-01 09:12:27
* @projectName MissKatyPyro
* Copyright @YasirPedia All rights reserved
"""
import os
from pyrogram import filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from misskaty import app
from misskaty.core.decorator.ratelimiter import ratelimiter
from misskaty.vars import COMMAND_HANDLER
# View Structure Telegram Message As JSON
@app.on_cmd("json")
@ratelimiter
async def jsonify(_, message: Message):
the_real_message = None
reply_to_id = None
the_real_message = message.reply_to_message or message
try:
await message.reply_text(
f"<code>{the_real_message}</code>",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{message.from_user.id}",
)
]
]
),
)
except Exception as e:
with open("json.txt", "w+", encoding="utf8") as out_file:
out_file.write(str(the_real_message))
await message.reply_document(
document="json.txt",
caption=f"<code>{str(e)}</code>",
disable_notification=True,
reply_to_message_id=reply_to_id,
thumb="assets/thumb.jpg",
)
os.remove("json.txt")