Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- started = 0
- our_id = 0
- function vardump(value, depth, key)
- local linePrefix = ""
- local spaces = ""
- if key ~= nil then
- linePrefix = "["..key.."] = "
- end
- if depth == nil then
- depth = 0
- else
- depth = depth + 1
- for i=1, depth do spaces = spaces .. " " end
- end
- if type(value) == 'table' then
- mTable = getmetatable(value)
- if mTable == nil then
- print(spaces ..linePrefix.."(table) ")
- else
- print(spaces .."(metatable) ")
- value = mTable
- end
- for tableKey, tableValue in pairs(value) do
- vardump(tableValue, depth, tableKey)
- end
- elseif type(value) == 'function' or
- type(value) == 'thread' or
- type(value) == 'userdata' or
- value == nil
- then
- print(spaces..tostring(value))
- else
- print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
- end
- end
- print ("HI, this is lua script")
- function ok_cb(extra, success, result)
- end
- function on_msg_receive (msg)
- if started == 0 then
- return
- end
- if msg.out then
- return
- end
- --Damit der "Gelesen Haken" erscheint
- if msg.text then
- mark_read (msg.from.print_name, ok_cb, false)
- end
- --Ggf. nur eine Rufnummer zulassen:
- if msg.from.print_name ~= 'Stefan' then
- os.execute("/home/pi/tg/send_script ".. msg.from.print_name .." 'UngΓΌltige Nr.'")
- return
- end
- if (string.lower(msg.text) == 'uptime') then
- local handle = io.popen("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.."'")
- --Alternativ:
- --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")
- handle:close()
- os.execute("/home/pi/tg/send_script "..msg.from.print_name.." '"..res.."'")
- 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
- elseif (string.lower(msg.text) == 't1h') then
- local handle = io.popen("sudo python /home/pi/tg/tg_actions.py t1h")
- 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 .." 'Fehler' ")
- end
- end
- function on_our_id (id)
- our_id = id
- end
- function on_user_update (user, what)
- --vardump (user)
- end
- function on_chat_update (chat, what)
- --vardump (chat)
- end
- function on_secret_chat_update (schat, what)
- --vardump (schat)
- end
- function on_get_difference_end ()
- end
- function cron()
- -- do something
- postpone (cron, false, 1.0)
- end
- function on_binlog_replay_end ()
- started = 1
- postpone (cron, false, 1.0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement