From 0df41a7aae23246d198ec18e6c42c3dc37b03680 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Sat, 23 Aug 2025 20:38:53 -0400 Subject: [PATCH] Delete commands arhitecture --- lib/commands.rb | 4 --- lib/commands/command.rb | 46 ----------------------------- lib/commands/help_command.rb | 16 ---------- lib/commands/lesson_command.rb | 19 ------------ lib/commands/stop_lesson_command.rb | 18 ----------- 5 files changed, 103 deletions(-) delete mode 100644 lib/commands.rb delete mode 100644 lib/commands/command.rb delete mode 100644 lib/commands/help_command.rb delete mode 100644 lib/commands/lesson_command.rb delete mode 100644 lib/commands/stop_lesson_command.rb diff --git a/lib/commands.rb b/lib/commands.rb deleted file mode 100644 index 68965b2..0000000 --- a/lib/commands.rb +++ /dev/null @@ -1,4 +0,0 @@ -require_relative "commands/command" -require_relative "commands/help_command" -require_relative "commands/lesson_command" -require_relative "commands/stop_lesson_command" diff --git a/lib/commands/command.rb b/lib/commands/command.rb deleted file mode 100644 index 18cec65..0000000 --- a/lib/commands/command.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Commands - @@commands = [] - - def self.register_command(command_class) - @@commands << command_class - end - - def self.registered_commands - @@commands - end - - class Command - def self.inherited(klass) - Commands.register_command klass - end - - def self.for(ika, message) - Commands.registered_commands.find do |command_class| - command_class.matches? message.content - end&.new(ika, message) - end - - def self.matches?(message_text) - message_text == "!#{command_string}" - end - - def self.help - "!#{command_string} - #{description}" - end - - def self.description - "blah blah blah" - end - - attr_reader :ika, :message - - def initialize(ika, message) - @ika = ika - @message = message - end - - def execute - puts "This is a generic command! I can't execute anything!" - end - end -end diff --git a/lib/commands/help_command.rb b/lib/commands/help_command.rb deleted file mode 100644 index aa9501f..0000000 --- a/lib/commands/help_command.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Commands - class Help < Command - def self.command_string - "help" - end - - def self.description - "Shows you a list of available commands" - end - - def execute - message.respond ["I'm Ika! Here are the commands I know:", - *Commands.registered_commands.map(&:help)].join("\n") - end - end -end diff --git a/lib/commands/lesson_command.rb b/lib/commands/lesson_command.rb deleted file mode 100644 index 71174c5..0000000 --- a/lib/commands/lesson_command.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Commands - class LessonCommand < Command - def self.command_string - "lesson" - end - - def self.description - "Starts timers for a lesson" - end - - def execute - return message.respond("There's already a lesson running!") if ika.current_lesson_running? - - message.respond("Starting a lesson now!") - - ika.start_lesson! message - end - end -end diff --git a/lib/commands/stop_lesson_command.rb b/lib/commands/stop_lesson_command.rb deleted file mode 100644 index ee0d571..0000000 --- a/lib/commands/stop_lesson_command.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Commands - class StopLessonCommand < Command - def self.command_string - "stoplesson" - end - - def self.description - "Stops the current lesson, if one is running" - end - - def execute - return message.respond("There's no lesson running") unless ika.current_lesson_running? - - message.respond("Ending the current lesson!") - ika.stop_current_lesson! - end - end -end