Sha256: d8dd652d9a1f31f38b8faf71cce87a5e7e75c4ae21df13490cc967461a98db71

Contents?: true

Size: 528 Bytes

Versions: 3

Compression:

Stored size: 528 Bytes

Contents

module MadChatter
  module MessageListeners
    class Nick
      
      include MadChatter::Actions
      
      @@regex = %r{^/nick (.+)}
      
      def handle(message)
        if @@regex =~ message.text
          username = parse_username(message.text)
          user = message.user
          if user
            user.update_username(username)
          end
          stop_message_handling
        end
      end
      
      def parse_username(text)
        @@regex.match(text).captures[0]
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mad_chatter-0.3.4 lib/mad_chatter/message_listeners/nick.rb
mad_chatter-0.3.3 lib/mad_chatter/message_listeners/nick.rb
mad_chatter-0.3.2 lib/mad_chatter/message_listeners/nick.rb