From b70d0eaa20d899dd40d7aa34bce02debb4baabc0 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 8 Jan 2016 00:57:42 +1100 Subject: [PATCH] Hopefully last change to the high-five catcher --- config.lua | 2 +- init.lua | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config.lua b/config.lua index 42d46c2..3ce8572 100644 --- a/config.lua +++ b/config.lua @@ -1 +1 @@ -{server="irc.quakenet.org",nick="yukichan",hostname="lain",servername="lain",realname="yuki",channels={"#SKSDev","#v","#ssss"},prefix=":",username="yuki",port=6667,admins={"ShadowKatStudios"}} +{server="irc.esper.net",nick="yukichan",hostname="lain",servername="lain",realname="yuki",channels={"#SKSDev","#v","#ssss"},prefix=":",username="yuki",port=6667,admins={"ShadowKatStudios"}} diff --git a/init.lua b/init.lua index 16df16f..e24fbdb 100644 --- a/init.lua +++ b/init.lua @@ -64,8 +64,12 @@ leftHanging = {0,false} function parsemsg(nick,chan,message) if message:find("o/") ~= nil or message:find("\\o") ~= nil and nick ~= "Shocky" and nick ~= "yukichan" then if leftHanging[2] == false then - print ("Left hanging at "..os.time()) - leftHanging = {os.time(),true,chan} + print (nick .." left hanging at "..os.time()) + local typeOfHighFive="o/" + if message:find("o/") ~= nil then + typeOfHighFive = "\\o" + end + leftHanging = {os.time(),true,chan,typeOfHighFive} elseif leftHanging[2] == true then leftHanging = {0,false} print("No longer left hanging.") @@ -153,9 +157,14 @@ function main() connection:send("NICK "..config.nick.."\n") connection:send("USER "..config.username.." "..config.hostname.." "..config.servername.." "..config.realname.."\n") repeat - line = connection:receive() + line = connection:receive() or "" + if string.find(line, "PING :") == 1 then + local _,pingid = string.match(line,"([^,]+):([^,]+)") + writeln("PONG :"..pingid) + print("Pinged: "..pingid) + end print(line) - until string.match(line,"%+i") ~= false + until string.match(line or "","%+i") ~= nil os.sleep(2) print("Sent everything relevant. Joining channels.") for k,v in pairs(config.channels) do @@ -169,7 +178,7 @@ function main() end if os.time() > leftHanging[1]+3 and leftHanging[2] then print ("Responding to a hanging high-five at "..leftHanging[1]) - sendchan(leftHanging[3],"\\o") + sendchan(leftHanging[3],leftHanging[4] or "\\o") leftHanging={0,false} end if line == nil then line = "" end