Fabian123123

Untitled

Jun 5th, 2016
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function on_msg_receive (msg)
  2. if started == 0 then
  3. return
  4. end
  5. if msg.out then
  6. return
  7. end
  8. --Damit der "Gelesen Haken" erscheint
  9. if msg.text then
  10. mark_read (msg.from.print_name, ok_cb, false)
  11. end
  12.  
  13. if msg.from.print_name ~= 'Vorname Nachname' then
  14. return
  15. end
  16. if (string.lower(msg.text) == 'uptime') then
  17. local handle = io.popen("sudo python /home/pi/tg/tg_actions.py uptime")
  18. local res = handle:read("*a")
  19. handle:close()
  20. return
  21. elseif (string.lower(msg.text) == 'shutdown') then
  22. local handle = io.popen("sudo python /home/pi/tg/tg_actions.py shutdown")
  23. local res = handle:read("*a")
  24. handle:close()
  25. return
  26. elseif (string.lower(msg.text) == 'reboot') then
  27. local handle = io.popen("sudo python /home/pi/tg/tg_actions.py reboot")
  28. local res = handle:read("*a")
  29. handle:close()
  30. return
  31. else
  32. end
  33.  
  34. end
RAW Paste Data