Class: Whatup::CLI::Dm

Inherits:
Thor
  • Object
show all
Extended by:
ThorInteractive
Defined in:
lib/whatup/cli/commands/interactive/dm.rb

Overview

Server commands

Constant Summary collapse

Room =
Whatup::Server::Room
Client =
Whatup::Server::Client

Instance Method Summary collapse

Methods included from ThorInteractive

banner, extended

Instance Method Details

#listObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/whatup/cli/commands/interactive/dm.rb', line 33

def list
  say 'Your direct messages:'
  msgs = current_user.received_messages.map do |msg|
    <<~MSG
      From: #{msg.sender.name}

      #{msg.content}
    MSG
  end.join('-' * 10)
  say msgs
end

#msg(name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/whatup/cli/commands/interactive/dm.rb', line 16

def msg name
  if recepient = Client.find_by(name: name)
    say <<~MSG
      Sending a direct message to #{name}...

      The message can span multiple lines.

      Type `.exit` when you're ready to send it.
    MSG
    current_user.composing_dm = recepient
    return
  end

  say "That user doesn't exist!"
end