Polyjuice Client v0.2.3 Polyjuice.Client.Room View Source
Room-related functions.
Link to this section Summary
Types
Represents a position in the timeline, used for paginating events before/after this position.
Functions
Get messages from a room starting from a certain point.
Get a room state.
If event_type
is not provided, returns a list of events.
If event_type
and state_key
are provided, returns an event content.
state_key
can be omitted but this will return events that have a blank state key, not events that have "any state key".
Send an event to a room.
Send a message to a room.
Send a state event to a room.
Paginate messages from a room starting from a certain point.
Update the client's read receipt (of the given type) to the given message in the given room.
Link to this section Types
Represents a position in the timeline, used for paginating events before/after this position.
Link to this section Functions
get_messages(client_api, room, from, dir, opts \\ [])
View Sourceget_messages( client_api :: Polyjuice.Client.API.t(), room :: String.t(), from :: timeline_pos(), dir :: :forward | :backward, opts :: list() ) :: {:ok, map()} | Any
Get messages from a room starting from a certain point.
get_state(client_api, room, event_type \\ nil, state_key \\ "")
View Sourceget_state( client_api :: Polyjuice.Client.API.t(), room :: String.t(), event_type :: String.t(), state_key :: String.t() ) :: {:ok, String.t()} | Any
Get a room state.
If event_type
is not provided, returns a list of events.
If event_type
and state_key
are provided, returns an event content.
state_key
can be omitted but this will return events that have a blank state key, not events that have "any state key".
join(client_api, room, servers \\ [], third_party_signed \\ nil)
View Sourcejoin( client_api :: Polyjuice.Client.API.t(), room :: String.t(), servers :: [String.t()], third_party_signed :: map() | nil ) :: {:ok, String.t()} | Any
Join a room.
send_event(client_api, room, event_type, event)
View Sourcesend_event( client_api :: Polyjuice.Client.API.t(), room :: String.t(), event_type :: String.t(), event :: map() ) :: {:ok, String.t()} | Any
Send an event to a room.
send_message(client_api, room, msg)
View Sourcesend_message( client_api :: Polyjuice.Client.API.t(), room :: String.t(), msg :: map() | Polyjuice.Client.MsgBuilder.MsgData.t() ) :: {:ok, String.t()} | Any
Send a message to a room.
msg
can either be anything that implements the
Polyjuice.Client.MsgBuilder.MsgData
protocol (which will be sent as an
m.message
), or a map (which specifies the full message content).
Examples:
Polyjuice.Client.Room.send_message(client, "text message", "!room_id")
Polyjuice.Client.Room.send_message(
client,
{"message with formatting", "<i>message</i> with <b>formatting</b>"},
"!room_id"
)
Polyjuice.Client.Room.send_message(
client,
["Hello, ", Polyjuice.Client.MsgBuilder.mention("@world:example.com")],
"!room_id"
)
Polyjuice.Client.Room.send_message(
client,
%{"msgtype" => "m.notice", "body" => "using full message content"},
"!room_id"
)
send_state_event(client_api, room, event_type, state_key \\ "", event)
View SourceSend a state event to a room.
stream_messages(client_api, room, from, dir, opts \\ [])
View Sourcestream_messages( client_api :: Polyjuice.Client.API.t(), room :: String.t(), from :: timeline_pos(), dir :: :forward | :backward, opts :: list() ) :: Enumerable.t()
Paginate messages from a room starting from a certain point.
This function returns a stream of message chunks as would be returned by
get_messages
.
Examples:
Back-paginate until it reaches events before a given timestamp.
Polyjuice.Client.Room.stream_messages(client, "!room_id", token, :backward)
|> Stream.map(&Map.get(&1, "chunk", []))
|> Stream.concat()
|> Stream.take_while(&(Map.get(&1, "origin_server_ts", 0) >= timestamp))
|> Enum.reverse()
update_read_receipt(client_api, room, event_id, receipt_type \\ "m.read")
View Sourceupdate_read_receipt( client_api :: Polyjuice.Client.API.t(), room :: String.t(), event_id :: String.t(), receipt_type :: String.t() ) :: {:ok} | Any
Update the client's read receipt (of the given type) to the given message in the given room.