Module: Mchat::Command::Name::InstanceMethods

Defined in:
lib/mchat/commands/name.rb

Instance Method Summary collapse

Instance Method Details

#name_command_run(user_name = nil) ⇒ Object



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

#name_help_docObject



16
17
18
19
20
21
22
23
24
# File 'lib/mchat/commands/name.rb', line 16

def name_help_doc
  _puts %Q(
#{"Help: Name".style.bold}

command: /name <your name in channel>
explain: give your name in channel for chatting.

  )
end