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
|
if url:match '^file://' then
|
||||||
local path = url:match '^file://(.+)$'
|
local path = url:match '^file://(.+)$'
|
||||||
os.execute('cp "'..path..'" "'..filename..'"')
|
os.execute('cp "'..path..'" "'..filename..'"')
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--local body, code, headers, status = generic_request(url)
|
--local body, code, headers, status = generic_request(url)
|
||||||
|
|
50
main.lua
50
main.lua
|
@ -189,24 +189,24 @@ local function handle_message(bot, user, channel, message, is_fast_channel)
|
||||||
join_channel(channel)
|
join_channel(channel)
|
||||||
return 'BOT'
|
return 'BOT'
|
||||||
end
|
end
|
||||||
if message:match 'help' then
|
if message:match 'help' then
|
||||||
bot:sendChat(channel, choose {
|
bot:sendChat(channel, choose {
|
||||||
'No manual entry for ro-bot',
|
'No manual entry for '..CONFIG.IRC_NICK,
|
||||||
'404',
|
'404',
|
||||||
'Jeg kan ikke hjælpe dig, desværre.',
|
'Jeg kan ikke hjælpe dig, desværre.',
|
||||||
'Du må selv finde ud af hvordan jeg virker.',
|
'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'
|
return '!BOT'
|
||||||
elseif message:match 'shutdown' or message:match 'poweroff' then
|
elseif message:match 'shutdown' or message:match 'poweroff' then
|
||||||
bot:sendChat(channel, choose {
|
bot:sendChat(channel, choose {
|
||||||
'Fuck af, du har ikke kontrol over mig!',
|
'Fuck af, du har ikke kontrol over mig!',
|
||||||
'Nope, det gider jeg ikke',
|
'Nope, det gider jeg ikke',
|
||||||
'Du er ikke min mor!',
|
'Du er ikke min mor!',
|
||||||
'Du er ikke min far!',
|
'Du er ikke min far!',
|
||||||
})
|
})
|
||||||
return '!BOT'
|
return '!BOT'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Farvel msg
|
-- Farvel msg
|
||||||
|
@ -253,10 +253,16 @@ local function handle_message(bot, user, channel, message, is_fast_channel)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function strip_whitespace (s)
|
||||||
|
assert(type(s) == 'string')
|
||||||
|
return s:gsub('%s+', ' '):gsub('^ ', ''):gsub(' $', '')
|
||||||
|
end
|
||||||
|
|
||||||
local DEBUG_CHANNEL = '#bot-test'
|
local DEBUG_CHANNEL = '#bot-test'
|
||||||
|
|
||||||
bot:hook("OnChat", function(user, channel, message)
|
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
|
if channel == CONFIG.IRC_NICK then
|
||||||
channel = user.nick
|
channel = user.nick
|
||||||
is_fast_channel = 'direct'
|
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
|
if message:match('^'..escape_pattern(CONFIG.IRC_NICK)..':%s*(.*)$') then
|
||||||
message = message:match('^'..escape_pattern(CONFIG.IRC_NICK)..':%s*(.*)$')
|
message = message:match('^'..escape_pattern(CONFIG.IRC_NICK)..':%s*(.*)$')
|
||||||
is_fast_channel = 'direct'
|
is_fast_channel = 'direct'
|
||||||
|
elseif message:match(escape_pattern(CONFIG.IRC_NICK)) then
|
||||||
|
is_fast_channel = 'mention'
|
||||||
end
|
end
|
||||||
|
|
||||||
io.write '...\r'; io.flush()
|
io.write '...\r'; io.flush()
|
||||||
|
@ -271,9 +279,10 @@ bot:hook("OnChat", function(user, channel, message)
|
||||||
|
|
||||||
-- Handle error
|
-- Handle error
|
||||||
if not success then
|
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)])
|
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
|
end
|
||||||
|
|
||||||
-- Print status
|
-- Print status
|
||||||
|
@ -308,7 +317,6 @@ local BOT_FAREWELL = {
|
||||||
'Jeg keder mig.'
|
'Jeg keder mig.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function shutdown_memebot ()
|
local function shutdown_memebot ()
|
||||||
-- Leave channels
|
-- Leave channels
|
||||||
for channel in pairs(ACTIVE_CHANNELS) do
|
for channel in pairs(ACTIVE_CHANNELS) do
|
||||||
|
|
20
memes.lua
20
memes.lua
|
@ -685,16 +685,16 @@ function memes.generate_for_message (user, message)
|
||||||
-- Is this a rich picture?
|
-- Is this a rich picture?
|
||||||
if is_image_link(message) then
|
if is_image_link(message) then
|
||||||
local filename, status = download_and_standardize_image(message)
|
local filename, status = download_and_standardize_image(message)
|
||||||
if filename then
|
if filename then
|
||||||
local img_link = generate_is_this_a_pidgeon {
|
local img_link = generate_is_this_a_pidgeon {
|
||||||
{ type = 'image', filename = filename },
|
{ type = 'image', filename = filename },
|
||||||
{ type = 'text', text = 'Is this a rich picture?' }
|
{ type = 'text', text = 'Is this a rich picture?' }
|
||||||
}
|
}
|
||||||
return img_link, 'KYNG'
|
return img_link, 'KYNG'
|
||||||
else
|
else
|
||||||
img_link = 'Kunne ikke skaffe det billede. Fik fejlkode '..tostring(status)
|
img_link = 'Kunne ikke skaffe det billede. Fik fejlkode '..tostring(status)
|
||||||
return img_link, '!KYNG'
|
return img_link, '!KYNG'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- OMG his first word
|
-- OMG his first word
|
||||||
|
|
Loading…
Reference in New Issue
Block a user