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
Message =
Whatup::Server::Message
Client =
Whatup::Server::Client

Instance Method Summary collapse

Methods included from ThorInteractive

banner, extended

Instance Method Details

#listObject



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

def list
  say 'Your direct messages:'
  say \
    Message.where(sender: current_user)
    .or(Message.where(recipient: current_user))
    .map(&:to_s)
           .join('-' * 10)
end

#msg(name) ⇒ Object



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

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