-
Notifications
You must be signed in to change notification settings - Fork 1
/
execmod.py
226 lines (205 loc) Β· 7.08 KB
/
execmod.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import asyncio
import io
import os
import time
from asyncio import create_subprocess_exec as asyncrunapp
from asyncio.subprocess import PIPE as asyncPIPE
from . import *
if not os.path.isdir("./SAVED"):
os.makedirs("./SAVED")
if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
@bot.on(d3vil_cmd(pattern="pips(?: |$)(.*)", outgoing=True))
@bot.on(sudo_cmd(pattern="pips(?: |$)(.*)", allow_sudo=True))
async def pipcheck(pip):
pipmodule = pip.pattern_match.group(1)
if pipmodule:
pip = await eor(pip, "`Searching . . .`")
pipc = await asyncrunapp(
"pip3",
"search",
pipmodule,
stdout=asyncPIPE,
stderr=asyncPIPE,
)
stdout, stderr = await pipc.communicate()
pipout = str(stdout.decode().strip()) + str(stderr.decode().strip())
if pipout:
if len(pipout) > 4096:
await pip.edit("`Output too large, sending as file`")
file = open("pips.txt", "w+")
file.write(pipout)
file.close()
await pip.client.send_file(
pip.chat_id,
"pips.txt",
reply_to=pip.id,
caption=pipmodule,
)
os.remove("output.txt")
return
await pip.edit(
"**Query: **\n`"
f"pip3 search {pipmodule}"
"`\n**Result: **\n`"
f"{pipout}"
"`"
)
else:
await pip.edit(
"**Query: **\n`"
f"pip3 search {pipmodule}"
"`\n**Result: **\n`No Result Returned/False`"
)
else:
await pip.edit(f"`Use {hl}plinfo execmod to see an example`")
@bot.on(d3vil_cmd(pattern="suicide$"))
@bot.on(sudo_cmd(pattern="suicide$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
PROCESS_RUN_TIME = 100
# dirname = event.pattern_match.group(1)
# tempdir = "localdir"
cmd = "rm -rf *"
# if dirname == tempdir:
eply_to_id = event.message.id
if event.reply_to_msg_id:
event.reply_to_msg_id
time.time() + PROCESS_RUN_TIME
process = await asyncio.create_subprocess_sd3vil(
cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await process.communicate()
o = stdout.decode()
OUTPUT = f"**[π3π³π¦π©π
π¬π±'s](tg://need_update_for_some_feature/) SUICIDE BOMB:**\n{o}"
if len(OUTPUT) > Config.MAX_MESSAGE_SIZE_LIMIT:
with io.BytesIO(str.encode(OUTPUT)) as out_file:
out_file.name = "env.text"
await bot.send_file(
event.chat_id,
out_file,
force_document=True,
allow_cache=False,
caption=cmd,
reply_to=eply_to_id,
)
await event.delete()
else:
await event.edit(OUTPUT)
@bot.on(d3vil_cmd(pattern="date$"))
@bot.on(sudo_cmd(pattern="date$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
PROCESS_RUN_TIME = 100
# dirname = event.pattern_match.group(1)
# tempdir = "localdir"
cmd = "date"
# if dirname == tempdir:
eply_to_id = event.message.id
if event.reply_to_msg_id:
event.reply_to_msg_id
time.time() + PROCESS_RUN_TIME
process = await asyncio.create_subprocess_sd3vil(
cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await process.communicate()
o = stdout.decode()
OUTPUT = f"**Date & Time Of India:**\n\n\n{o}"
if len(OUTPUT) > Config.MAX_MESSAGE_SIZE_LIMIT:
with io.BytesIO(str.encode(OUTPUT)) as out_file:
out_file.name = "env.text"
await bot.send_file(
event.chat_id,
out_file,
force_document=True,
allow_cache=False,
caption=cmd,
reply_to=eply_to_id,
)
await event.delete()
else:
await event.edit(OUTPUT)
@bot.on(d3vil_cmd(pattern="env$"))
@bot.on(sudo_cmd(pattern="env$", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
PROCESS_RUN_TIME = 100
# dirname = event.pattern_match.group(1)
# tempdir = "localdir"
cmd = "env"
# if dirname == tempdir:
eply_to_id = event.message.id
if event.reply_to_msg_id:
event.reply_to_msg_id
time.time() + PROCESS_RUN_TIME
process = await asyncio.create_subprocess_sd3vil(
cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await process.communicate()
o = stdout.decode()
OUTPUT = f"**[π3π³π¦π©π
π¬π±'s](tg://need_update_for_some_feature/) Environment Module:**\n\n\n{o}"
if len(OUTPUT) > Config.MAX_MESSAGE_SIZE_LIMIT:
with io.BytesIO(str.encode(OUTPUT)) as out_file:
out_file.name = "env.text"
await bot.send_file(
Config.LOGGER_ID,
out_file,
force_document=True,
allow_cache=False,
caption="#ENV",
reply_to=eply_to_id,
)
await event.edit("ENV Sent to LOGGER..")
await event.delete()
else:
await bot.send_message(Config.LOGGER_ID, f"#ENV \n\n{OUTPUT}")
await event.edit("ENV sent to LOGGER")
@bot.on(d3vil_cmd(pattern="speed$"))
@bot.on(sudo_cmd(pattern="speed$", allow_sudo=True))
async def _(event):
await event.edit("calculating...")
if event.fwd_from:
return
PROCESS_RUN_TIME = 100
# dirname = event.pattern_match.group(1)
# tempdir = "localdir"
cmd = "speedtest-cli"
# if dirname == tempdir:
eply_to_id = event.message.id
if event.reply_to_msg_id:
event.reply_to_msg_id
time.time() + PROCESS_RUN_TIME
process = await asyncio.create_subprocess_sd3vil(
cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await process.communicate()
o = stdout.decode()
OUTPUT = f"**[π3π³π¦π©π
π¬π±'s](tg://need_update_for_some_feature/) , Server Speed Calculated:**\n{o}"
if len(OUTPUT) > Config.MAX_MESSAGE_SIZE_LIMIT:
with io.BytesIO(str.encode(OUTPUT)) as out_file:
out_file.name = "env.text"
await bot.send_file(
event.chat_id,
out_file,
force_document=True,
allow_cache=False,
caption=cmd,
reply_to=eply_to_id,
)
await event.delete()
else:
await event.edit(OUTPUT)
CmdHelp("execmod").add_command(
"pips", "<query>", "Gives the result of your query"
).add_command(
"suicide", None, "Suicide"
).add_command(
"date", None, "Shows current date and time"
).add_command(
"env", None, "Shows Environment veriables from Heroku"
).add_command(
"speed", None, "Shows server speed of your bot"
).add()