Portiere:

- Chucknorris
- Dogify
This commit is contained in:
Andreas Bielawski 2016-08-22 22:11:29 +02:00
parent d9a6836dd5
commit 76c285910a
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,29 @@
local chucknorris = {}
chucknorris.command = 'cn'
function chucknorris:init(config)
chucknorris.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('cn', true).table
chucknorris.doc = [[*
]]..config.cmd_pat..[[cn*: Postet einen zufälligen Chuck-Norris-Witz]]
end
function chucknorris:get_joke()
local url = 'http://api.icndb.com/jokes/random'
local res, code = http.request(url)
if code ~= 200 then return nil end
local data = json.decode(res)
local text = data.value.joke
return text
end
function chucknorris:action(msg, config)
local text = chucknorris:get_joke()
if not text then
utilities.send_reply(self, msg, config.errors.connection)
return
end
utilities.send_reply(self, msg, unescape(text))
end
return chucknorris

30
miku/plugins/dogify.lua Normal file
View File

@ -0,0 +1,30 @@
local dogify = {}
function dogify:init(config)
dogify.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('dogify', true).table
dogify.doc = [[*
]]..config.cmd_pat..[[dogify* _text/den/du/willst_: Wow, much doge!
]]
end
dogify.command = 'dogify text/den/du/willst'
function dogify:action(msg, config, matches)
local input = utilities.input_from_msg(msg)
if not input then
utilities.send_reply(self, msg, dogify.doc, true)
return
end
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local path = input:gsub(" ", "%%20")
local photo_url = 'http://dogr.io/'..path..'.png?split=false&.png'
local file = download_to_file(photo_url)
if not file then
utilities.send_reply(self, msg, config.errors.connection)
return
end
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
end
return dogify