fixed pornhub and youporn plugin
thx @synk0
This commit is contained in:
parent
e2e8bee99e
commit
d3c7322222
@ -1,48 +1,39 @@
|
|||||||
function run(msg, matches)
|
local function googlethat(query)
|
||||||
|
query = "site:pornhub.com" .. query
|
||||||
-- local g = require "./plugins/google"
|
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
|
||||||
-- local query = "site:pornhub.com+viewkey+" .. matches[1]
|
local parameters = "q=".. (URL.escape(query))
|
||||||
-- local new_matches = {query}
|
|
||||||
|
|
||||||
-- return g.run(msg, new_matches)
|
|
||||||
local results = findPornhub(matches[1])
|
|
||||||
return results-- build_result(results)
|
|
||||||
end
|
|
||||||
|
|
||||||
function findPornhub(query)
|
|
||||||
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:pornhub.com+viewkey+" .. query:gsub(" ", "+")
|
|
||||||
|
|
||||||
-- Do the request
|
-- Do the request
|
||||||
local res, code = https.request(api)
|
local res, code = https.request(api..parameters)
|
||||||
|
|
||||||
if code ~=200 then return nil end
|
if code ~=200 then return nil end
|
||||||
local data = json:decode(res)
|
local data = json:decode(res)
|
||||||
local results = data.responseData.results
|
|
||||||
|
|
||||||
|
local results = {}
|
||||||
|
for key,result in ipairs(data.responseData.results) do
|
||||||
math.randomseed( os.time() )
|
table.insert(results, {
|
||||||
math.random(#results)
|
result.titleNoFormatting,
|
||||||
math.random(#results)
|
result.unescapedUrl or result.url
|
||||||
local index = math.random(#results)
|
})
|
||||||
|
end
|
||||||
local result = results[index].titleNoFormatting .. "\n".. results[index].unescapedUrl .."\n"
|
return results
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function build_result(query)
|
local function stringlinks(results)
|
||||||
local stringresults=""
|
local stringresults=""
|
||||||
for key,val in ipairs(results) do
|
for key,val in ipairs(results) do
|
||||||
stringresults=stringresults..val[1].."\n"..val[2].."\n\n"
|
stringresults=stringresults..val[1].." - "..val[2].."\n"
|
||||||
end
|
end
|
||||||
return stringresults
|
return stringresults
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function run(msg, matches)
|
||||||
|
local results = googlethat(matches[1])
|
||||||
|
return stringlinks(results)
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
description = "Sendet ein PornHub Video",
|
description = "Sendet ein PornHub Video",
|
||||||
usage = {"/pornhub [Suchwort]","/ph [Suchwort]"},
|
usage = {"/pornhub [Begriff]","/ph [Begriff]"},
|
||||||
patterns = {"^/pornhub(.*)$","^/ph(.*)$"},
|
patterns = {"^/pornhub(.*)$","^/ph(.*)$"},
|
||||||
run = run
|
run = run
|
||||||
}
|
}
|
||||||
-- Modified by Akamaru [https://ponywave.de]
|
|
@ -1,47 +1,39 @@
|
|||||||
function run(msg, matches)
|
local function googlethat(query)
|
||||||
|
query = "site:youporn.com" .. query
|
||||||
-- local g = require "./plugins/google"
|
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
|
||||||
-- local query = "site:youporn.com+viewkey+" .. matches[1]
|
local parameters = "q=".. (URL.escape(query))
|
||||||
-- local new_matches = {query}
|
|
||||||
|
|
||||||
-- return g.run(msg, new_matches)
|
|
||||||
local results = findYouporn(matches[1])
|
|
||||||
return results-- build_result(results)
|
|
||||||
end
|
|
||||||
|
|
||||||
function findYouporn(query)
|
|
||||||
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site%3Ayouporn.com+" .. query:gsub(" ", "+")
|
|
||||||
|
|
||||||
-- Do the request
|
-- Do the request
|
||||||
local res, code = https.request(api)
|
local res, code = https.request(api..parameters)
|
||||||
|
|
||||||
if code ~=200 then return nil end
|
if code ~=200 then return nil end
|
||||||
local data = json:decode(res)
|
local data = json:decode(res)
|
||||||
local results = data.responseData.results
|
|
||||||
|
|
||||||
|
local results = {}
|
||||||
|
for key,result in ipairs(data.responseData.results) do
|
||||||
math.randomseed( os.time() )
|
table.insert(results, {
|
||||||
math.random(#results)
|
result.titleNoFormatting,
|
||||||
math.random(#results)
|
result.unescapedUrl or result.url
|
||||||
local index = math.random(#results)
|
})
|
||||||
|
end
|
||||||
local result = results[index].titleNoFormatting .. "\n".. results[index].unescapedUrl .."\n"
|
return results
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function build_result(query)
|
local function stringlinks(results)
|
||||||
local stringresults=""
|
local stringresults=""
|
||||||
for key,val in ipairs(results) do
|
for key,val in ipairs(results) do
|
||||||
stringresults=stringresults..val[1].."\n"..val[2].."\n\n"
|
stringresults=stringresults..val[1].." - "..val[2].."\n"
|
||||||
end
|
end
|
||||||
return stringresults
|
return stringresults
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function run(msg, matches)
|
||||||
|
local results = googlethat(matches[1])
|
||||||
|
return stringlinks(results)
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
description = "Sendet ein YouPorn Video",
|
description = "Sendet ein YouPorn Video",
|
||||||
usage = {"/youporn","/yp"},
|
usage = {"/youporn [Begriff]","/yp [Begriff]"},
|
||||||
patterns = {"^/youporn(.*)$","^/yp(.*)$"},
|
patterns = {"^/youporn(.*)$","^/yp(.*)$"},
|
||||||
run = run
|
run = run
|
||||||
}
|
}
|
Reference in New Issue
Block a user