class SlackBot::Message
Attributes
user[R]
Public Class Methods
new(data, bot)
click to toggle source
# File lib/slack/wrappers/message.rb, line 7 def initialize(data, bot) @data = data @bot = bot @user = bot.user(data['user']) end
Public Instance Methods
[](key)
click to toggle source
# File lib/slack/wrappers/message.rb, line 21 def [](key) @data[key] end
[]=(key, val)
click to toggle source
# File lib/slack/wrappers/message.rb, line 25 def []=(key, val) @data[key] = val end
channel()
click to toggle source
# File lib/slack/wrappers/message.rb, line 36 def channel chan = @data['channel'] @bot.channel(chan) || @bot.user_channel(@user) end
id()
click to toggle source
Helpers!
# File lib/slack/wrappers/message.rb, line 30 def id; @data['id'] end
reply(text)
click to toggle source
# File lib/slack/wrappers/message.rb, line 13 def reply(text) @bot.post channel, text end
text()
click to toggle source
# File lib/slack/wrappers/message.rb, line 31 def text; @data['text'] end
time()
click to toggle source
# File lib/slack/wrappers/message.rb, line 32 def time ts = @data['ts'] ts && Time.at(ts.to_i) end
to_s()
click to toggle source
# File lib/slack/wrappers/message.rb, line 17 def to_s "#{@user}: #{self.text}" end