26 lines
		
	
	
		
			594 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			594 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
| local get_txt = {}
 | |
| 
 | |
| get_txt.triggers = {
 | |
|   "(https?://.*%.txt)"
 | |
| }
 | |
| 
 | |
| function get_txt:action(msg, config, matches)
 | |
|   local url = matches[1]
 | |
|   local doer = http
 | |
|   if url:match('^https') then
 | |
| 	doer = https
 | |
|   end
 | |
|   local res, code  = doer.request(url)
 | |
|   if code ~= 200 then 
 | |
|    utilities.send_reply(msg, config.errors.connection)
 | |
|    return
 | |
|   end
 | |
|   if string.len(res) > 500 then
 | |
|     result = '<pre>'..string.sub(res, 1, 500)..'...</pre>\n<i>(Text gekürzt, da länger als 500 Zeichen.)</i>'
 | |
|   else
 | |
| 	result = '<pre>'..res..'</pre>'
 | |
|   end
 | |
|   utilities.send_reply(msg, result, 'HTML')
 | |
| end
 | |
| 
 | |
| return get_txt |