__version__ = (0, 0, 1)
# *
# * $$\ $$\ $$\ $$\ $$\
# * $$ | \__| $$ | $$ | $$ |
# * $$$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$\$$$$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$ | $$$$$$\ $$$$$$$\
# * $$ _____|$$ __$$\ $$ |\_$$ _| $$ _$$ _$$\ $$ __$$\ $$ __$$ |$$ | $$ |$$ |$$ __$$\ $$ _____|
# * \$$$$$$\ $$ | $$ |$$ | $$ | $$ / $$ / $$ |$$ / $$ |$$ / $$ |$$ | $$ |$$ |$$$$$$$$ |\$$$$$$\
# * \____$$\ $$ | $$ |$$ | $$ |$$\ $$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | $$ |$$ |$$ ____| \____$$\
# * $$$$$$$ |$$ | $$ |$$ | \$$$$ |$$ | $$ | $$ |\$$$$$$ |\$$$$$$$ |\$$$$$$ |$$ |\$$$$$$$\ $$$$$$$ |
# * \_______/ \__| \__|\__| \____/ \__| \__| \__| \______/ \_______| \______/ \__| \_______|\_______/
# *
# *
# * © Copyright 2022/2023
# *
# * https://t.me/shitmodules
# *
# 🔒 Code is licensed under CC-BY-NC-ND 4.0 unless otherwise specified.
# 🌐 https://creativecommons.org/licenses/by-nc-nd/4.0/
# You CANNOT edit this file without direct permission from the author.
# You can redistribute this file without any changes.
# scope: hikka_only
# scope: hikka_min 1.6.2
# meta pic: https://raw.githubusercontent.com/kamolgks/assets/main/AnonUploader.jpg
# meta banner: https://raw.githubusercontent.com/kamolgks/assets/main/AnonymUploader.jpg
# meta developer: @shitmodules
import re
import io
import random
import logging
import requests
from .. import loader, utils
from telethon.tl.types import Message
from telethon.errors.rpcerrorlist import YouBlockedUserError
logger = logging.getLogger(__name__)
@loader.tds
class AnonymUploader(loader.Module):
"""Anonymous files upload via anonfiles.com"""
strings = {
"name": "AnonymUploader",
"uploading": "🚀 Uploading...",
"noargs": "🚫 No file specified",
"bot_blocked": "🚫 Unban @anonfiles_com_bot",
}
strings_ru = {
"uploading": "🚀 Загрузка...",
"noargs": "🚫 Файл не указан",
"bot_blocked": "🚫 Разблокируй @anonfiles_com_bot",
}
async def get_media(self, message: Message):
reply = await message.get_reply_message()
m = None
if reply and reply.media:
m = reply
elif message.media:
m = message
elif not reply:
await utils.answer(message, self.strings("noargs"))
return False
if not m:
file = io.BytesIO(bytes(reply.raw_text, "utf-8"))
file.name = "file.txt"
else:
file = io.BytesIO(await self._client.download_media(m, bytes))
file.name = (
m.file.name
or (
"".join(
[
random.choice(
"abcdefghijklmnopqrstuvwxyz1234567890")
for _ in range(16)
]
)
)
+ m.file.ext
)
return file
@loader.command()
async def auplcmd(self, message: Message):
"""> - Anonymous file Uploader"""
chat = "@anonfiles_com_bot"
message = await utils.answer(message, self.strings("uploading"))
file = await self.get_media(message)
async with self._client.conversation(chat) as conv:
try:
m = await conv.send_message(file=file)
response = await conv.get_response()
except YouBlockedUserError:
await utils.answer(message, self.strings("bot_blocked"))
return
await m.delete()
await response.delete()
await self.client.delete_dialog(chat)
try:
url = (
re.search(
r'🪄Your file uploaded: {url}")