-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathKUploader.py
More file actions
184 lines (173 loc) · 7.59 KB
/
KUploader.py
File metadata and controls
184 lines (173 loc) · 7.59 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import io
import json
from pyrogram import Client, filters
from command import fox_command, fox_sudo, who_message
from requirements_installer import install_library
import os
install_library("requests -U")
import requests
@Client.on_message(fox_command("catbox", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def catbox_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.post(
"https://catbox.moe/user/api.php",
files={"fileToUpload": file},
data={"reqtype": "fileupload"}
)
if response.ok:
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(response.text))
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
@Client.on_message(fox_command("envs", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def envs_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.post("https://envs.sh", files={"file": file})
if response.ok:
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(response.text))
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
@Client.on_message(fox_command("kappa", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def kappa_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.post("https://kappa.lol/api/upload", files={"file": file})
if response.ok:
data = response.json()
url = f"https://kappa.lol/{data['id']}"
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(url))
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
@Client.on_message(fox_command("0x0", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def oxo_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.post(
"https://0x0.st",
files={"file": file},
data={"secret": True}
)
if response.ok:
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(response.text))
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
@Client.on_message(fox_command("x0", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def x0_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.post("https://x0.at", files={"file": file})
if response.ok:
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(response.text))
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
@Client.on_message(fox_command("tmpfiles", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def tmpfiles_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.post(
"https://tmpfiles.org/api/v1/upload",
files={"file": file}
)
if response.ok:
data = json.loads(response.text)
url = data["data"]["url"]
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(url))
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
@Client.on_message(fox_command("pomf", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def pomf_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.post(
"https://pomf.lain.la/upload.php",
files={"files[]": file}
)
if response.ok:
data = json.loads(response.text)
url = data["files"][0]["url"]
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(url))
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
@Client.on_message(fox_command("bash", "Uploader", os.path.basename(__file__)) & fox_sudo())
async def bash_handler(client, message):
message = await who_message(client, message)
await message.edit("⚡ <b>Uploading file...</b>")
file = await get_file(client, message)
if not file:
return
try:
response = requests.put(
"https://bashupload.com",
data=file.read()
)
if response.ok:
urls = [line for line in response.text.split("\n") if "wget" in line]
if urls:
url = urls[0].split()[-1]
await message.edit("❤️ <b>File uploaded!</b>\n\n🔥 <b>URL:</b> <code>{}</code>".format(url))
else:
await message.edit("❌ <b>Error while uploading: Could not find URL</b>")
else:
await message.edit("❌ <b>Error while uploading: {}</b>".format(response.status_code))
except Exception as e:
await message.edit("❌ <b>Error while uploading: {}</b>".format(str(e)))
async def get_file(client, message):
reply = message.reply_to_message
if not reply:
await message.edit("❌ <b>Reply to file!</b>")
return None
if reply.media:
downloaded = await reply.download(in_memory=True)
if reply.document:
downloaded.name = reply.document.file_name or f"file_{reply.document.file_size}"
else:
downloaded.name = f"file_{reply.id}.jpg"
return downloaded
else:
text = reply.text or reply.caption or ""
file = io.BytesIO(text.encode("utf-8"))
file.name = "text.txt"
return file