chore(userbot): apply ruff check --fix and ruff format
- ruff check --fix: 210 auto-fixed errors (import sorting, trailing whitespace, unused imports, f-string fixups, deprecated annotations) - ruff format: 104 files reformatted to consistent style - 268 non-auto-fixable issues remain (S113 requests timeout, etc.)
This commit is contained in:
+11
-13
@@ -15,37 +15,35 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from utils.misc import modules_help
|
||||
from utils.scripts import prefix, import_library, with_reply
|
||||
from utils.scripts import import_library, prefix, with_reply
|
||||
|
||||
import_library("markitdown")
|
||||
import_library('markitdown')
|
||||
|
||||
from markitdown import MarkItDown
|
||||
|
||||
|
||||
@Client.on_message(filters.command(["markitdown", "mkdn"], prefix) & filters.me)
|
||||
@Client.on_message(filters.command(['markitdown', 'mkdn'], prefix) & filters.me)
|
||||
@with_reply
|
||||
async def markitdown(client: Client, message: Message):
|
||||
if message.reply_to_message.document:
|
||||
await message.edit("Converting to Markdown...")
|
||||
await message.edit('Converting to Markdown...')
|
||||
file = await message.reply_to_message.download()
|
||||
file_name = (message.reply_to_message.document.file_name).split(".")[0] + ".md"
|
||||
file_name = (message.reply_to_message.document.file_name).split('.')[0] + '.md'
|
||||
markitdown = MarkItDown()
|
||||
result = markitdown.convert(file)
|
||||
with open(file_name, "w") as f:
|
||||
with open(file_name, 'w') as f:
|
||||
f.write(result.text_content)
|
||||
await message.edit("Uploading...")
|
||||
await client.send_document(
|
||||
message.chat.id, file_name, reply_to_message_id=message.reply_to_message.id
|
||||
)
|
||||
await message.edit('Uploading...')
|
||||
await client.send_document(message.chat.id, file_name, reply_to_message_id=message.reply_to_message.id)
|
||||
os.remove(file)
|
||||
os.remove(file_name)
|
||||
await message.delete()
|
||||
else:
|
||||
await message.edit("Reply to a document to convert it to Markdown.")
|
||||
await message.edit('Reply to a document to convert it to Markdown.')
|
||||
|
||||
|
||||
modules_help["markitdown"] = {"markitdown": "Convert a document to Markdown."}
|
||||
modules_help['markitdown'] = {'markitdown': 'Convert a document to Markdown.'}
|
||||
|
||||
Reference in New Issue
Block a user