diff --git a/main.rb b/main.rb index 69b10c2..91d20dd 100644 --- a/main.rb +++ b/main.rb @@ -47,8 +47,8 @@ def update_mpd() return true end puts "telling mpd to refresh" - system("mv spool/*.mp3 tracks/") - system("mpc update") + `mv spool/*.mp3 tracks/` + `mpc update` new_songs.each do |song| s = song.split("/")[1] res = system("mpc add #{Shellwords.shellescape(s)}") @@ -72,8 +72,8 @@ if options.length == 0 end puts "creating spool and tracks directories" -system("mkdir -p spool") -system("mkdir -p tracks") +`mkdir -p spool` +`"mkdir -p tracks` if File.exists?("/usr/bin/mpd") if !File.exists?("/usr/bin/mpc") @@ -81,49 +81,49 @@ if File.exists?("/usr/bin/mpd") exit end puts "starting mpd if not already running" - system("systemctl start mpd") unless `ps aux | grep mpd` != "" - system("mpc clear") - system("mpc add /") - system("mpc shuffle") - system("mpc repeat") + `systemctl start mpd` unless `ps aux | grep mpd` != "" + `mpc clear` + `mpc add /` + `mpc shuffle` + `mpc repeat` end bot = Discordrb::Commands::CommandBot.new token: options[:bot_token], prefix: '!radio ' bot.command :start do |event| - system("mpc play") + `mpc play` event.respond("starting radio") end bot.command :stop do |event| - system("mpc stop") + `mpc stop` event.respond("stoping radio") end bot.command :reload do |event| event.respond("reloading queue") - system("mpc stop") - system("mpc clear") - system("mpc update") - system("mpc add /") + `mpc stop` + `mpc clear` + `mpc update` + `mpc add /` event.respond("queue reloaded") nil end bot.command :pause do |event| event.respond("pausing playback") - system("mpc toggle") + `mpc toggle` nil end bot.command :skip do |event| event.respond("skipping") - system("mpc next") + `mpc next` nil end bot.command :shuffle do |event| - system("mpc shuffle") + `mpc shuffle` event.respond("shuffled queue") nil end