Module: Mchat::Command::Join::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#join_command_run(channel_name = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mchat/commands/join.rb', line 25

def join_command_run(channel_name = nil)
  if !channel_name
    _puts "channel_name missing !\n type`/join <channel_name>`".style.warn
  else
    # TODO channel password
    # TODO channel 白名单
    resp = _api.get_channels
    all_channels = resp.fetch("data")

    if all_channels.any? channel_name
      _mchat_action("join channel: #{channel_name}")
      _set_current_channel  channel_name
      fetch_channel_task
    else
      _puts "Channel: #{channel_name} not found!".style.warn
    end
  end
end

#join_help_docObject



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

def join_help_doc
  _puts %Q(
#{"Help: Join".style.bold}

command: /join <channel_name>
explain: join the channel

  )
end