26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/mchat/commands/name.rb', line 26
def name_command_run(user_name = nil)
if _current_nickname
_puts "You have `name` and active in this channel now.".style.warn
_puts "Please leave this channel then change your name.".style.warn
else
resp = _api.join_channel( _current_channel , user_name)
code = resp.fetch("code")
if code == StatusCode::Success
_puts "#{user_name} is avalibale.".style.primary
_set_current_nickname user_name
channel_heartbeat_task
else
_set_current_nickname nil
_puts "#{user_name} has been used in channel: #{_current_channel}\ntry rename.".style.warn
end
end
end
|