Fixed high-five responding.

This commit is contained in:
Izaya 2016-01-07 23:03:05 +11:00
parent f4a188194f
commit 1710a64304

View File

@ -59,10 +59,17 @@ function addcommand(fname,str)
cmds[fname] = load(str) cmds[fname] = load(str)
end end
leftHanging = {0,false}
function parsemsg(nick,chan,message) function parsemsg(nick,chan,message)
if message:sub(-2) == "o/" and nick ~= "Shocky" and nick ~= "yukichan" then if message:find("o/") ~= nil or message:find("\\o") ~= nil and nick ~= "Shocky" and nick ~= "yukichan" then
os.sleep(4) if leftHanging[2] == false then
sendchan(chan,"\\o") print ("Left hanging at "..os.time())
leftHanging = {os.time(),true,chan}
elseif leftHanging[2] == true then
leftHanging = {0,false}
print("No longer left hanging.")
end
end end
if string.find(message,":") == 1 then if string.find(message,":") == 1 then
local command = message:sub(2) .. " " local command = message:sub(2) .. " "
@ -147,7 +154,7 @@ function main()
repeat repeat
line = connection:receive() line = connection:receive()
print(line) print(line)
until string.match(line,"+i") ~= false until string.match(line,"%+i") ~= false
os.sleep(2) os.sleep(2)
print("Sent everything relevant. Joining channels.") print("Sent everything relevant. Joining channels.")
for k,v in pairs(config.channels) do for k,v in pairs(config.channels) do
@ -159,6 +166,11 @@ function main()
print(line) print(line)
pcall(parse,line) pcall(parse,line)
end 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")
leftHanging={0,false}
end
if line == nil then line = "" end if line == nil then line = "" end
until string.find(line,"ERROR :Closing link:") ~= nil until string.find(line,"ERROR :Closing link:") ~= nil
print(connection:receive()) print(connection:receive())