Class: MadChatter::MessageListeners::Nick

Inherits:
Object
  • Object
show all
Includes:
Actions
Defined in:
lib/mad_chatter/message_listeners/nick.rb

Constant Summary collapse

@@regex =
%r{^/nick (.+)}

Instance Method Summary collapse

Methods included from Actions

#send_action, #send_message, #send_status_message, #stop_message_handling

Instance Method Details

#handle(message) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/mad_chatter/message_listeners/nick.rb', line 9

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

#parse_username(text) ⇒ Object



20
21
22
# File 'lib/mad_chatter/message_listeners/nick.rb', line 20

def parse_username(text)
  @@regex.match(text).captures[0]
end