class Chatrix::Components::Messaging

Class to handle messaging actions for a room.

Public Class Methods

new(room, matrix) click to toggle source

Initializes a new Messaging instance. @param room [Room] The room to handle messaging for. @param matrix [Matrix] Matrix API instance.

# File lib/chatrix/components/messaging.rb, line 11
def initialize(room, matrix)
  @room = room
  @matrix = matrix
end

Public Instance Methods

send_emote(message) click to toggle source

Sends an emote to the room. @param message [String] The emote text to send. @return (see send_message)

# 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) click to toggle source

Sends an HTML message to the room. @param message [String] The HTML formatted message to send. @param clean [String, nil] The “clean” message to use for the `body`

field for clients that are unable to render the formatted
message.

@return (see send_message)

# 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) click to toggle source

Sends a message to the room. @param message [String] The message to send. @return [String] Event ID for the send action.

# File lib/chatrix/components/messaging.rb, line 19
def send_message(message)
  @matrix.rooms.actions.send_message @room.id, message
end
send_notice(message) click to toggle source

Sends a notice to the room. @param message [String] The notice to send. @return (see send_message)

# File lib/chatrix/components/messaging.rb, line 26
def send_notice(message)
  @matrix.rooms.actions.send_message @room.id, message, 'm.notice'
end