Class: MadChatter::Actions::Rename
- Defined in:
- lib/mad_chatter/actions/rename.rb
Constant Summary collapse
- @@regex =
/\/nick (.+)/
Instance Method Summary collapse
Methods inherited from Base
Methods included from Dsl
#on_message, #send_action, #send_json, #send_message, #send_status_message, #send_users_list, #stop_message_handling
Constructor Details
This class inherits a constructor from MadChatter::Actions::Base
Instance Method Details
#handle(message) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mad_chatter/actions/rename.rb', line 7 def handle() if .filtered_text =~ @@regex old_username = .username username = parse_username(.filtered_text) MadChatter::Users.update(.token, username) "#{old_username} is now known as #{username}" send_users_list end end |
#parse_username(text) ⇒ Object
18 19 20 |
# File 'lib/mad_chatter/actions/rename.rb', line 18 def parse_username(text) @@regex.match(text).captures[0] end |