diff --git a/miku/plugins/get_txt.lua b/miku/plugins/get_txt.lua new file mode 100644 index 0000000..26624f3 --- /dev/null +++ b/miku/plugins/get_txt.lua @@ -0,0 +1,21 @@ +local get_txt = {} + +get_txt.triggers = { + "(https?://.*.txt)" +} + +function get_txt:action(msg, config, matches) + local url = matches[1] + local doer = http + if url:match('^https') then + doer = https + end + local res, code = doer.request(url) + if code ~= 200 then + utilities.send_reply(self, msg, config.errors.connection) + return + end + utilities.send_reply(self, msg, res) +end + +return get_txt \ No newline at end of file diff --git a/miku/plugins/soundboard.lua b/miku/plugins/soundboard.lua index 77a33fb..bbfdfb3 100644 --- a/miku/plugins/soundboard.lua +++ b/miku/plugins/soundboard.lua @@ -1,42 +1,59 @@ local soundboard = {} function soundboard:init(config) - soundboard.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sound', true).table + soundboard.triggers = { + "^/(sound) (.+)$", + "^/(gronkh) (.+)$" + } soundboard.inline_triggers = { - "^sounds? (.+)$" + "^(sound) (.+)$", + "^(gronkh) (.+)$" } soundboard.doc = [[* -]]..config.cmd_pat..[[sound* __: Sendet einen Sound -*]]..config.cmd_pat..[[sound* __: Sendet eine Liste aller Sounds +]]..config.cmd_pat..[[sound/gronkh* __: Sendet einen Sound +*]]..config.cmd_pat..[[sound/gronkh* __: Sendet eine Liste aller Sounds ]] end soundboard.command = 'sound ' --- local BASE_URL = 'http://code.ponywave.de/workspace/mikubot/sounds' -local BASE_URL = 'http://kyouko.local/sounds' +local BASE_URL = 'http://code.ponywave.de/workspace/mikubot/sounds' +--local BASE_URL = 'http://kyouko.local/sounds' +local GRONKH_URL = 'http://code.ponywave.de/workspace/mikubot/gronkhsounds' function soundboard:inline_callback(inline_query, config, matches) - local input = matches[1] - local url = BASE_URL..'/'..string.lower(input)..'.mp3' + local board = matches[1] + local input = matches[2] + if board == 'sound' then + url = BASE_URL..'/'..string.lower(input)..'.mp3' + elseif board == 'gronkh' then + url = GRONKH_URL..'/'..string.lower(input)..'.mp3' + end local _, code = get_http_header(url) if code ~= 200 then utilities.answer_inline_query(self, inline_query, nil, 5, true) return end local results = '[{"type":"audio","id":"7900","title":"'..input..'","audio_url":"'..url..'"}]' - utilities.answer_inline_query(self, inline_query, results, 3600) + utilities.answer_inline_query(self, inline_query, results, 2) end -function soundboard:action(msg, config) - local input = utilities.input_from_msg(msg) - if not input then - utilities.send_reply(self, msg, soundboard.doc, true) - return - end +function soundboard:action(msg, config, matches) + local board = matches[1] + local input = matches[2] if input:match('^[Ll][Ii][Ss][Tt][Ee]$') then - utilities.send_reply(self, msg, 'Hier findest du eine Liste aller Sounds!', 'HTML') - return + if board == 'sound' then + utilities.send_reply(self, msg, 'Hier findest du eine Liste aller Sounds!', 'HTML') + return + elseif board == 'gronkh' then + utilities.send_reply(self, msg, 'Hier findest du eine Liste aller Gronkh-Sounds!', 'HTML') + return + end + end + + if board == 'sound' then + url = BASE_URL..'/'..string.lower(input)..'.mp3' + elseif board == 'gronkh' then + url = GRONKH_URL..'/'..string.lower(input)..'.mp3' end - local url = BASE_URL..'/'..string.lower(input)..'.mp3' local sound = download_to_file(url) if not sound then utilities.send_reply(self, msg, config.errors.results)