ika_bot/lib/ika.rb

46 lines
976 B
Ruby

require_relative './session'
require_relative './lesson'
require_relative './commands'
require_relative './message'
require_relative './drill_plugin'
class Ika
attr_reader :handler
attr_reader :lessons, :sessions
attr_accessor :current_lesson, :current_session
attr_reader :drill_plugin
def self.for(type:, **kwargs)
type.new **kwargs
end
def initialize
@lessons = {}
@sessions = {}
@current_session = nil
@current_lesson = Lesson.new(responder: responder(nil))
@drill_plugin = DrillPlugin.new(self)
end
def current_lesson_running?
current_lesson.running?
end
def start_lesson!(message)
current_lesson.responder = responder(message.channel)
current_lesson.start!(message.channel)
end
def stop_current_lesson!
current_lesson.stop!
end
def handle_message(message)
if command = Commands::Command.for(self, message)
command.execute
end
# drill_plugin.handle_message message
end
end