fixed pornhub and youporn plugin

thx @synk0
This commit is contained in:
Akamaru 2015-06-15 14:59:55 +02:00
parent e2e8bee99e
commit d3c7322222
2 changed files with 58 additions and 75 deletions

View File

@ -1,48 +1,39 @@
function run(msg, matches) local function googlethat(query)
query = "site:pornhub.com" .. query
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
local parameters = "q=".. (URL.escape(query))
-- local g = require "./plugins/google" -- Do the request
-- local query = "site:pornhub.com+viewkey+" .. matches[1] local res, code = https.request(api..parameters)
-- local new_matches = {query} if code ~=200 then return nil end
local data = json:decode(res)
-- return g.run(msg, new_matches) local results = {}
local results = findPornhub(matches[1]) for key,result in ipairs(data.responseData.results) do
return results-- build_result(results) table.insert(results, {
result.titleNoFormatting,
result.unescapedUrl or result.url
})
end
return results
end end
function findPornhub(query) local function stringlinks(results)
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:pornhub.com+viewkey+" .. query:gsub(" ", "+") local stringresults=""
for key,val in ipairs(results) do
-- Do the request stringresults=stringresults..val[1].." - "..val[2].."\n"
local res, code = https.request(api) end
return stringresults
if code ~=200 then return nil end
local data = json:decode(res)
local results = data.responseData.results
math.randomseed( os.time() )
math.random(#results)
math.random(#results)
local index = math.random(#results)
local result = results[index].titleNoFormatting .. "\n".. results[index].unescapedUrl .."\n"
return result
end end
function build_result(query) local function run(msg, matches)
local stringresults="" local results = googlethat(matches[1])
for key,val in ipairs(results) do return stringlinks(results)
stringresults=stringresults..val[1].."\n"..val[2].."\n\n"
end
return stringresults
end 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]

View File

@ -1,47 +1,39 @@
function run(msg, matches) local function googlethat(query)
query = "site:youporn.com" .. query
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
local parameters = "q=".. (URL.escape(query))
-- local g = require "./plugins/google" -- Do the request
-- local query = "site:youporn.com+viewkey+" .. matches[1] local res, code = https.request(api..parameters)
-- local new_matches = {query} if code ~=200 then return nil end
local data = json:decode(res)
-- return g.run(msg, new_matches) local results = {}
local results = findYouporn(matches[1]) for key,result in ipairs(data.responseData.results) do
return results-- build_result(results) table.insert(results, {
result.titleNoFormatting,
result.unescapedUrl or result.url
})
end
return results
end end
function findYouporn(query) local function stringlinks(results)
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site%3Ayouporn.com+" .. query:gsub(" ", "+") local stringresults=""
for key,val in ipairs(results) do
-- Do the request stringresults=stringresults..val[1].." - "..val[2].."\n"
local res, code = https.request(api) end
return stringresults
if code ~=200 then return nil end
local data = json:decode(res)
local results = data.responseData.results
math.randomseed( os.time() )
math.random(#results)
math.random(#results)
local index = math.random(#results)
local result = results[index].titleNoFormatting .. "\n".. results[index].unescapedUrl .."\n"
return result
end end
function build_result(query) local function run(msg, matches)
local stringresults="" local results = googlethat(matches[1])
for key,val in ipairs(results) do return stringlinks(results)
stringresults=stringresults..val[1].."\n"..val[2].."\n\n"
end
return stringresults
end 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
} }