Sha256: 5de7d7a6da1674403ef5cb10002f7a6d593a19b36b2653c0ee12927b237f6547

Contents?: true

Size: 546 Bytes

Versions: 6

Compression:

Stored size: 546 Bytes

Contents

module MadChatter
  module Actions
    class Join < MadChatter::Action
      
      @@regex = /\/join (.+)/
      
      def handle(message)
        if message.text =~ @@regex
          username = parse_username(message.text)
          MadChatter::Users.update(message.token, username)
          send_status_message "#{username} has joined the chatroom"
          send_users_list
          stop_message_handling
        end
      end
      
      def parse_username(text)
        @@regex.match(text).captures[0]
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mad_chatter-0.2.1 lib/mad_chatter/actions/join.rb
mad_chatter-0.2.0 lib/mad_chatter/actions/join.rb
mad_chatter-0.1.3 lib/mad_chatter/actions/join.rb
mad_chatter-0.1.2 lib/mad_chatter/actions/join.rb
mad_chatter-0.1.1 lib/mad_chatter/actions/join.rb
mad_chatter-0.1.0 lib/mad_chatter/actions/join.rb