- NEU: Amazon-Reflink-Entferner
- HEAD-Requests bei Expand und GitHub-Feed ignorieren jetzt den Inhalt
This commit is contained in:
		
							
								
								
									
										33
									
								
								otouto/plugins/amazon_cleaner.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								otouto/plugins/amazon_cleaner.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| local cln_amzn = {} | ||||
|  | ||||
| cln_amzn.triggers = { | ||||
|   'amazon.(%w+)/gp/product/(.+)/(.+)', | ||||
|   'amazon.(%w+)/gp/product/(.+)%?(.+)', | ||||
|   'amazon.(%w+)/dp/(.+)/(.+)', | ||||
|   'amazon.(%w+)/dp/(.+)%?(.+)', | ||||
|   'amzn.to/(.+)' | ||||
| } | ||||
|  | ||||
| function cln_amzn:action(msg, config, matches) | ||||
|   if #matches == 1 then | ||||
|    local request_constructor = { | ||||
|       url = 'http://amzn.to/'..matches[1], | ||||
|       method = "HEAD", | ||||
|       sink = ltn12.sink.null(), | ||||
|       redirect = false | ||||
|    } | ||||
|  | ||||
|    local ok, response_code, response_headers = http.request(request_constructor) | ||||
|    local long_url = response_headers.location | ||||
|    local domain, product_id = long_url:match('amazon.(%w+)/gp/product/(.+)/(.+)') | ||||
|    utilities.send_reply(msg, 'Ohne Ref: https://amazon.'..domain..'/dp/'..product_id) | ||||
|    return | ||||
|   end | ||||
|  | ||||
|   text = msg.text:lower() | ||||
|   if text:match('tag%=.+') or text:match('linkid%=.+') then | ||||
|     utilities.send_reply(msg, 'Ohne Ref: https://amazon.'..matches[1]..'/dp/'..matches[2]) | ||||
|   end | ||||
| end | ||||
|  | ||||
| return cln_amzn | ||||
| @@ -31,16 +31,14 @@ function expand:inline_callback(inline_query, config, matches) | ||||
| end | ||||
|  | ||||
| function expand:url(long_url) | ||||
|    local response_body = {} | ||||
|    local request_constructor = { | ||||
|       url = long_url, | ||||
|       method = "HEAD", | ||||
|       sink = ltn12.sink.table(response_body), | ||||
|       headers = {}, | ||||
|       sink = ltn12.sink.null(), | ||||
|       redirect = false | ||||
|    } | ||||
|  | ||||
|    local ok, response_code, response_headers, response_status_line = http.request(request_constructor) | ||||
|    local ok, response_code, response_headers = http.request(request_constructor) | ||||
|    return ok, response_headers | ||||
| end | ||||
|  | ||||
|   | ||||
| @@ -47,11 +47,11 @@ end | ||||
|  | ||||
| function gh_feed_check_modified(repo, cur_etag, last_date) | ||||
|   local url = BASE_URL..'/'..repo | ||||
|   local response_body = {} | ||||
|   local request_constructor = { | ||||
|       url = url, | ||||
|       method = "HEAD", | ||||
| 	  redirect = false, | ||||
|       sink = ltn12.sink.null(), | ||||
|       headers = { | ||||
| 	    Authorization = 'token '..token, | ||||
| 		["If-None-Match"] = cur_etag | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Andreas Bielawski
					Andreas Bielawski