-
Notifications
You must be signed in to change notification settings - Fork 5
/
fileconverter.py
188 lines (153 loc) Β· 5.72 KB
/
fileconverter.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
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
185
186
187
188
"""plugin made for reading nd exploting message in tg {i}reveal <reply to file>"""
# originally made by @ItzSjDude All Rights reserved!!
# Added Paste System by @danish_00
# All Credits - @ItzSjDude #Added Paste System by @danish_00
# @ItzSjDude
# @ItzSjDude
# Added Paste System by @danish_00
import os, requests, re
import asyncio
import time
from datetime import datetime
from ULTRA.utils import admin_cmd, sudo_cmd , edit_or_reply
from ULTRA import CMD_HELP, bot
@borg.on(admin_cmd(pattern=r"open", outgoing=True))
async def _(event):
b = await event.client.download_media(await event.get_reply_message())
a = open(b, "r")
c = a.read()
a.close()
a = await event.reply("Reading file...")
if len(c) >= 4096:
await event.edit("output file too large lemme paste it ππ")#hehe
out = c
url = "https://del.dog/documents"
r = requests.post(url, data=out.encode("UTF-8")).json()
url = f"https://del.dog/{r['key']}"
await event.edit(
f" Output file is too large Not supported By Telegram\n**So Pasted to** [Dog Bin]({url}) ππ", link_preview=False)
await a.delete()
else:
await event.client.send_message(event.chat_id, f"{c}")
await a.delete()
os.remove(b)
@borg.on(admin_cmd(pattern="doc ?(.*)"))
async def get(event):
name = event.text[5:]
if name is None:
await event.edit("reply to text message as .ttf <file name>")
return
m = await event.get_reply_message()
if m.text:
with open(name, "w") as f:
f.write(m.message)
await event.delete()
await event.client.send_file(event.chat_id, name, force_document=True)
os.remove(name)
else:
await event.edit("reply to text message as .doc <file name.extension>")
#hehe
#.stoi nd .itos made by @danish_00
#teamcobra
#hehe
thumb_image_path = Config.TMP_DOWNLOAD_DIRECTORY + "thumb_image.jpg"
@borg.on(admin_cmd(pattern="stoi"))
@borg.on(sudo_cmd(pattern="stoi", allow_sudo=True))
async def danish(hehe):
if hehe.fwd_from:
return
thumb = None
reply_to_id = hehe.message.id
if hehe.reply_to_msg_id:
reply_to_id = hehe.reply_to_msg_id
cobra = await edit_or_reply(hehe, "Converting.....")
input_str = "dc.jpeg"
if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
if cobra.reply_to_msg_id:
start = datetime.now()
file_name = input_str
reply_message = await cobra.get_reply_message()
to_download_directory = Config.TMP_DOWNLOAD_DIRECTORY
downloaded_file_name = os.path.join(to_download_directory, file_name)
downloaded_file_name = await hehe.client.download_media(
reply_message,
downloaded_file_name
)
try:
thumb = await reply_message.download_media(thumb=-1)
except Exception:
thumb = thumb
if os.path.exists(downloaded_file_name):
dc = await hehe.client.send_file(
hehe.chat_id,
downloaded_file_name,
force_document=False,
supports_streaming=True,
allow_cache=False,
reply_to=reply_message,
thumb=thumb
)
os.remove(downloaded_file_name)
await cobra.delete()
else:
await cobra.edit("Something went wrong")
else:
await cobra.edit("reply to a non animated sticker")
#hehe
@borg.on(admin_cmd(pattern="itos"))
@borg.on(sudo_cmd(pattern="itos", allow_sudo=True))
async def teamcobra(hehe):
if hehe.fwd_from:
return
thumb = None
reply_to_id = hehe.message.id
if hehe.reply_to_msg_id:
reply_to_id = hehe.reply_to_msg_id
cobra = await edit_or_reply(hehe, "Converting.....")
input_str = "dc.webp"
if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
if cobra.reply_to_msg_id:
start = datetime.now()
file_name = input_str
reply_message = await cobra.get_reply_message()
to_download_directory = Config.TMP_DOWNLOAD_DIRECTORY
downloaded_file_name = os.path.join(to_download_directory, file_name)
downloaded_file_name = await hehe.client.download_media(
reply_message,
downloaded_file_name
)
try:
thumb = await reply_message.download_media(thumb=-1)
except Exception:
thumb = thumb
if os.path.exists(downloaded_file_name):
dc = await hehe.client.send_file(
hehe.chat_id,
downloaded_file_name,
force_document=False,
supports_streaming=True,
allow_cache=False,
reply_to=reply_message,
thumb=thumb
)
os.remove(downloaded_file_name)
await cobra.delete()
else:
await cobra.edit("Something went wrong")
else:
await cobra.edit("reply to a non animated sticker")
CMD_HELP.update(
{
"fileconverter": "PLUGIN NAME : fileconverter\
\n\nπ CMD β
.open\
\nUSAGE β
open files as text (id the amount of words r resonable)\
\n\nπ CMD β
.doc <file name.extension> <reply to any text/media>\
\nUSAGE β
Create a document of anything (example:- .doc dc.mp4, .doc dc.txt, .doc dc.webp)\
\n\nπ CMD β
.stoi\
\nUSAGE β
Convert sticker to image\
\n\nπ CMD β
.itos\
\nUSAGE β
Convert Image to Sticker"
}
)