This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/miku/plugins/cowsay.lua

40 lines
1.1 KiB
Lua
Raw Normal View History

local cowsay = {}
function cowsay:init(config)
cowsay.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('cowsay', true).table
cowsay.inline_triggers = {'^cow (.+)$'}
cowsay.doc = '\n*/cowsay* _<Text>_'
end
cowsay.command = 'cowsay <Text>'
function cowsay:inline_callback(inline_query, config, matches)
local input = matches[1]
if string.match(input, '"') then utilities.answer_inline_query(self, inline_query) return end
local text = '```'..run_command('cowsay "'..input..'"')..'```'
local text = text:gsub('\\', '\\\\')
local results = '[{"type":"article","id":"7912","title":"Muh!","input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}}]'
utilities.answer_inline_query(self, inline_query, results, 2)
end
function cowsay:action(msg, config)
local input = utilities.input_from_msg(msg)
if not input then
utilities.send_reply(self, msg, cowsay.doc, true)
return
end
if string.match(input, '"') then
text = 'Vergiss es!'
else
text = '```'..run_command('cowsay "'..input..'"')..'```'
end
utilities.send_reply(self, msg, text, true)
end
return cowsay