- get_txt hinzugefügt
- Gronkh-Soundboard ins Soundboard integriert
This commit is contained in:
parent
7025498768
commit
557405af2f
21
miku/plugins/get_txt.lua
Normal file
21
miku/plugins/get_txt.lua
Normal file
@ -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
|
@ -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* _<Sound>_: Sendet einen Sound
|
||||
*]]..config.cmd_pat..[[sound* _<Liste>_: Sendet eine Liste aller Sounds
|
||||
]]..config.cmd_pat..[[sound/gronkh* _<Sound>_: Sendet einen Sound
|
||||
*]]..config.cmd_pat..[[sound/gronkh* _<Liste>_: Sendet eine Liste aller Sounds
|
||||
]]
|
||||
end
|
||||
soundboard.command = 'sound <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, '<a href="https://ponywave.de/a/sounds">Hier findest du eine Liste aller Sounds!</a>', 'HTML')
|
||||
return
|
||||
if board == 'sound' then
|
||||
utilities.send_reply(self, msg, '<a href="https://ponywave.de/a/sounds">Hier findest du eine Liste aller Sounds!</a>', 'HTML')
|
||||
return
|
||||
elseif board == 'gronkh' then
|
||||
utilities.send_reply(self, msg, '<a href="https://ponywave.de/a/gronkhsounds">Hier findest du eine Liste aller Gronkh-Sounds!</a>', '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)
|
||||
|
Reference in New Issue
Block a user