Sha256: 1d843728a59e044aa4fd90f515423abf602f2d5f4cd8265ee8b5f2e2129e2130

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

module MadChatter
  
  module Actions
    
    class Rename < MadChatter::Actions::Base
      
      @@command = '/nick'
      
      def process
        old_username = username
        username = parse_username_from_message
        MadChatter::Users.update(@user_token, username)
        MadChatter::Server.send_users_list
        MadChatter::Server.send_status("#{old_username} is now known as #{username}")
      end
      
      def parse_username_from_message
        # clear the command from the message string
        # the rest will be the new username
        username = @message.sub("#{@@command} ", '')
      end
      
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mad_chatter-0.0.7 lib/mad_chatter/actions/rename.rb