Class: Chatrix::Components::Messaging

Inherits:
Object
  • Object
show all
Defined in:
lib/chatrix/components/messaging.rb

Overview

Class to handle messaging actions for a room.

Instance Method Summary collapse

Constructor Details

#initialize(room, matrix) ⇒ Messaging

Initializes a new Messaging instance.

Parameters:

  • room (Room)

    The room to handle messaging for.

  • matrix (Matrix)

    Matrix API instance.



11
12
13
14
# File 'lib/chatrix/components/messaging.rb', line 11

def initialize(room, matrix)
  @room = room
  @matrix = matrix
end

Instance Method Details

#send_emote(message) ⇒ String

Sends an emote to the room.

Parameters:

  • message (String)

    The emote text to send.

Returns:

  • (String)

    Event ID for the send action.



33
34
35
# File 'lib/chatrix/components/messaging.rb', line 33

def send_emote(message)
  @matrix.rooms.actions.send_message @room.id, message, 'm.emote'
end

#send_html(message, clean = nil) ⇒ String

Sends an HTML message to the room.

Parameters:

  • message (String)

    The HTML formatted message to send.

  • clean (String, nil) (defaults to: nil)

    The "clean" message to use for the body field for clients that are unable to render the formatted message.

Returns:

  • (String)

    Event ID for the send action.



43
44
45
# File 'lib/chatrix/components/messaging.rb', line 43

def send_html(message, clean = nil)
  @matrix.rooms.actions.send_html @room.id, message, clean
end

#send_message(message) ⇒ String

Sends a message to the room.

Parameters:

  • message (String)

    The message to send.

Returns:

  • (String)

    Event ID for the send action.



19
20
21
# File 'lib/chatrix/components/messaging.rb', line 19

def send_message(message)
  @matrix.rooms.actions.send_message @room.id, message
end

#send_notice(message) ⇒ String

Sends a notice to the room.

Parameters:

  • message (String)

    The notice to send.

Returns:

  • (String)

    Event ID for the send action.



26
27
28
# File 'lib/chatrix/components/messaging.rb', line 26

def send_notice(message)
  @matrix.rooms.actions.send_message @room.id, message, 'm.notice'
end