use backticks since we don't want to pollute stdout
This commit is contained in:
parent
5ae6ae4671
commit
91c6f62f7e
36
main.rb
36
main.rb
@ -47,8 +47,8 @@ def update_mpd()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
puts "telling mpd to refresh"
|
puts "telling mpd to refresh"
|
||||||
system("mv spool/*.mp3 tracks/")
|
`mv spool/*.mp3 tracks/`
|
||||||
system("mpc update")
|
`mpc update`
|
||||||
new_songs.each do |song|
|
new_songs.each do |song|
|
||||||
s = song.split("/")[1]
|
s = song.split("/")[1]
|
||||||
res = system("mpc add #{Shellwords.shellescape(s)}")
|
res = system("mpc add #{Shellwords.shellescape(s)}")
|
||||||
@ -72,8 +72,8 @@ if options.length == 0
|
|||||||
end
|
end
|
||||||
|
|
||||||
puts "creating spool and tracks directories"
|
puts "creating spool and tracks directories"
|
||||||
system("mkdir -p spool")
|
`mkdir -p spool`
|
||||||
system("mkdir -p tracks")
|
`"mkdir -p tracks`
|
||||||
|
|
||||||
if File.exists?("/usr/bin/mpd")
|
if File.exists?("/usr/bin/mpd")
|
||||||
if !File.exists?("/usr/bin/mpc")
|
if !File.exists?("/usr/bin/mpc")
|
||||||
@ -81,49 +81,49 @@ if File.exists?("/usr/bin/mpd")
|
|||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
puts "starting mpd if not already running"
|
puts "starting mpd if not already running"
|
||||||
system("systemctl start mpd") unless `ps aux | grep mpd` != ""
|
`systemctl start mpd` unless `ps aux | grep mpd` != ""
|
||||||
system("mpc clear")
|
`mpc clear`
|
||||||
system("mpc add /")
|
`mpc add /`
|
||||||
system("mpc shuffle")
|
`mpc shuffle`
|
||||||
system("mpc repeat")
|
`mpc repeat`
|
||||||
end
|
end
|
||||||
|
|
||||||
bot = Discordrb::Commands::CommandBot.new token: options[:bot_token], prefix: '!radio '
|
bot = Discordrb::Commands::CommandBot.new token: options[:bot_token], prefix: '!radio '
|
||||||
|
|
||||||
bot.command :start do |event|
|
bot.command :start do |event|
|
||||||
system("mpc play")
|
`mpc play`
|
||||||
event.respond("starting radio")
|
event.respond("starting radio")
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.command :stop do |event|
|
bot.command :stop do |event|
|
||||||
system("mpc stop")
|
`mpc stop`
|
||||||
event.respond("stoping radio")
|
event.respond("stoping radio")
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.command :reload do |event|
|
bot.command :reload do |event|
|
||||||
event.respond("reloading queue")
|
event.respond("reloading queue")
|
||||||
system("mpc stop")
|
`mpc stop`
|
||||||
system("mpc clear")
|
`mpc clear`
|
||||||
system("mpc update")
|
`mpc update`
|
||||||
system("mpc add /")
|
`mpc add /`
|
||||||
event.respond("queue reloaded")
|
event.respond("queue reloaded")
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.command :pause do |event|
|
bot.command :pause do |event|
|
||||||
event.respond("pausing playback")
|
event.respond("pausing playback")
|
||||||
system("mpc toggle")
|
`mpc toggle`
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.command :skip do |event|
|
bot.command :skip do |event|
|
||||||
event.respond("skipping")
|
event.respond("skipping")
|
||||||
system("mpc next")
|
`mpc next`
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.command :shuffle do |event|
|
bot.command :shuffle do |event|
|
||||||
system("mpc shuffle")
|
`mpc shuffle`
|
||||||
event.respond("shuffled queue")
|
event.respond("shuffled queue")
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user