removed screen.lua, added screen, update and upgrade function to sh.lua

This commit is contained in:
Akamaru 2015-06-10 15:06:52 +02:00
parent 64bb221da6
commit bf1756c4cb
2 changed files with 19 additions and 33 deletions

View File

@ -1,32 +0,0 @@
function run_sh(msg)
name = get_name(msg)
text = ''
bash = msg.text:sub(4,-1)
text = run_bash(bash)
return text
end
function run_bash(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
function run(msg, matches)
local receiver = get_receiver(msg)
if string.starts(msg.text, '/screen') then
text = run_bash("scrot 'scrot.png' -e 'mv $f ~/Mikubot/tmp/'")
send_photo(get_receiver(msg), "tmp/scrot.png", ok_cb, false)
return 'Screenshot wird gesendet!'
end
end
return {
description = "Macht ein Screenshot vom PC auf dem der Bot läuft",
usage = {"/screen"},
patterns = {"^/screen$"},
run = run,
privileged = true
}
--by Akamaru [https://ponywave.de]

View File

@ -38,12 +38,30 @@ function run(msg, matches)
return return
end end
if string.starts(msg.text, '/screen') then
text = run_bash("scrot 'scrot.png' -e 'mv $f ~/Mikubot/tmp/'")
send_photo(get_receiver(msg), "tmp/scrot.png", ok_cb, false)
return 'Screenshot wird gesendet!'
end
if string.starts(msg.text, '/update') then
text = run_bash("sudo apt-get update")
print(text)
return 'Update durchgeführt!'
end
if string.starts(msg.text, '/upgrade') then
text = run_bash("sudo apt-get upgrade -y")
print(text)
return 'Upgrade durchgeführt!'
end
end end
return { return {
description = "Führt Befehle in der Konsole aus", description = "Führt Befehle in der Konsole aus",
usage = {"/sh kann nur Akamaru"}, usage = {"/sh kann nur Akamaru"},
patterns = {"^/uptime", "^/sh (.*)$","^/temp$","^/volt$","^/takt$"}, patterns = {"^/uptime","^/sh (.*)$","^/temp$","^/volt$","^/takt$","^/screen$","^/update$","^/upgrade$"},
run = run, run = run,
privileged = true privileged = true
} }