function on_msg_receive (msg) if started == 0 then return end if msg.out then return end --For the "has read" tick if msg.text then mark_read (msg.from.print_name, ok_cb, false) end --only allow one Number/contact if msg.from.print_name ~= 'Contact_Name' then os.execute("/home/pi/tg/send_script " .. msg.from.print_name .. " 'Invalid number.'") return end if (string.lower(msg.text) == 'uptime') then local handle = io.popen("sudo python /home/pi/tg/tg_actions.py uptime") local res = handle:read("*a") handle:close() os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." '"..res.."' ") --Alternative: --send_msg (msg.from.print_name, res) return elseif (string.lower(msg.text) == 'shutdown') then local handle = io.popen("sudo python /home/pi/tg/tg_actions.py shutdown") local res = handle:read("*a") os.execute("/home/pi/tg/send_script "..msg.from.print_name.." '"..res.."' ") handle:close() return elseif (string.lower(msg.text) == 'reboot') then local handle = io.popen("sudo python /home/pi/tg/tg_actions.py reboot") local res = handle:read("*a") handle:close() os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." '"..res.."' ") return else os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." 'Error' ") end end