From 952ec87ba47a16fa234f59b2550c5d3d81e35bf8 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 19 Dec 2021 17:49:03 -0500 Subject: [PATCH] add commands --- main.rb | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/main.rb b/main.rb index dd8c462..8776575 100644 --- a/main.rb +++ b/main.rb @@ -28,12 +28,42 @@ if File.exists?("/usr/bin/mpd") system("systemctl start mpd") unless `ps aux | grep mpd` != "" system("mpc clear") system("mpc add /") + system("mpc repeat") mpd = true end -bot = Discordrb::Bot.new token: options[:bot_token] +bot = Discordrb::Commands::CommandBot.new token: options[:bot_token], prefix: '!' + +bot.command :start do |event| + system("mpc play") + event.respond("starting radio") +end + +bot.command :stop do |event| + system("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 /") +end + +bot.command :pause do |event| + event.respond("pausing playback") + system("mpc pause") +end + +bot.command :skip do |event| + event.respond("skipping") + system("mpc next") +end + + bot.message(in: options[:channel_id],contains: "youtube.com") do |event| - event.respond("got message") urls = URI.extract(event.content) if urls != "" puts "Found #{urls}; downloading"