Sha256: fe7d36f7fd0424b28b3c7c2fc5c1e2b0d1d11134647c94e13067754662e7b8db

Contents?: true

Size: 623 Bytes

Versions: 9

Compression:

Stored size: 623 Bytes

Contents

module MadChatter
  module Actions
    class Rename < MadChatter::Actions::Base
      
      @@regex = /\/nick (.+)/
      
      def handle(message)
        if message.filtered_text =~ @@regex
          old_username = message.username
          username = parse_username(message.filtered_text)
          MadChatter::Users.update(message.token, username)
          send_status_message "#{old_username} is now known as #{username}"
          send_users_list
          stop_message_handling
        end
      end
      
      def parse_username(text)
        @@regex.match(text).captures[0]
      end
      
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mad_chatter-0.3.1 lib/mad_chatter/actions/rename.rb
mad_chatter-0.3.0 lib/mad_chatter/actions/rename.rb
mad_chatter-0.2.9 lib/mad_chatter/actions/rename.rb
mad_chatter-0.2.8 lib/mad_chatter/actions/rename.rb
mad_chatter-0.2.7 lib/mad_chatter/actions/rename.rb
mad_chatter-0.2.6 lib/mad_chatter/actions/rename.rb
mad_chatter-0.2.5 lib/mad_chatter/actions/rename.rb
mad_chatter-0.2.4 lib/mad_chatter/actions/rename.rb
mad_chatter-0.2.3 lib/mad_chatter/actions/rename.rb