Skip to content

Commit

Permalink
Merge pull request yagop#159 from rockneurotiko/plugins/dogify
Browse files Browse the repository at this point in the history
Dogify plugin
  • Loading branch information
yagop committed May 16, 2015
2 parents 090d4d1 + 3e708ae commit 7ea7f57
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ Bot Commands
<td>Gets a random fresh or popular image from Danbooru</td>
<td>!danbooru - gets a random fresh image from Danbooru :underage:<br>!danboorud - random daily popular image :underage:<br>!danbooruw - random weekly popular image :underage:<br>!danboorum - random monthly popular image :underage:<br></td>
</tr>
<tr>
<td>dogify.lua</td>
<td>Create a doge image with words.</td>
<td>!dogify (words/or phrases/separated/by/slashes) - Create a doge image with the words.</td>
</tr>
<tr>
<td>download_media.lua</td>
<td>When bot receives a media msg, download the media.</td>
Expand Down
24 changes: 24 additions & 0 deletions plugins/dogify.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local function run(msg, matches)
local base = "http://dogr.io/"
local path = string.gsub(matches[1], " ", "")
local url = base .. path .. '.png'
local urlm = "https?://[%w-_%.%?%.:/%+=&]+"

if string.match(url, urlm) == url then
local receiver = get_receiver(msg)
send_photo_from_url(receiver, url)
else
print("Can't build a good URL with parameter " .. matches[1])
end
end

return {
description = "Create a doge image with you words",
usage = {
"!dogify (your/words/with/slashes): Create a doge with the image and words"
},
patterns = {
"^!dogify (.+)$",
},
run = run
}

0 comments on commit 7ea7f57

Please sign in to comment.