Error messages are suppressed unless the triggering message was direct or mentioning.
This commit is contained in:
parent
d9c6a2a5d7
commit
575c481ad4
|
@ -274,7 +274,7 @@ function internet.download_file (url, filename)
|
|||
if url:match '^file://' then
|
||||
local path = url:match '^file://(.+)$'
|
||||
os.execute('cp "'..path..'" "'..filename..'"')
|
||||
return
|
||||
return true
|
||||
end
|
||||
|
||||
--local body, code, headers, status = generic_request(url)
|
||||
|
|
20
main.lua
20
main.lua
|
@ -191,11 +191,11 @@ local function handle_message(bot, user, channel, message, is_fast_channel)
|
|||
end
|
||||
if message:match 'help' then
|
||||
bot:sendChat(channel, choose {
|
||||
'No manual entry for ro-bot',
|
||||
'No manual entry for '..CONFIG.IRC_NICK,
|
||||
'404',
|
||||
'Jeg kan ikke hjælpe dig, desværre.',
|
||||
'Du må selv finde ud af hvordan jeg virker.',
|
||||
'Jeg er ligesom et menneske; jeg kommer ikke med manual.'
|
||||
'Jeg er ligesom et menneske; jeg kommer ikke med en manual.'
|
||||
})
|
||||
return '!BOT'
|
||||
elseif message:match 'shutdown' or message:match 'poweroff' then
|
||||
|
@ -253,10 +253,16 @@ local function handle_message(bot, user, channel, message, is_fast_channel)
|
|||
end
|
||||
end
|
||||
|
||||
local function strip_whitespace (s)
|
||||
assert(type(s) == 'string')
|
||||
return s:gsub('%s+', ' '):gsub('^ ', ''):gsub(' $', '')
|
||||
end
|
||||
|
||||
local DEBUG_CHANNEL = '#bot-test'
|
||||
|
||||
bot:hook("OnChat", function(user, channel, message)
|
||||
local is_fast_channel = user == channel == DEBUG_CHANNEL
|
||||
local is_fast_channel = (channel == DEBUG_CHANNEL)
|
||||
message = strip_whitespace(message)
|
||||
if channel == CONFIG.IRC_NICK then
|
||||
channel = user.nick
|
||||
is_fast_channel = 'direct'
|
||||
|
@ -264,6 +270,8 @@ bot:hook("OnChat", function(user, channel, message)
|
|||
if message:match('^'..escape_pattern(CONFIG.IRC_NICK)..':%s*(.*)$') then
|
||||
message = message:match('^'..escape_pattern(CONFIG.IRC_NICK)..':%s*(.*)$')
|
||||
is_fast_channel = 'direct'
|
||||
elseif message:match(escape_pattern(CONFIG.IRC_NICK)) then
|
||||
is_fast_channel = 'mention'
|
||||
end
|
||||
|
||||
io.write '...\r'; io.flush()
|
||||
|
@ -271,9 +279,10 @@ bot:hook("OnChat", function(user, channel, message)
|
|||
|
||||
-- Handle error
|
||||
if not success then
|
||||
io.write(("[ERROR] [%s] %s: %s\n\n\t%s\n\n"):format(channel, user.nick, message, status))
|
||||
if is_fast_channel == 'direct' or is_fast_channel == 'mention' then
|
||||
bot:sendChat(channel, ERROR_MSG[math.random(#ERROR_MSG)])
|
||||
return
|
||||
end
|
||||
status, message = 'ERROR', ('%s\n\n\t%s\n\n'):format(message, status)
|
||||
end
|
||||
|
||||
-- Print status
|
||||
|
@ -308,7 +317,6 @@ local BOT_FAREWELL = {
|
|||
'Jeg keder mig.'
|
||||
}
|
||||
|
||||
|
||||
local function shutdown_memebot ()
|
||||
-- Leave channels
|
||||
for channel in pairs(ACTIVE_CHANNELS) do
|
||||
|
|
Loading…
Reference in New Issue
Block a user