Module: Mchat::Command::Message::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#message_command_run(words) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mchat/commands/message.rb', line 26

def message_command_run(words)
  if !_current_channel
    _puts "You are not in channel, so you cannot message.".style.warn
    _puts "type `/n[ame] <your name>` before chat".style.warn
  elsif !_current_nickname
    _puts "You must register a name to this channel".style.warn
    _puts "type `/n[ame] <your name>` before chat".style.warn
  elsif _current_channel && _current_nickname
    resp = _api.create_channel_message(_current_channel, _current_nickname, words)
    code = resp.fetch("code")

    if code != StatusCode::Success
      _puts warn "Send Message Fail:"
      _puts "quote----"
      _puts "#{words}"
      _puts "---------"
    else
      _puts "send success"
    end
  end
  # TODO send to server
  # _puts2("#{Message.new(words).display}")
end

#message_help_docObject



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

def message_help_doc
  _puts %Q(
  #{"Help: Message".style.bold}

  command: /message <message>
  explain: send your message

  )
end