forked from infernal1200/Virus-Tg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.lua
56 lines (53 loc) · 1.3 KB
/
server.lua
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
function run_sh(msg, matches)
local receiver = get_receiver(msg)
name = get_name(msg)
text = ''
if is_sudo(msg) then
bash = msg.text:sub(4,-1)
text = run_bash(bash)
else
text = name .. ' you have no power here!'
end
send_large_msg(receiver, 'In Process...', ok_cb, false)
return text
end
function run_bash(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
function on_getting_dialogs(cb_extra,success,result)
if success then
local dialogs={}
for key,value in pairs(result) do
for chatkey, chat in pairs(value.peer) do
print(chatkey,chat)
if chatkey=="id" then
table.insert(dialogs,chat.."\n")
end
if chatkey=="print_name" then
table.insert(dialogs,chat..": ")
end
end
end
send_msg(cb_extra[1],table.concat(dialogs),ok_cb,false)
end
end
function run(msg, matches)
if not is_admin1(msg) then
return "only for sudo"
end
local receiver = get_receiver(msg)
if string.match then
text = run_bash(matches[1])
send_large_msg(receiver, text, ok_cb, false)
return
end
end
return {
description = "return cmd in trm",
usage = "server manager",
patterns = {"^[$](.*)$"},
run = run
}