From 55a56e1a6f28b2db58cfa6ff0ed6b66413300935 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Tue, 9 Aug 2016 00:49:54 +0200 Subject: [PATCH] Sende keine Fehlermeldungen mehr an den Chat, sondern ignoriere die Nachricht einfach. Es wird empfohlen, einen Log-Chat einzurichten und die Fehlermeldungen dort hinleiten zu lassen (siehe config.lua.example) --- otouto/bot.lua | 12 ++---------- otouto/utilities.lua | 20 ++++++++------------ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/otouto/bot.lua b/otouto/bot.lua index d146b6a..a6c5c45 100644 --- a/otouto/bot.lua +++ b/otouto/bot.lua @@ -222,16 +222,8 @@ function match_plugins(self, msg, config, plugin) return plugin.action(self, msg, config, matches) end) if not success then - -- If the plugin has an error message, send it. If it does - -- not, use the generic one specified in config. If it's set - -- to false, do nothing. - if plugin.error then - utilities.send_reply(self, msg, plugin.error) - elseif plugin.error == nil then - utilities.send_reply(self, msg, config.errors.generic, true) - end - utilities.handle_exception(self, result, msg.from.id .. ': ' .. msg.text, config) - return + utilities.handle_exception(self, result, msg.from.id .. ': ' .. msg.text, config) + return end end end diff --git a/otouto/utilities.lua b/otouto/utilities.lua index 3cb7b7d..ed8f59f 100644 --- a/otouto/utilities.lua +++ b/otouto/utilities.lua @@ -485,18 +485,14 @@ function utilities:user_from_message(msg, no_extra) end function utilities:handle_exception(err, message, config) - - if not err then err = '' end - - local output = '\n[' .. os.date('%F %T', os.time()) .. ']\n' .. self.info.username .. ': ' .. err .. '\n' .. message .. '\n' - - if config.log_chat then - output = '```' .. output .. '```' - utilities.send_message(self, config.log_chat, output, true, nil, true) - else - print(output) - end - + if not err then err = '' end + local output = '\n[' .. os.date('%F %T', os.time()) .. ']\n' .. self.info.username .. ': ' .. err .. '\n' .. message .. '\n' + if config.log_chat then + output = '```' .. output .. '```' + utilities.send_message(self, config.log_chat, output, true, nil, true) + else + print(output) + end end -- MOVED TO DOWNLOAD_TO_FILE