class Session attr_reader :bot, :owner, :users def initialize(event, owner) @bot = event.bot @owner = owner @users = [owner] event.respond "New Ika session created!" end COMMANDS = %w[ join ] def command_join(event) user = event.message.author if contains_user? user "#{event.message.author.username} is already in this session" else "#{event.message.author.username} joined" end end def add_user(user) users << user end def contains_user?(user) users.include? user end def valid_command(message_content) prebang, cmd = message_content.split("!") cmd if prebang.empty? && COMMANDS.include?(cmd) end def respond_to(event) if command = valid_command(event.message.content) puts "running !#{command} from #{event.message.author.username}" event.respond send("command_#{command}", event) else respond_to_normal_message event end end def respond_to_normal_message(event) puts "received '#{event.message.content}' from #{event.message.author.username}" end end