Merge pull request #1 from yagop/master

Updating to latest
This commit is contained in:
soend
2015-03-12 09:46:42 +02:00
12 changed files with 241 additions and 101 deletions

71
plugins/boobs.lua Normal file
View File

@@ -0,0 +1,71 @@
do
function getRandomButts(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.obutts.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then
print('Cannot get that butts, trying another ones...')
return getRandomButts(attempt)
end
return 'http://media.obutts.ru/' .. data.preview
end
function getRandomBoobs(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.oboobs.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then
print('Cannot get that boobs, trying another ones...')
return getRandomBoobs(attempt)
end
return 'http://media.oboobs.ru/' .. data.preview
end
function run(msg, matches)
local url = nil
if matches[1] == "!boobs" then
url = getRandomBoobs()
end
if matches[1] == "!butts" then
url = getRandomButts()
end
if url ~= nil then
local receiver = get_receiver(msg)
send_photo_from_url(receiver, url)
else
return 'Error getting boobs/butts for you, please try again later.'
end
end
return {
description = "Gets a random boobs or butts pic",
usage = {
"!boobs",
"!butts"
},
patterns = {
"^!boobs$",
"^!butts$"
},
run = run
}
end

View File

@@ -6,24 +6,40 @@ do
local BASE_URL = 'http://api.giphy.com/v1'
local API_KEY = 'dc6zaTOxFJmzC' -- public beta key
function get_random_top()
local res, code = http.request(BASE_URL.."/gifs/trending?api_key="..API_KEY)
if code ~= 200 then return nil end
local images = json:decode(res).data
function get_image(response)
local images = json:decode(response).data
if #images == 0 then return nil end -- No images
local i = math.random(0,#images)
return images[i].images.downsized.url
local image = images[i] -- A random one
if image.images.downsized then
return image.images.downsized.url
end
if image.images.original then
return image.original.url
end
return nil
end
function get_random_top()
local url = BASE_URL.."/gifs/trending?api_key="..API_KEY
local response, code = http.request(url)
if code ~= 200 then return nil end
return get_image(response)
end
function search(text)
local res, code = http.request(BASE_URL.."/gifs/search?q="..text.."&api_key="..API_KEY)
local images = json:decode(res).data
if #images == 0 then return nil end -- No images
local i = math.random(0,#images)
return images[i].images.downsized.url
text = URL.escape(text)
local url = BASE_URL.."/gifs/search?q="..text.."&api_key="..API_KEY
local response, code = http.request(url)
if code ~= 200 then return nil end
return get_image(response)
end
function run(msg, matches)
local gif_url = ''
local gif_url = nil
-- If no search data, a random trending GIF will be sended
if matches[1] == "!gif" or matches[1] == "!giphy" then

View File

@@ -22,17 +22,17 @@ function stringlinks(results)
end
function run(msg, matches)
vardump(matches)
local results = googlethat(matches[1])
return stringlinks(results)
vardump(matches)
local results = googlethat(matches[1])
return stringlinks(results)
end
return {
description = "Searches Google and send results",
usage = "!google [terms]: Searches Google and send results",
patterns = {
"^!google (.*)$",
"^%.[g|G]oogle (.*)$"
},
run = run
description = "Searches Google and send results",
usage = "!google [terms]: Searches Google and send results",
patterns = {
"^!google (.*)$",
"^%.[g|G]oogle (.*)$"
},
run = run
}

View File

@@ -1,15 +1,17 @@
do
function run(msg, matches)
return "Hello, " .. matches[1]
end
return {
description = "Says hello to someone",
usage = "say hello to [name]",
patterns = {
"^say hello to (.*)$",
"^Say hello to (.*)$"
},
run = run
description = "Says hello to someone",
usage = "say hello to [name]",
patterns = {
"^say hello to (.*)$",
"^Say hello to (.*)$"
},
run = run
}
end

View File

@@ -61,14 +61,14 @@ function run(msg, matches)
end
return {
description = "Help plugin. Get info from other plugins. ",
usage = {
"!help: Show all the help",
"!help md: Generate a GitHub Markdown table"
},
patterns = {
"^!help$",
"^!help md$"
},
run = run
description = "Help plugin. Get info from other plugins. ",
usage = {
"!help: Show all the help",
"!help md: Generate a GitHub Markdown table"
},
patterns = {
"^!help$",
"^!help md$"
},
run = run
}

View File

@@ -10,11 +10,11 @@ return {
description = "When user sends image URL (ends with png, jpg, jpeg) download and send it to origin.",
usage = "",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+.png)$",
"(https?://[%w-_%.%?%.:/%+=&]+.jpg)$",
"(https?://[%w-_%.%?%.:/%+=&]+.jpeg)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.png)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.jpg)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.jpeg)$",
},
run = run
}
end
end

View File

@@ -26,10 +26,10 @@ function run(msg, matches)
end
return {
description = "Search image with Google API and sends it.",
usage = "!img [term]: Random search an image with Google API.",
patterns = {"^!img (.*)$"},
run = run
description = "Search image with Google API and sends it.",
usage = "!img [term]: Random search an image with Google API.",
patterns = {"^!img (.*)$"},
run = run
}
end

View File

@@ -1,23 +1,26 @@
do
function run(msg, matches)
file = download_to_file(matches[1])
send_document(get_receiver(msg), file, ok_cb, false)
file = download_to_file(matches[1])
send_document(get_receiver(msg), file, ok_cb, false)
end
return {
description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
usage = "",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+.gif)$",
"(https?://[%w-_%.%?%.:/%+=&]+.mp4)$",
"(https?://[%w-_%.%?%.:/%+=&]+.pdf)$",
"(https?://[%w-_%.%?%.:/%+=&]+.ogg)$",
"(https?://[%w-_%.%?%.:/%+=&]+.zip)$",
"(https?://[%w-_%.%?%.:/%+=&]+.mp3)$",
"(https?://[%w-_%.%?%.:/%+=&]+.rar)$",
"(https?://[%w-_%.%?%.:/%+=&]+.wmv)$",
"(https?://[%w-_%.%?%.:/%+=&]+.doc)$",
"(https?://[%w-_%.%?%.:/%+=&]+.avi)$"
},
run = run
}
description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
usage = "",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+%.gif)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.mp4)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.pdf)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.ogg)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.zip)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.mp3)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.rar)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.wmv)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.doc)$",
"(https?://[%w-_%.%?%.:/%+=&]+%.avi)$"
},
run = run
}
end

View File

@@ -44,7 +44,7 @@ end
return {
description = "Send comic images from xkcd",
usage = {"!xkcd (id): Send an xkcd image and tigle. If not id, send a random one"},
usage = {"!xkcd (id): Send an xkcd image and title. If not id, send a random one"},
patterns = {
"^!xkcd$",
"^!xkcd (%d+)",