# * _ __ __ _ _ # * / \ _ _ _ __ ___ _ __ __ _| \/ | ___ __| |_ _| | ___ ___ # * / _ \| | | | '__/ _ \| '__/ _` | |\/| |/ _ \ / _` | | | | |/ _ \/ __| # * / ___ \ |_| | | | (_) | | | (_| | | | | (_) | (_| | |_| | | __/\__ \ # * /_/ \_\__,_|_| \___/|_| \__,_|_| |_|\___/ \__,_|\__,_|_|\___||___/ # * # * © Copyright 2026 # * # * https://t.me/AuroraModules # * # * 🔒 Code is licensed under GNU AGPLv3 # * 🌐 https://www.gnu.org/licenses/agpl-3.0.html # * ⛔️ You CANNOT edit this file without direct permission from the author. # * ⛔️ You CANNOT distribute this file if you have modified it without the direct permission of the author. # Name: InvalidFiles # Author: Felix? # Commands: # .CreateInvalidFile (cifile) | .FormatFiles (ffiles) # scope: hikka_only # meta developer: @AuroraModules __version__ = (1, 0, 0) import os import re import time from .. import loader, utils # type: ignore from telethon.tl.types import Message # type: ignore from telethon.tl.functions.messages import EditMessageRequest # type: ignore from telethon.tl.types import InputMediaUploadedDocument, DocumentAttributeFilename # type: ignore @loader.tds class InvalidFilesMod(loader.Module): """Module for creating corrupted (broken) files of any format.""" strings = { "name": "InvalidFiles", "invalid_format": " Invalid size format.", "max_size": " Maximum file size is 2GB", "file_created": ( " File successfully created and sent.\n\n" "
" "👤 File name: {}\n" "⚖️ Size: {}{}\n" "⌛️ Creation: {:.2f} sec.\n" "📤 Upload: {:.2f} sec." "
" ), "invalid_args": ( " Invalid arguments\n\n" "Usage: {prefix}cifile <name> <size>\n" "Example: {prefix}cifile test.txt 3.4mb\n\n" "Supported: b, kb, mb, gb" ), "creating": "⌛️ Creating file...\n\n*Large files may take a long time to upload.", "error": "⚠️ Error:\n{}", "formats": ( "📂 Popular file extensions:\n\n" "📄 Documents: .txt .docx .pdf .rtf\n" "📊 Spreadsheets: .xlsx .csv\n" "📈 Presentations: .pptx\n" "🖼️ Images: .jpg .png .gif .bmp .webp\n" "🎵 Audio: .mp3 .wav .flac\n" "🎬 Video: .mp4 .mkv .avi\n" "📦 Archives: .zip .rar .7z\n" "💻 Code: .py .js .html .css .json" ), } strings_ru = { "invalid_format": " Неверный формат размера.", "max_size": " Максимальный размер файла — 2GB", "file_created": ( " Файл успешно создан и отправлен.\n\n" "
" "👤 Имя файла: {}\n" "⚖️ Размер: {}{}\n" "⌛️ Создание: {:.2f} сек.\n" "📤 Отправка: {:.2f} сек." "
" ), "invalid_args": ( " Неверные аргументы\n\n" "Использование: {prefix}cifile <имя> <размер>\n" "Пример: {prefix}cifile test.txt 3.4mb\n\n" "Поддерживаются: b, kb, mb, gb" ), "creating": "⌛️ Создаю файл...\n\n*Файлы большого размера могут долго загружаться.", "error": "⚠️ Ошибка:\n{}", "formats": ( "📂 Популярные расширения файлов:\n\n" "📄 Документы: .txt .docx .pdf .rtf\n" "📊 Таблицы: .xlsx .csv\n" "📈 Презентации: .pptx\n" "🖼️ Изображения: .jpg .png .gif .bmp .webp\n" "🎵 Аудио: .mp3 .wav .flac\n" "🎬 Видео: .mp4 .mkv .avi\n" "📦 Архивы: .zip .rar .7z\n" "💻 Код: .py .js .html .css .json" ), } strings_uz = { "invalid_format": " Hajm formati noto‘g‘ri.", "max_size": " Maksimal fayl hajmi — 2GB", "file_created": ( " Fayl muvaffaqiyatli yaratildi va yuborildi.\n\n" "
" "👤 Fayl nomi: {}\n" "⚖️ Hajmi: {}{}\n" "⌛️ Yaratish: {:.2f} sek.\n" "📤 Yuborish: {:.2f} sek." "
" ), "invalid_args": ( " Noto‘g‘ri argumentlar\n\n" "Foydalanish: {prefix}cifile <nom> <hajm>\n" "Misol: {prefix}cifile test.txt 3.4mb\n\n" "Qo‘llab-quvvatlanadi: b, kb, mb, gb" ), "creating": "⌛️ Fayl yaratilmoqda...\n\n*Katta fayllar uzoq yuklanishi mumkin.", "error": "⚠️ Xatolik:\n{}", "formats": ( "📂 Mashhur fayl kengaytmalari:\n\n" "📄 Hujjatlar: .txt .docx .pdf .rtf\n" "📊 Jadvallar: .xlsx .csv\n" "📈 Taqdimotlar: .pptx\n" "🖼️ Rasmlar: .jpg .png .gif .bmp .webp\n" "🎵 Audio: .mp3 .wav .flac\n" "🎬 Video: .mp4 .mkv .avi\n" "📦 Arxivlar: .zip .rar .7z\n" "💻 Kod: .py .js .html .css .json" ), } strings_de = { "invalid_format": " Ungültiges Größenformat.", "max_size": " Maximale Dateigröße — 2GB", "file_created": ( " Datei erfolgreich erstellt und gesendet.\n\n" "
" "👤 Dateiname: {}\n" "⚖️ Größe: {}{}\n" "⌛️ Erstellung: {:.2f} Sek.\n" "📤 Upload: {:.2f} Sek." "
" ), "invalid_args": ( " Ungültige Argumente\n\n" "Verwendung: {prefix}cifile <name> <größe>\n" "Beispiel: {prefix}cifile test.txt 3.4mb\n\n" "Unterstützt: b, kb, mb, gb" ), "creating": "⌛️ Datei wird erstellt...\n\n*Große Dateien können lange zum Hochladen brauchen.", "error": "⚠️ Fehler:\n{}", "formats": ( "📂 Beliebte Dateiendungen:\n\n" "📄 Dokumente: .txt .docx .pdf .rtf\n" "📊 Tabellen: .xlsx .csv\n" "📈 Präsentationen: .pptx\n" "🖼️ Bilder: .jpg .png .gif .bmp .webp\n" "🎵 Audio: .mp3 .wav .flac\n" "🎬 Video: .mp4 .mkv .avi\n" "📦 Archive: .zip .rar .7z\n" "💻 Code: .py .js .html .css .json" ), } strings_es = { "invalid_format": " Formato de tamaño inválido.", "max_size": " El tamaño máximo del archivo es 2GB", "file_created": ( " Archivo creado y enviado correctamente.\n\n" "
" "👤 Nombre del archivo: {}\n" "⚖️ Tamaño: {}{}\n" "⌛️ Creación: {:.2f} seg.\n" "📤 Subida: {:.2f} seg." "
" ), "invalid_args": ( " Argumentos inválidos\n\n" "Uso: {prefix}cifile <nombre> <tamaño>\n" "Ejemplo: {prefix}cifile test.txt 3.4mb\n\n" "Soportado: b, kb, mb, gb" ), "creating": "⌛️ Creando archivo...\n\n*Los archivos grandes pueden tardar en subirse.", "error": "⚠️ Error:\n{}", "formats": ( "📂 Extensiones de archivo populares:\n\n" "📄 Documentos: .txt .docx .pdf .rtf\n" "📊 Hojas de cálculo: .xlsx .csv\n" "📈 Presentaciones: .pptx\n" "🖼️ Imágenes: .jpg .png .gif .bmp .webp\n" "🎵 Audio: .mp3 .wav .flac\n" "🎬 Video: .mp4 .mkv .avi\n" "📦 Archivos: .zip .rar .7z\n" "💻 Código: .py .js .html .css .json" ), } async def create_invalid_file(self, filename: str, size_str: str): match = re.fullmatch(r"(\d+(?:\.\d+)?)(b|kb|mb|gb)", size_str.lower()) if not match: return False, self.strings["invalid_format"] multiplier = { "b": 1, "kb": 1024, "mb": 1024 ** 2, "gb": 1024 ** 3, } size_value = float(match.group(1)) unit = match.group(2) total_bytes = int(size_value * multiplier[unit]) if total_bytes > 2 * 1024 ** 3: return False, self.strings["max_size"] start_time = time.time() try: with open(filename, "wb") as f: remaining = total_bytes chunk = 5 * 1024 * 1024 while remaining > 0: write_size = min(chunk, remaining) f.write(os.urandom(write_size)) remaining -= write_size except Exception as e: return False, self.strings["error"].format(e) elapsed = time.time() - start_time return True, (filename, size_value, unit, elapsed) @loader.command( ru_doc="<имя>.<формат> <размер> — создать битый файл", uz_doc=". — buzilgan fayl yaratish", de_doc=". — beschädigte Datei erstellen", es_doc=". — crear archivo corrupto", alias="cifile" ) async def CreateInvalidFile(self, message: Message): """. - create corrupted file""" args = utils.get_args_raw(message).split() if len(args) != 2: await utils.answer( message, self.strings("invalid_args").format(prefix=self.get_prefix()) ) return filename, size_str = args status = await utils.answer(message, self.strings("creating")) success, data = await self.create_invalid_file(filename, size_str) if not success: await utils.answer(status, data) return filename, size_value, unit, create_time = data try: start_upload = time.time() uploaded = await self.client.upload_file(filename) upload_time = time.time() - start_upload media = InputMediaUploadedDocument( file=uploaded, mime_type="application/octet-stream", attributes=[DocumentAttributeFilename(file_name=filename)] ) await self.client(EditMessageRequest( peer=message.chat_id, id=status.id, message="", media=media )) await utils.answer( status, self.strings["file_created"].format( filename, size_value, unit, create_time, upload_time ) ) except Exception as e: await utils.answer(status, self.strings["error"].format(e)) finally: if os.path.exists(filename): try: os.remove(filename) except Exception: pass @loader.command( ru_doc="— показать список популярных форматов(расширейний) файлов", uz_doc="— mashhur fayl formatlari (kengaytmalari) ro'yxatini ko'rsatish", de_doc="— eine Liste gängiger Dateiformate (Erweiterungen) anzeigen", es_doc="— mostrar una lista de formatos de archivo (extensiones) populares", alias="ffiles" ) async def FormatFiles(self, message: Message): """— show a list of popular file formats (extensions)""" await utils.answer(message, self.strings('formats'))