49 lines
702 B
Ruby
49 lines
702 B
Ruby
class Drill
|
|
COMMANDS = %w[
|
|
init
|
|
start
|
|
end
|
|
]
|
|
|
|
attr_reader :channel
|
|
|
|
def initialize(channel)
|
|
@channel = channel
|
|
@exists = false
|
|
@started = false
|
|
end
|
|
|
|
def init!
|
|
@exists = true
|
|
end
|
|
|
|
def start!
|
|
@started = true
|
|
end
|
|
|
|
def end!
|
|
@started = false
|
|
end
|
|
|
|
def handle_message(message)
|
|
message.command_message ? handle_command(message) : handle_normal_message(message)
|
|
end
|
|
|
|
def handle_command(message)
|
|
command = message.command
|
|
if COMMANDS.includes?(command)
|
|
send("handle_#{command}", message)
|
|
else
|
|
puts "[Drill] Unknown command #{command}"
|
|
end
|
|
end
|
|
|
|
def started?
|
|
@started
|
|
end
|
|
|
|
def exists?
|
|
@exists
|
|
end
|
|
end
|