refactor: userbot to subtree

This commit is contained in:
2026-06-19 23:20:13 +02:00
parent 1930600c40
commit 69ffd3682e
134 changed files with 224 additions and 15451 deletions
-47
View File
@@ -1,47 +0,0 @@
import os
import pygments
from pygments.formatters import ImageFormatter
from pygments.lexers import Python3Lexer
from pyrogram import Client, filters
from pyrogram.errors import MessageNotModified
from pyrogram.types import Message
from utils.misc import modules_help, prefix
@Client.on_message(filters.command('ncode', prefix) & filters.me)
async def coder_print(client, message: Message):
if message.reply_to_message:
reply_message = message.reply_to_message
if reply_message.media:
download_path = await client.download_media(reply_message)
with open(download_path) as file:
code = file.read()
if os.path.exists(download_path):
os.remove(download_path)
pygments.highlight(
f'{code}',
Python3Lexer(),
ImageFormatter(font_name='DejaVu Sans Mono', line_numbers=True),
'result.png',
)
try:
sent_message = await message.edit_text('Pasting this code on my page...')
await client.send_document(
chat_id=message.chat.id,
document='result.png',
caption='Code highlighted by Pygments',
reply_to_message_id=message.id,
)
except MessageNotModified:
pass
await sent_message.delete()
if os.path.exists('result.png'):
os.remove('result.png')
else:
return await message.reply_text('Please reply to a text or a file.')
else:
return await message.reply_text('Please reply to a text or a file.')
modules_help['ncode'] = {'ncode': 'Highlight the code using Pygments and send it as an image.'}