Guest User

Untitled

a guest
Oct 17th, 2015
113
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. --Ggf. nur eine Rufnummer zulassen:
  14. if msg.from.print_name ~= 'Fillip_iPhone' then
  15. os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." 'Ung├╝ltige Nr.'")
  16. return
  17. end
  18. if (string.lower(msg.text) == 'uptime') then
  19. local handle = io.popen("sudo python /home/pi/tg/tg_actions.py uptime")
  20. local res = handle:read("*a")
  21. handle:close()
  22. os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." '"..res.."' ")
  23. --Alternativ:
  24. --send_msg (msg.from.print_name, res)
  25. return
  26. elseif (string.lower(msg.text) == 'Standheizung') then
  27. local handle = io.popen("sudo python /home/pi/tg/tg_actions.py Standheizung")
  28. local res = handle:read("*a")
  29. os.execute("/home/pi/tg/send_script "..msg.from.print_name.." '"..res.."' ")
  30. handle:close()
  31. return
  32. elseif (string.lower(msg.text) == 'reboot') then
  33. local handle = io.popen("sudo python /home/pi/tg/tg_actions.py reboot")
  34. local res = handle:read("*a")
  35. handle:close()
  36. os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." '"..res.."' ")
  37. return
  38. else
  39. os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." 'Fehler' ")
  40. end
RAW Paste Data