Neu: rule34 und wikia plugins
This commit is contained in:
parent
919561b34c
commit
f652e49c5d
45
plugins/rule34.lua
Normal file
45
plugins/rule34.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
|
||||||
|
-- DO NOT USE WITHOUT PERMISSION
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
local function get_r34_info(tag)
|
||||||
|
local limit = 50 -- number of posts to return (higher = more choices for random, but longer load times, hard limit of 100 posts)
|
||||||
|
local BASE_URL = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%27http%3A%2F%2Frule34.xxx%2Findex.php%3Fpage%3Ddapi%26s%3Dpost%26q%3Dindex%26limit%3D'..limit..'%26tags%3D'
|
||||||
|
local END_URL = '%27&format=json'
|
||||||
|
local url = BASE_URL..tag..END_URL
|
||||||
|
local res,code = https.request(url)
|
||||||
|
local r34 = json:decode(res).query.results.posts.post
|
||||||
|
if code ~= 200 then return "HTTP-Fehler" end
|
||||||
|
|
||||||
|
-- truly randomize
|
||||||
|
math.randomseed(os.time())
|
||||||
|
-- random max json table size
|
||||||
|
local i = math.random(#r34)
|
||||||
|
|
||||||
|
local url = r34[i].file_url
|
||||||
|
local source_url = 'Source: http://rule34.xxx/index.php?page=post&s=view&id='..r34[i].id
|
||||||
|
return url, source_url
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run(msg, matches)
|
||||||
|
local tag = matches[1]
|
||||||
|
local tag = string.gsub(tag, " ", '_')
|
||||||
|
local tag = string.gsub(tag, ":", '%%3A')
|
||||||
|
local receiver = get_receiver(msg)
|
||||||
|
local url, id = get_r34_info(tag)
|
||||||
|
local cb_extra = {
|
||||||
|
receiver=receiver,
|
||||||
|
url=url
|
||||||
|
}
|
||||||
|
send_msg(receiver, id, send_photo_from_url_callback, cb_extra)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
description = "Sendet zufälliges Bild von rule34.xxx",
|
||||||
|
usage = "/r34 [Tag]: Sendet zufälliges Bild von rule34.xxx",
|
||||||
|
patterns = {"^/r34 (.*)"},
|
||||||
|
run = run
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
@ -19,7 +19,8 @@ function getTitle(page)
|
|||||||
s = string.gsub(s, "Ψ", "ψ")
|
s = string.gsub(s, "Ψ", "ψ")
|
||||||
s = string.gsub(s, "ψ", "ψ")
|
s = string.gsub(s, "ψ", "ψ")
|
||||||
s = string.gsub(s, "»", "»")
|
s = string.gsub(s, "»", "»")
|
||||||
s = string.gsub(s, "ß", "ß")
|
s = string.gsub(s, "ß", "ß")
|
||||||
|
s = string.gsub(s, "™", "™")
|
||||||
s = string.gsub(s, "'", "'")
|
s = string.gsub(s, "'", "'")
|
||||||
s = string.gsub(s, "|", "|")
|
s = string.gsub(s, "|", "|")
|
||||||
s = string.gsub(s, " ", " ")
|
s = string.gsub(s, " ", " ")
|
||||||
@ -88,6 +89,8 @@ function run(msg, matches)
|
|||||||
string.match(msg.text, "deviantart.com") or
|
string.match(msg.text, "deviantart.com") or
|
||||||
string.match(msg.text, "urbanup.com/") or
|
string.match(msg.text, "urbanup.com/") or
|
||||||
string.match(msg.text, "urbandictionary.com/define.php")or
|
string.match(msg.text, "urbandictionary.com/define.php")or
|
||||||
|
string.match(msg.text, "wikia.com") or
|
||||||
|
string.match(msg.text, "rule34.xxx/index.php") or
|
||||||
string.match(msg.text, "dropbox.com/s/") then
|
string.match(msg.text, "dropbox.com/s/") then
|
||||||
print('Ungültig, da "'..title..'"')
|
print('Ungültig, da "'..title..'"')
|
||||||
else
|
else
|
||||||
|
46
plugins/wikia.lua
Normal file
46
plugins/wikia.lua
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
|
||||||
|
-- DO NOT USE WITHOUT PERMISSION
|
||||||
|
|
||||||
|
do
|
||||||
|
|
||||||
|
local BASE_URL = '.wikia.com/api/v1/Articles/Details?abstract=400'
|
||||||
|
|
||||||
|
function send_wikia_article (wikia, article)
|
||||||
|
local url = 'http://'..wikia..BASE_URL..'&titles='..article
|
||||||
|
local res,code = http.request(url)
|
||||||
|
if code ~= 200 then return "HTTP-FEHLER" end
|
||||||
|
if string.match(res, "Not a valid Wikia") then return 'Kein valides Wikia!' end
|
||||||
|
local data = json:decode(res)
|
||||||
|
|
||||||
|
local keyset={}
|
||||||
|
local n=0
|
||||||
|
for id,_ in pairs(data.items) do
|
||||||
|
n=n+1
|
||||||
|
keyset[n]=id
|
||||||
|
end
|
||||||
|
|
||||||
|
local id = keyset[1]
|
||||||
|
if not id then return 'Diese Seite existiert nicht!' end
|
||||||
|
|
||||||
|
local title = data.items[id].title
|
||||||
|
local abstract = data.items[id].abstract
|
||||||
|
local article_url = data.basepath..data.items[id].url
|
||||||
|
|
||||||
|
local text = title..':\n'..abstract..'\n'..article_url
|
||||||
|
return text
|
||||||
|
end
|
||||||
|
|
||||||
|
function run(msg, matches)
|
||||||
|
local wikia = matches[1]
|
||||||
|
local article = matches[2]
|
||||||
|
return send_wikia_article(wikia, article)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
description = "Sendet Wikia-Artikel.",
|
||||||
|
usage = "URL zu Wikia-Artikel in irgendeinem Wikia",
|
||||||
|
patterns = {"https?://(.+).wikia.com/wiki/(.+)"},
|
||||||
|
run = run
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user