1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

Handle pastebin spam protection and add a cache buster

This commit is contained in:
Drew Lemmy 2019-02-24 13:47:09 +00:00
parent e2bfaafe28
commit bd04a93ffb
No known key found for this signature in database
GPG Key ID: 21657E4652E0C2F1

View File

@ -20,11 +20,20 @@ end
local function get(paste)
write( "Connecting to pastebin.com... " )
-- Add a cache buster so that spam protection is re-checked
local cacheBuster = tostring(math.random())
local response = http.get(
"https://pastebin.com/raw/"..textutils.urlEncode( paste )
"https://pastebin.com/raw/"..textutils.urlEncode( paste ).."?cb="..cacheBuster
)
if response then
-- If spam protection is activated, we get redirected to /paste with Content-Type: text/html
local headers = response.getResponseHeaders()
if not headers["Content-Type"] or not headers["Content-Type"]:find( "^text/plain" ) then
printError( "\nFailed to get paste. Please complete the captcha in a web browser: https://pastebin.com/"..textutils.urlEncode( paste ) )
return
end
print( "Success." )
local sResponse = response.readAll()