Bugfix für handle_exception() und Crons
This commit is contained in:
parent
fb9d3652f3
commit
49dd18ce3f
@ -221,9 +221,9 @@ function bot:run(config)
|
|||||||
for n=1, #self.plugins do
|
for n=1, #self.plugins do
|
||||||
local v = self.plugins[n]
|
local v = self.plugins[n]
|
||||||
if v.cron then -- Call each plugin's cron function, if it has one.
|
if v.cron then -- Call each plugin's cron function, if it has one.
|
||||||
local result, err = pcall(function() v.cron(config) end)
|
local result, err = pcall(function() v.cron(self, config) end)
|
||||||
if not result then
|
if not result then
|
||||||
utilities.handle_exception(err, 'CRON: ' .. n, config.log_chat)
|
utilities.handle_exception(self, err, 'CRON: ' .. n, config.log_chat)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -499,14 +499,20 @@ function utilities:resolve_username(input)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function utilities:handle_exception(err, message, log_chat)
|
function utilities:handle_exception(err, message, log_chat)
|
||||||
if not err then err = '' end
|
local output = string.format(
|
||||||
local output = '\n[' .. os.date('%F %T', os.time()) .. ']\n' .. self.info.username .. ': ' .. err .. '\n' .. message .. '\n'
|
'[%s]\n%s: %s\n%s\n',
|
||||||
if log_chat then
|
os.date('%F %T'),
|
||||||
output = '<code>' .. utilities.html_escape(output) .. '</code>'
|
self.info.username,
|
||||||
return utilities.send_message(log_chat, output, true, nil, 'html')
|
err or '',
|
||||||
else
|
message
|
||||||
print(output)
|
)
|
||||||
end
|
if log_chat then
|
||||||
|
output = '<code>' .. utilities.html_escape(output) .. '</code>'
|
||||||
|
return utilities.send_message(log_chat, output, true, nil, 'html')
|
||||||
|
else
|
||||||
|
print(output)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MOVED TO DOWNLOAD_TO_FILE
|
-- MOVED TO DOWNLOAD_TO_FILE
|
||||||
|
Reference in New Issue
Block a user