class S3PO::Message
Message
Event
class comes from Slack, or you would create one to send a message.
Public Instance Methods
instruction()
click to toggle source
Break up the message text into an Arrary per word when prefixed with bot username; e.g., “@bot echo hello” @return [Array] excluding the prefixed bot username
# File lib/s-3po/events.rb, line 116 def instruction return nil unless is_instruction? @instruction ||= Parser.instruction_from_plain(plain, options[:botid]) end
is_instruction?()
click to toggle source
Is the message directed to me and/or prefixed with bot username? @return [Boolean]
# File lib/s-3po/events.rb, line 103 def is_instruction? return false unless plain withprefix = /^@#{options[:botid]}[!:;,.-]*\s+\S/ withoutprefix = /^[^@]/ return true if (withprefix =~ plain) == 0 if is_im? return true if (withoutprefix =~ plain) == 0 end return false end
mentions()
click to toggle source
# File lib/s-3po/events.rb, line 97 def mentions @mentions ||= Parser.mentions_from_text(text) end
plain()
click to toggle source
# File lib/s-3po/events.rb, line 86 def plain return nil if text.nil? @plain ||= Parser.plain_from_text(text) end
plain=(string)
click to toggle source
# File lib/s-3po/events.rb, line 91 def plain=(string) fail 'Must be a String.' unless string.class == String @plain = string object[:text] = Generator.text_from_plain(@plain) end
text()
click to toggle source
# File lib/s-3po/events.rb, line 76 def text object[:text] end
text=(string)
click to toggle source
# File lib/s-3po/events.rb, line 80 def text=(string) fail 'Must be a String.' unless string.class == String object[:text] = string @plain = nil end