Class: S3PO::Message

Inherits:
Event
  • Object
show all
Defined in:
lib/s-3po/events.rb

Overview

Message Event class comes from Slack, or you would create one to send a message.

Instance Attribute Summary

Attributes inherited from Event

#object

Instance Method Summary collapse

Methods inherited from Event

#channel, #channel=, #is_message?, #is_simplemessage?, #subtype, #ts, #type, #user

Constructor Details

#initialize(event = {}) ⇒ Message

Returns a new instance of Message.



62
63
64
65
# File 'lib/s-3po/events.rb', line 62

def initialize(event = {})
  event[:type] = :message
  super(event)
end

Instance Method Details

#commandsObject



92
93
94
# File 'lib/s-3po/events.rb', line 92

def commands
  @commands ||= Parser.commands_from_text(text)
end

#mentionsObject



87
88
89
# File 'lib/s-3po/events.rb', line 87

def mentions
  @mentions ||= Parser.mentions_from_text(text)
end

#plainObject



77
78
79
# File 'lib/s-3po/events.rb', line 77

def plain
  @plain ||= Parser.plain_from_text(text)
end

#plain=(string) ⇒ Object



81
82
83
84
85
# File 'lib/s-3po/events.rb', line 81

def plain=(string)
  fail 'Must be a String.' unless string.class == String
  @plain = string
  object[:text] = Generator.text_from_plain(@plain)
end

#textObject



67
68
69
# File 'lib/s-3po/events.rb', line 67

def text
  object[:text]
end

#text=(string) ⇒ Object



71
72
73
74
75
# File 'lib/s-3po/events.rb', line 71

def text=(string)
  fail 'Must be a String.' unless string.class == String
  object[:text] = string
  @plain = nil
end