ika_bot/lesson.rb
2025-08-14 20:02:00 -04:00

39 lines
839 B
Ruby

DEFAULT_LESSON_PLAN = [
[15, "login and catch up on the week"],
[45, "review chapter vocab and grammar"],
[15, "answer Seth Clydesdale Genki review questions"],
[15, "ask closing questions and have Japanese conversation"],
]
class Lesson
attr_reader :lesson_plan, :channel, :thread, :running
def initialize(lesson_plan=DEFAULT_LESSON_PLAN)
@lesson_plan = lesson_plan
@running = false
end
def stop!
thread.kill if thread
@running = false
end
def start!(channel)
stop!
@channel = channel
@thread = Thread.new do
@running = true
lesson_plan.each do |time, message|
channel.send_message "#{time} minutes to #{message}"
sleep(time * 60)
end
channel.send_message "Lesson over!"
@running = false
end
end
def running?
running
end
end