Slight code cleanup, many parts still deserves complete rewrite - but it works for me.

master
Pitriss 7 years ago
parent 377b906f9d
commit c56d620785

@ -9,7 +9,6 @@ require 'yaml'
def configload ()
$CONF = YAML::load_file('conf/config.yml')
puts $CONF.to_hash
# Parsing of the general part of the yaml file
$SCNAME = $CONF["general"]["scriptname"]
# Parsing of the Jabber part of the yaml file
@ -36,7 +35,6 @@ rescue => error
exit
end
mpd = MPD.new $HOST, $PORT
mpd.connect
@ -127,7 +125,7 @@ def mpdcontrol(mpd,request, mess, type)
end
end
def outputsctl (outputs,sitelink)
def outputsctl (outputs)
reply = ""
def site_state_translate (input)
if input == 0 then
@ -140,6 +138,7 @@ def mpdcontrol(mpd,request, mess, type)
|key,var|
outfile = var[:name].split.last
weblink = ""
# This part needs to be modified to fit your setup.
case outfile
when "HQ"
file = "hi.ogg"
@ -148,7 +147,7 @@ def mpdcontrol(mpd,request, mess, type)
when "MP3"
file = "stream.mp3"
end
reply = reply+"#{key} - #{sitelink}/#{file} - #{site_state_translate(var.status)}\n"
reply = reply+"#{key} - #{$SITE}/#{file} - #{site_state_translate(var.status)}\n"
}
return reply
end
@ -169,11 +168,9 @@ def mpdcontrol(mpd,request, mess, type)
end
song = mpd.current_song
if song.name != nil then
# do nothing
else
if song.name.nil? then
ns = mpd.nextsong
answer = "#{answer}\nNext song in queue: #{ns[:artist]} - #{ns[:title]} [album #{ns[:album]}]"
answer = "#{answer}\nNext song in the queue: #{ns[:artist]} - #{ns[:title]} [album #{ns[:album]}]"
end
if type == "0" then
post "#{sticon} #{answer}"
@ -228,9 +225,8 @@ def mpdcontrol(mpd,request, mess, type)
ns = mpd.nextsong
nsanswer = "Next song in queue: #{ns[:artist]} - #{ns[:title]} [album #{ns[:album]}]"
end
sitelink = $SITE
outputs = mpd.outputstatus([0, 1, 2])
outs = outputsctl(outputs,$SITE)
outs = outputsctl(outputs)
if type == "0" then
post "#{sticon} #{answer}\n#{nsanswer}\nOutputs:\n#{outs}"
@ -240,9 +236,9 @@ def mpdcontrol(mpd,request, mess, type)
when "outputs"
outputs = mpd.outputstatus([0, 1, 2])
if type == "0" then
post outputsctl(outputs,$SITE)
post outputsctl(outputs)
else
post outputsctl(outputs,$SITE) => mess.user
post outputsctl(outputs) => mess.user
end
when "version"
if type == "0" then
@ -253,17 +249,18 @@ def mpdcontrol(mpd,request, mess, type)
when "help"
answer = "Stream is located at #{$SITE}/xyz.ext (see outputs)\n
Commands:\n
status - Info about played track
nestsong - Info about next song in queue
info - Verbose info about most relevant aspects
outputs - list all outputs available and its status
toggle <output number> - toggle state of output
play - start MPD
pause - pause MPD
stop - stops MPD
status - Info about currently played track
nestsong - Info about the next song in the queue
info - Verbose info about the most relevant aspects
outputs - Lists all outputs available and its status
toggle <output number> - Toggle state of the output
play - start the MPD
pause - pause the MPD
stop - stops the MPD
next - next song
prev - previous song\n\n
For more info ask in room. (eg howto access playlist control)"
For more info ask in the room. (eg howto access playlist control)\n
Playlist control (Adding/Removing songs to/from the playlist) is not possible via this bot."
if type == "0" then
post answer
else

Loading…
Cancel
Save