diff --git a/main.lua b/main.lua index fc58005..e0e4d47 100644 --- a/main.lua +++ b/main.lua @@ -596,25 +596,31 @@ local LAST_USER_LOGIN local LAST_TIME_USER_LOGGED_OUT = {} local IRC_ALLOWED_TIMEOUT = 20 --20 * 60 +local INDENT = 11 + 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 -- On self join - io.write(string.format(' !! Joined %s\n', channel)) + io.write '[SELF]\n' 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(), '", "')..'"') 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 -- And that user wasn't the last one to join -- And that user haven't been logged in for IRC_ALLOWED_TIMEOUT seconds. LAST_USER_LOGIN = user.nick human_delay() bot:sendChat(channel, choose(HILSNER):format(user.nick)) + io.write '[HILS]\n' end - -- - io.write ' \r'; io.flush() end) bot:hook('OnPart', function(user, channel) @@ -818,7 +824,7 @@ local function init_memebot () if signal then signal.signal(signal.SIGINT, function (signum) 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() os.exit(128 + signum) end)