Bugfix für handle_exception() und Crons
This commit is contained in:
		| @@ -221,9 +221,9 @@ function bot:run(config) | ||||
| 		    for n=1, #self.plugins do  | ||||
| 			    local v = self.plugins[n] | ||||
| 				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 | ||||
| 						utilities.handle_exception(err, 'CRON: ' .. n, config.log_chat) | ||||
| 						utilities.handle_exception(self, err, 'CRON: ' .. n, config.log_chat) | ||||
| 					end | ||||
| 				end | ||||
| 			end | ||||
|   | ||||
| @@ -499,14 +499,20 @@ function utilities:resolve_username(input) | ||||
| end | ||||
|  | ||||
| function utilities:handle_exception(err, message, log_chat) | ||||
|   if not err then err = '' end | ||||
|   local output = '\n[' .. os.date('%F %T', os.time()) .. ']\n' .. self.info.username .. ': ' .. err .. '\n' .. message .. '\n' | ||||
|   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 | ||||
|     local output = string.format( | ||||
|         '[%s]\n%s: %s\n%s\n', | ||||
|         os.date('%F %T'), | ||||
|         self.info.username, | ||||
|         err or '', | ||||
|         message | ||||
|     ) | ||||
|     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 | ||||
|  | ||||
| -- MOVED TO DOWNLOAD_TO_FILE | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Andreas Bielawski
					Andreas Bielawski