Delete commands arhitecture

This commit is contained in:
Bill Rossi 2025-08-23 20:38:53 -04:00
parent 8320d2dfcb
commit 0df41a7aae
5 changed files with 0 additions and 103 deletions

View File

@ -1,4 +0,0 @@
require_relative "commands/command"
require_relative "commands/help_command"
require_relative "commands/lesson_command"
require_relative "commands/stop_lesson_command"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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