This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/sh.lua

68 lines
1.7 KiB
Lua
Raw Normal View History

2015-04-14 20:21:23 +02:00
function run_sh(msg)
name = get_name(msg)
text = ''
bash = msg.text:sub(4,-1)
text = run_bash(bash)
return text
end
function run(msg, matches)
local receiver = get_receiver(msg)
if string.starts(msg.text, '/sh') then
text = run_sh(msg)
send_msg(receiver, text, ok_cb, false)
return
end
if string.starts(msg.text, '/uptime') then
text = run_bash('uptime')
send_msg(receiver, text, ok_cb, false)
return
end
2015-06-10 14:28:44 +02:00
if string.starts(msg.text, '/temp') then
text = run_bash('vcgencmd measure_temp')
2015-07-06 18:31:44 +02:00
text = string.gsub(text, "temp=", " ")
return "Die CPU Temperatur beträgt" ..text
2015-06-10 14:28:44 +02:00
end
if string.starts(msg.text, '/volt') then
text = run_bash('vcgencmd measure_volts')
send_msg(receiver, text, ok_cb, false)
return
end
if string.starts(msg.text, '/takt') then
text = run_bash('vcgencmd measure_clock arm')
send_msg(receiver, text, ok_cb, false)
return
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
2015-06-10 14:28:44 +02:00
2015-04-14 20:21:23 +02:00
end
return {
description = "Führt Befehle in der Konsole aus",
usage = {"/sh kann nur Akamaru"},
2015-07-06 18:31:44 +02:00
patterns = {"^/uptime$","^/sh (.*)$","^/temp$","^/volt$","^/takt$","^/screen$","^/update$","^/upgrade$"},
2015-04-14 20:21:23 +02:00
run = run,
privileged = true
}