Better logging of hils decisions.

This commit is contained in:
Jon Michael Aanes 2018-06-12 10:37:50 +02:00
parent a97b9a8b18
commit 77ed541662

View File

@ -596,25 +596,31 @@ local LAST_USER_LOGIN
local LAST_TIME_USER_LOGGED_OUT = {} local LAST_TIME_USER_LOGGED_OUT = {}
local IRC_ALLOWED_TIMEOUT = 20 --20 * 60 local IRC_ALLOWED_TIMEOUT = 20 --20 * 60
local INDENT = 11
bot:hook('OnJoin', function(user, channel) bot:hook('OnJoin', function(user, channel)
io.write '...\r'; io.flush() io.write(string.format('...%s%s joined %s\r', string.rep(' ',INDENT - 3), user.nick, channel))
io.flush()
-- --
if user.nick == CONFIG.IRC_NICK then if user.nick == CONFIG.IRC_NICK then
-- On self join -- On self join
io.write(string.format(' !! Joined %s\n', channel)) io.write '[SELF]\n'
if #imlib.font.list_fonts() == 0 then if #imlib.font.list_fonts() == 0 then
common_error(channel, 'Hjælp! Min computer har ingen fonts! Hvorfor er fonts så svære på linux? Jeg har kigget i: "'..table.concat(imlib.font.list_paths(), '", "')..'"') common_error(channel, 'Hjælp! Min computer har ingen fonts! Hvorfor er fonts så svære på linux? Jeg har kigget i: "'..table.concat(imlib.font.list_paths(), '", "')..'"')
end end
elseif user.nick ~= LAST_USER_LOGIN and (LAST_TIME_USER_LOGGED_OUT[user.nick] or 0) + IRC_ALLOWED_TIMEOUT < os.time() then elseif user.nick == LAST_USER_LOGIN then
io.write '[!LAST]\n'
elseif os.time() < (LAST_TIME_USER_LOGGED_OUT[user.nick] or 0) + IRC_ALLOWED_TIMEOUT then
io.write(string.format('%s%s reconnected to %s\n', string.rep(' ',INDENT), user.nick, channel))
else
-- On other join -- On other join
-- And that user wasn't the last one to join -- And that user wasn't the last one to join
-- And that user haven't been logged in for IRC_ALLOWED_TIMEOUT seconds. -- And that user haven't been logged in for IRC_ALLOWED_TIMEOUT seconds.
LAST_USER_LOGIN = user.nick LAST_USER_LOGIN = user.nick
human_delay() human_delay()
bot:sendChat(channel, choose(HILSNER):format(user.nick)) bot:sendChat(channel, choose(HILSNER):format(user.nick))
io.write '[HILS]\n'
end end
--
io.write ' \r'; io.flush()
end) end)
bot:hook('OnPart', function(user, channel) bot:hook('OnPart', function(user, channel)
@ -818,7 +824,7 @@ local function init_memebot ()
if signal then if signal then
signal.signal(signal.SIGINT, function (signum) signal.signal(signal.SIGINT, function (signum)
io.write ' !! Received SIGINT, will shut down...\n' io.write ' !! Received SIGINT, will shut down...\n'
send_to_all(BOT_FAREWELL[math.random(#BOT_FAREWELL)]) --send_to_all(BOT_FAREWELL[math.random(#BOT_FAREWELL)])
shutdown_memebot() shutdown_memebot()
os.exit(128 + signum) os.exit(128 + signum)
end) end)