pi-lights/action.lua

57 lines
1.9 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"
2017-01-07 17:37:07 -05:00
if ((string.lower(msg.text)=='/red') or (string.lower(msg.text)=='/r')) then
tcp:send("r")
2017-01-27 01:27:47 -05:00
send_msg (msg.from.print_name, "Red", ok_cb, false)
2017-01-07 17:37:07 -05:00
elseif ((string.lower(msg.text)=='/green') or (string.lower(msg.text)=='/g')) then
tcp:send("g")
send_msg (msg.from.print_name, "Green", ok_cb, false)
elseif ((string.lower(msg.text)=='/blue') or (string.lower(msg.text)=='/b')) then
tcp:send("b")
send_msg (msg.from.print_name, "Blue", ok_cb, false)
elseif ((string.lower(msg.text)=='/purple') or (string.lower(msg.text)=='/p')) then
2017-01-07 17:27:12 -05:00
tcp:send("p")
send_msg (msg.from.print_name, "Purple", ok_cb, false)
elseif ((string.lower(msg.text)=='/yellow') or (string.lower(msg.text)=='/y')) then
tcp:send("y")
2017-01-07 17:37:07 -05:00
send_msg (msg.from.print_name, "Yellow", ok_cb, false)
elseif ((string.lower(msg.text)=='/cyan') or (string.lower(msg.text)=='/c')) then
tcp:send("c")
send_msg (msg.from.print_name, "Cyan", ok_cb, false)
2017-01-27 01:27:47 -05:00
elseif ((string.lower(msg.text)=='/off') or (string.lower(msg.text)=='/o') or (string.lower(msg.text)=='o')) then
2017-01-07 17:37:07 -05:00
tcp:send("o")
send_msg (msg.from.print_name, "Off", ok_cb, false)
2017-01-27 01:27:47 -05:00
elseif ((string.lower(msg.text)=='/white') or (string.lower(msg.text)=='/w') or (string.lower(msg.text)=='w')) then
2017-01-07 17:37:07 -05:00
tcp:send("w")
send_msg (msg.from.print_name, "White", 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