do_lex infinite loop when "mutated = false"

This commit is contained in:
yago 2015-01-04 20:32:04 +01:00
parent 68fed25b49
commit ffa72bb22f

View File

@ -49,17 +49,12 @@ function msg_valid(msg)
end end
function do_lex(msg, text) function do_lex(msg, text)
local mutated = true
while mutated do
mutated = false
for name, desc in pairs(plugins) do for name, desc in pairs(plugins) do
if (desc.lex ~= nil) then if (desc.lex ~= nil) then
result = desc.lex(msg, text) result = desc.lex(msg, text)
if (result ~= nil) then if (result ~= nil) then
-- print ("Mutating to " .. result) print ("Mutating to " .. result)
text = result text = result
mutated = true
end
end end
end end
end end
@ -78,7 +73,7 @@ function do_action(msg)
end end
-- print("Received msg", text) -- print("Received msg", text)
text = do_lex(msg, text) msg.text = do_lex(msg, text)
for name, desc in pairs(plugins) do for name, desc in pairs(plugins) do
-- print("Trying module", name) -- print("Trying module", name)
@ -96,11 +91,8 @@ function do_action(msg)
result = desc.run(msg, matches) result = desc.run(msg, matches)
-- print(" sending", result) -- print(" sending", result)
if (result) then if (result) then
local result2 = do_lex(msg, result) result = do_lex(msg, result)
if (result2 == nil) then _send_msg(receiver, result)
result2 = result
end
_send_msg(receiver, result2)
end end
end end
end end