From 3c3034de21bd00c83bc598418005258b815260f8 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 13 Jan 2016 01:41:25 +1100 Subject: [PATCH] General code cleanup. Soon: More phrases to respond with. --- hooks/ai.lua | 24 ++++++++++++------------ init.lua | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hooks/ai.lua b/hooks/ai.lua index 03dd1c5..073ff49 100644 --- a/hooks/ai.lua +++ b/hooks/ai.lua @@ -1,22 +1,22 @@ nick,chan,message = ... local serialization = require "serialization" lnick = "yukichan" -print(lnick,nick,chan,message) +--print(lnick,nick,chan,message) if string.find(message,lnick) ~= nil and nick ~= "Shocky" then - print("Message addressed to AI!") +-- print("Message addressed to AI!") local f = io.open("./ai.lua","rb") if f ~= nil then local content = f:read("*a") f:close() - print(content) - print("Loaded AI file.") - print(type(serialization.unserialize)) +-- print(content) +-- print("Loaded AI file.") +-- print(type(serialization.unserialize)) w,aitab = pcall(serialization.unserialize,content) - print(w,aitab) - print("Decoded AI file.") +-- print(w,aitab) +-- print("Decoded AI file.") local selection = 0 local hscore = 0 - print("Starting interpretation.") +-- print("Starting interpretation.") for k,v in ipairs(aitab) do local count = 0 for l,w in ipairs(v[2]) do @@ -25,21 +25,21 @@ if string.find(message,lnick) ~= nil and nick ~= "Shocky" then if count > hscore then selection = k hscore = count - print(selection,hscore) +-- print(selection,hscore) end end if hscore == 0 then - print("No high score, selecting a random response.") +-- print("No high score, selecting a random response.") selection = math.random(1,#aitab) end - print(selection) +-- print(selection) selstring = aitab[selection][1][1] if type(selstring) == "table" then for k,v in pairs(selstring) do print(k.."="..v) end end - print(selstring) + print("Selected response: " .. selstring) sendchan(chan,selstring) end end diff --git a/init.lua b/init.lua index 3664a1c..5f4c31a 100644 --- a/init.lua +++ b/init.lua @@ -106,7 +106,7 @@ leftHanging = {0,false} function parsemsg(nick,chan,message) for k,v in pairs(hooks) do - print("Running hook "..k) +-- print("Running hook "..k) local fail,errors = pcall(v,nick,chan,message) if not fail then print(errors) end end