pi-lights/action.lua

44 lines
1.0 KiB
Lua
Raw Normal View History

2017-01-07 17:27:12 -05:00
local host, port = "127.0.0.1", 12345
local socket = require("socket")
local tcp = assert(socket.tcp())
tcp:connect(host, port)
2017-01-07 12:44:30 -05:00
function on_msg_receive (msg)
if msg.out then
return
end
2017-01-07 17:27:12 -05:00
--local file = io.open("/home/pi/git/lights/tglog.txt", "w")
--local timestr = os.date("%Y/%m/%d-%H:%M:%S")
local message = "Invaild color"
if ((string.lower(msg.text)=='/purple') or (string.lower(msg.text)=='/p')) then
--message = ("purple|" .. timestr .. "|")
tcp:send("p")
send_msg (msg.from.print_name, "Purple", ok_cb, false)
--file:write("purple|", timestr, "\n")
--file:write("p")
--file:close()
elseif ((string.lower(msg.text)=='/yellow') or (string.lower(msg.text)=='/y')) then
tcp:send("y")
send_msg (msg.from.print_name, "Uh, yella, I guess", ok_cb, false)
2017-01-07 12:44:30 -05:00
end
end
2017-01-07 17:27:12 -05:00
2017-01-07 12:44:30 -05:00
function on_our_id (id)
end
2017-01-07 17:27:12 -05:00
2017-01-07 12:44:30 -05:00
function on_secret_chat_created (peer)
end
2017-01-07 17:27:12 -05:00
2017-01-07 12:44:30 -05:00
function on_user_update (user)
end
2017-01-07 17:27:12 -05:00
2017-01-07 12:44:30 -05:00
function on_chat_update (user)
end
2017-01-07 17:27:12 -05:00
2017-01-07 12:44:30 -05:00
function on_get_difference_end ()
end
2017-01-07 17:27:12 -05:00
2017-01-07 12:44:30 -05:00
function on_binlog_replay_end ()
end