-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path0x.py
More file actions
39 lines (33 loc) · 1.01 KB
/
0x.py
File metadata and controls
39 lines (33 loc) · 1.01 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
from .. import loader, utils # pylint: disable=relative-beyond-top-level
from requests import post
import io
@loader.tds
class x0Mod(loader.Module):
"""Uploader"""
strings = {
"name": "x0 Uploader"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def x0cmd(self, message):
await message.edit("<b>Uploading...</b>")
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>Reply to message!</b>")
return
media = reply.media
if not media:
file = io.BytesIO(bytes(reply.raw_text, "utf-8"))
file.name = "txt.txt"
else:
file = io.BytesIO(await self.client.download_file(media))
file.name = reply.file.name if reply.file.name else reply.file.id+reply.file.ext
try:
x0at = post('https://x0.at', files={'file': file})
except ConnectionError as e:
await message.edit(ste(e))
return
url = x0at.text
output = f'<a href="{url}">URL: </a><code>{url}</code>'
await message.edit(output)