ika_bot/lib/drill.rb

49 lines
702 B
Ruby
Raw Normal View History

2025-08-19 21:07:51 -04:00
class Drill
2025-08-23 14:38:42 -04:00
COMMANDS = %w[
init
start
end
]
2025-08-19 21:07:51 -04:00
attr_reader :channel
def initialize(channel)
@channel = channel
2025-08-23 14:38:42 -04:00
@exists = false
2025-08-19 21:07:51 -04:00
@started = false
end
2025-08-23 14:38:42 -04:00
def init!
@exists = true
end
2025-08-19 21:07:51 -04:00
def start!
@started = true
end
2025-08-23 14:38:42 -04:00
def end!
@started = false
2025-08-19 21:07:51 -04:00
end
2025-08-23 14:38:42 -04:00
def handle_message(message)
message.command_message ? handle_command(message) : handle_normal_message(message)
2025-08-19 21:07:51 -04:00
end
2025-08-23 14:38:42 -04:00
def handle_command(message)
command = message.command
if COMMANDS.includes?(command)
send("handle_#{command}", message)
else
puts "[Drill] Unknown command #{command}"
2025-08-19 21:07:51 -04:00
end
2025-08-23 14:38:42 -04:00
end
2025-08-19 21:07:51 -04:00
2025-08-23 14:38:42 -04:00
def started?
@started
end
2025-08-19 21:07:51 -04:00
2025-08-23 14:38:42 -04:00
def exists?
@exists
2025-08-19 21:07:51 -04:00
end
end