Adding ability for hooks to return, and OnRaw hook

By adding the ability for hooks to return, we can stop the processing of a line at any point.
This is used by the OnRaw hook such that any non-nil return value will cause the irc library to assume that line has been handled.
This commit is contained in:
Joshua Simmons 2010-07-17 21:19:07 +08:00 committed by JakobOvrum
parent 7604bb2a51
commit b392b69f87
1 changed files with 5 additions and 2 deletions

View File

@ -163,7 +163,10 @@ end
function meta:think()
while true do
local line = getline(self, 3)
if line then self:handle(parse(line))
if line then
if not self:invoke("OnRaw", line) then
self:handle(parse(line))
end
else
break
end
@ -292,7 +295,7 @@ end
function meta:handle(prefix, cmd, params)
local handler = handlers[cmd]
if handler then
handler(self, prefix, unpack(params))
return handler(self, prefix, unpack(params))
end
end