Class: Boty::Slack::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/boty/slack/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, match: nil) ⇒ Message

Returns a new instance of Message.



7
8
9
10
11
12
13
14
# File 'lib/boty/slack/message.rb', line 7

def initialize(data, match: nil)
  @text = data["text"]
  @user = Slack.users.info data["user"]
  @channel = data["channel"]
  @ts = data["ts"]
  @team = data["team"]
  @match = match
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



4
5
6
# File 'lib/boty/slack/message.rb', line 4

def channel
  @channel
end

#matchObject (readonly)

Returns the value of attribute match.



5
6
7
# File 'lib/boty/slack/message.rb', line 5

def match
  @match
end

#teamObject

Returns the value of attribute team.



4
5
6
# File 'lib/boty/slack/message.rb', line 4

def team
  @team
end

#textObject

Returns the value of attribute text.



4
5
6
# File 'lib/boty/slack/message.rb', line 4

def text
  @text
end

#tsObject

Returns the value of attribute ts.



4
5
6
# File 'lib/boty/slack/message.rb', line 4

def ts
  @ts
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/boty/slack/message.rb', line 4

def user
  @user
end

Instance Method Details

#from?(author) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/boty/slack/message.rb', line 20

def from?(author)
  if author.respond_to? :id
    @user.id == author.id
  else
    @user.id == author
  end
end

#match!(regex) ⇒ Object



16
17
18
# File 'lib/boty/slack/message.rb', line 16

def match!(regex)
  @match = regex.match @text
end