2016-07-17 13:22:27 +02:00
|
|
|
local echo = {}
|
|
|
|
|
|
|
|
echo.command = 'echo <Text>'
|
|
|
|
|
|
|
|
function echo:init(config)
|
2016-08-01 21:07:27 +02:00
|
|
|
echo.triggers = {'/[Ee][Cc][Hh][Oo] (.*)$'}
|
2016-07-17 13:22:27 +02:00
|
|
|
echo.inline_triggers = {
|
2016-08-01 21:07:27 +02:00
|
|
|
'^echo (.*)',
|
|
|
|
'^bold (.*)'
|
2016-07-17 13:22:27 +02:00
|
|
|
}
|
|
|
|
echo.doc = [[*
|
|
|
|
]]..config.cmd_pat..[[echo* _<Text>_: Gibt den Text aus]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function echo:inline_callback(inline_query, config, matches)
|
2016-08-03 19:05:05 +02:00
|
|
|
local text = matches[1]
|
2016-07-17 13:22:27 +02:00
|
|
|
local results = '['
|
|
|
|
|
|
|
|
-- enable custom markdown button
|
|
|
|
if text:match('%[.*%]%(.*%)') or text:match('%*.*%*') or text:match('_.*_') or text:match('`.*`') then
|
2016-08-15 23:14:28 +02:00
|
|
|
results = results..'{"type":"article","id":"3","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/custom.jpg","title":"Eigenes Markdown","description":"'..text..'","input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}},'
|
2016-07-17 13:22:27 +02:00
|
|
|
end
|
|
|
|
|
2016-08-15 23:14:28 +02:00
|
|
|
local results = results..'{"type":"article","id":"4","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fett.jpg","title":"Fett","description":"*'..text..'*","input_message_content":{"message_text":"<b>'..text..'</b>","parse_mode":"HTML"}},{"type":"article","id":"5","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/kursiv.jpg","title":"Kursiv","description":"_'..text..'_","input_message_content":{"message_text":"<i>'..text..'</i>","parse_mode":"HTML"}},{"type":"article","id":"6","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/echo/fixedsys.jpg","title":"Feste Breite","description":"`'..text..'`","input_message_content":{"message_text":"<code>'..text..'</code>","parse_mode":"HTML"}}]'
|
2016-07-17 13:22:27 +02:00
|
|
|
utilities.answer_inline_query(self, inline_query, results, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
function echo:action(msg)
|
2016-08-15 23:14:28 +02:00
|
|
|
local input = utilities.input_from_msg(msg)
|
2016-07-17 13:22:27 +02:00
|
|
|
if not input then
|
|
|
|
utilities.send_message(self, msg.chat.id, echo.doc, true, msg.message_id, true)
|
|
|
|
else
|
|
|
|
local output
|
|
|
|
if msg.chat.type == 'supergroup' then
|
|
|
|
output = '*Echo:*\n"' .. utilities.md_escape(input) .. '"'
|
2016-08-01 21:07:27 +02:00
|
|
|
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
|
|
|
return
|
2016-07-17 13:22:27 +02:00
|
|
|
end
|
|
|
|
utilities.send_message(self, msg.chat.id, input, true, nil, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-15 23:14:28 +02:00
|
|
|
return echo
|