fixed wiki plugin
Wikipedia links working again
This commit is contained in:
parent
16286b9dae
commit
e2e8bee99e
28
plugins/googlethat.lua
Normal file
28
plugins/googlethat.lua
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
-- Need this for wiki.lua
|
||||||
|
function googlethat(query)
|
||||||
|
local number = 5 -- Set number of results
|
||||||
|
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&safe=active&hl=de&rsz="..number.."&"
|
||||||
|
local parameters = "q=".. (URL.escape(query) or "")
|
||||||
|
|
||||||
|
-- Do the request
|
||||||
|
local res, code = https.request(api..parameters)
|
||||||
|
if code ~=200 then return nil end
|
||||||
|
local data = json:decode(res)
|
||||||
|
|
||||||
|
local results={}
|
||||||
|
for key,result in ipairs(data.responseData.results) do
|
||||||
|
table.insert(results, {
|
||||||
|
result.titleNoFormatting,
|
||||||
|
result.unescapedUrl or result.url
|
||||||
|
})
|
||||||
|
end
|
||||||
|
return results
|
||||||
|
end
|
||||||
|
|
||||||
|
function stringlinks(results)
|
||||||
|
local stringresults=""
|
||||||
|
for key,val in ipairs(results) do
|
||||||
|
stringresults=stringresults..val[1].." - "..val[2].."\n"
|
||||||
|
end
|
||||||
|
return stringresults
|
||||||
|
end
|
@ -1,4 +1,4 @@
|
|||||||
require("./plugins/google")
|
require("./plugins/googlethat")
|
||||||
|
|
||||||
function firstresult(results)
|
function firstresult(results)
|
||||||
return results[1][2]
|
return results[1][2]
|
||||||
|
Reference in New Issue
Block a user