44 lines
1.0 KiB
Lua
44 lines
1.0 KiB
Lua
local host, port = "127.0.0.1", 12345
|
|
local socket = require("socket")
|
|
local tcp = assert(socket.tcp())
|
|
tcp:connect(host, port)
|
|
|
|
function on_msg_receive (msg)
|
|
if msg.out then
|
|
return
|
|
end
|
|
--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)
|
|
end
|
|
end
|
|
|
|
function on_our_id (id)
|
|
end
|
|
|
|
function on_secret_chat_created (peer)
|
|
end
|
|
|
|
function on_user_update (user)
|
|
end
|
|
|
|
function on_chat_update (user)
|
|
end
|
|
|
|
function on_get_difference_end ()
|
|
end
|
|
|
|
function on_binlog_replay_end ()
|
|
end
|