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|
    "      From: \#{msg.sender.name}\n\n      \#{msg.content}\n    MSG\n  end.join('-' * 10)\n  say msgs\nend\n"

#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 "      Sending a direct message to \#{name}...\n\n      The message can span multiple lines.\n\n      Type `.exit` when you're ready to send it.\n    MSG\n    current_user.composing_dm = recepient\n    return\n  end\n\n  say \"That user doesn't exist!\"\nend\n"