Class: ReactionEvent

Inherits:
Event
  • Object
show all
Defined in:
src/events/reaction_event.rb

Instance Attribute Summary

Attributes inherited from Event

#app

Instance Method Summary collapse

Methods inherited from Event

#message?, #mqtt_message?

Instance Method Details

#added?Boolean

Is this a reaction add event?

Parameters:

  • (Boolean)

Returns:

  • (Boolean)


48
49
50
# File 'src/events/reaction_event.rb', line 48

def added?
  data.type == 'reaction_added'
end

#channelObject

The channel ID of the message the reaction was on

Parameters:

  • (String)


62
63
64
# File 'src/events/reaction_event.rb', line 62

def channel
  data.item.channel
end

#messageMessage

TODO:

Test

TODO:

Support reactions on files

The message that was reacted on

Returns:



72
73
74
75
76
77
78
79
# File 'src/events/reaction_event.rb', line 72

def message
  @_message ||= Message.from_partial(
    @app,
    data.item.type,
    data.item.channel,
    data.item.ts
  )
end

#message_from_self?Boolean

Is the reaction on a message that was posted by the bot?

Returns:

  • (Boolean)


84
85
86
# File 'src/events/reaction_event.rb', line 84

def message_from_self?
  message_user_id == app.user_id
end

#reactionString

The name of the reaction that was reacted with

Does not include :.

Returns:

  • (String)

    The reaction name



41
42
43
# File 'src/events/reaction_event.rb', line 41

def reaction
  data.reaction
end

#reaction?true

Is this a reaction event?

Returns:

  • (true)


16
17
18
# File 'src/events/reaction_event.rb', line 16

def reaction?
  true
end

#reaction_on_message?Boolean

Is this a reaction on a message?

Other reaction types may be on files.

Returns:

  • (Boolean)


25
26
27
# File 'src/events/reaction_event.rb', line 25

def reaction_on_message?
  @data.item.type == 'message'
end

#removed?Boolean

Is this a reaction remove event?

Parameters:

  • (Boolean)

Returns:

  • (Boolean)


55
56
57
# File 'src/events/reaction_event.rb', line 55

def removed?
  !added?
end

#userUser

Get the user that reacted on the message

Returns:

  • (User)

    The user that reacted on the message



32
33
34
# File 'src/events/reaction_event.rb', line 32

def user
  @_user ||= User.new(app, @data.user)
end