-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnonymUploader.py
126 lines (106 loc) · 4.37 KB
/
AnonymUploader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
__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": "🚀 <b>Uploading...</b>",
"noargs": "🚫 <b>No file specified</b>",
"bot_blocked": "🚫 <b>Unban @anonfiles_com_bot</b>",
}
strings_ru = {
"uploading": "🚀 <b>Загрузка...</b>",
"noargs": "🚫 <b>Файл не указан</b>",
"bot_blocked": "🚫 <b>Разблокируй @anonfiles_com_bot</b>",
}
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):
"""> <reply to file> - 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'<meta property="og:image" data-react-helmet="true"',
r' content="(.*?)"',
(await utils.run_sync(requests.get, response.raw_text)).text,
)
.group(1)
.split("?")[0]
)
except Exception:
url = response.raw_text
await utils.answer(message, f"<b>🪄Your file uploaded: <code>{url}</code></b>")