Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains the client-server API https://matrix.org/docs/spec/client_server/r0.6.1
Synopsis
- data ClientSession
- newtype MatrixToken = MatrixToken Text
- getTokenFromEnv :: Text -> IO MatrixToken
- createSession :: Text -> MatrixToken -> IO ClientSession
- type MatrixM m a = m (Either MatrixError a)
- type MatrixIO a = MatrixM IO a
- data MatrixError = MatrixError {}
- retry :: MatrixIO a -> MatrixIO a
- retryWithLog :: (MonadMask m, MonadIO m) => Int -> (Text -> m ()) -> MatrixM m a -> MatrixM m a
- newtype UserID = UserID Text
- getTokenOwner :: ClientSession -> MatrixIO UserID
- data RoomCreatePreset
- data RoomCreateRequest = RoomCreateRequest {}
- createRoom :: ClientSession -> RoomCreateRequest -> MatrixIO RoomID
- newtype TxnID = TxnID Text
- sendMessage :: ClientSession -> RoomID -> Event -> TxnID -> MatrixIO EventID
- mkReply :: RoomID -> RoomEvent -> MessageText -> Event
- data MessageTextType
- data MessageText = MessageText {
- mtBody :: Text
- mtType :: MessageTextType
- mtFormat :: Maybe Text
- mtFormattedBody :: Maybe Text
- newtype RoomMessage = RoomMessageText MessageText
- data Event
- newtype EventID = EventID {}
- eventType :: Event -> Text
- newtype RoomID = RoomID Text
- getJoinedRooms :: ClientSession -> MatrixIO [RoomID]
- joinRoom :: ClientSession -> Text -> MatrixIO RoomID
- joinRoomById :: ClientSession -> RoomID -> MatrixIO RoomID
- leaveRoomById :: ClientSession -> RoomID -> MatrixIO ()
- data EventFormat
- = Client
- | Federation
- data EventFilter = EventFilter {}
- defaultEventFilter :: EventFilter
- eventFilterAll :: EventFilter
- data RoomEventFilter = RoomEventFilter {
- refLimit :: Maybe Int
- refNotSenders :: Maybe [Text]
- refNotTypes :: Maybe [Text]
- refSenders :: Maybe [Text]
- refTypes :: Maybe [Text]
- refLazyLoadMembers :: Maybe Bool
- refIncludeRedundantMembers :: Maybe Bool
- refNotRooms :: Maybe [Text]
- refRooms :: Maybe [Text]
- refContainsUrl :: Maybe Bool
- defaultRoomEventFilter :: RoomEventFilter
- roomEventFilterAll :: RoomEventFilter
- data StateFilter = StateFilter {
- sfLimit :: Maybe Int
- sfNotSenders :: Maybe [Text]
- sfNotTypes :: Maybe [Text]
- sfSenders :: Maybe [Text]
- sfTypes :: Maybe [Text]
- sfLazyLoadMembers :: Maybe Bool
- sfIncludeRedundantMembers :: Maybe Bool
- sfNotRooms :: Maybe [Text]
- sfRooms :: Maybe [Text]
- sfContains_url :: Maybe Bool
- defaultStateFilter :: StateFilter
- stateFilterAll :: StateFilter
- data RoomFilter = RoomFilter {}
- defaultRoomFilter :: RoomFilter
- data Filter = Filter {}
- defaultFilter :: Filter
- newtype FilterID = FilterID Text
- messageFilter :: Filter
- createFilter :: ClientSession -> UserID -> Filter -> MatrixIO FilterID
- getFilter :: ClientSession -> UserID -> FilterID -> MatrixIO Filter
- sync :: ClientSession -> Maybe FilterID -> Maybe Text -> Maybe Presence -> Maybe Int -> MatrixIO SyncResult
- getTimelines :: SyncResult -> [(RoomID, NonEmpty RoomEvent)]
- syncPoll :: MonadIO m => ClientSession -> Maybe FilterID -> Maybe Text -> Maybe Presence -> (SyncResult -> m ()) -> MatrixM m ()
- newtype Author = Author {}
- data Presence
- = Offline
- | Online
- | Unavailable
- data RoomEvent = RoomEvent {}
- data RoomSummary = RoomSummary {}
- data TimelineSync = TimelineSync {}
- data InvitedRoomSync = InvitedRoomSync
- data JoinedRoomSync = JoinedRoomSync {}
- data SyncResult = SyncResult {}
- data SyncResultRoom = SyncResultRoom {
- srrJoin :: Maybe (Map Text JoinedRoomSync)
- srrInvite :: Maybe (Map Text InvitedRoomSync)
Client
data ClientSession Source #
The session record, use createSession
to create it.
newtype MatrixToken Source #
:: Text | The envirnoment variable name |
-> IO MatrixToken |
:: Text | The matrix client-server base url, e.g. "https://matrix.org" |
-> MatrixToken | The user token |
-> IO ClientSession |
createSession
creates the session record.
API
type MatrixM m a = m (Either MatrixError a) Source #
data MatrixError Source #
Instances
Eq MatrixError Source # | |
Defined in Network.Matrix.Internal (==) :: MatrixError -> MatrixError -> Bool # (/=) :: MatrixError -> MatrixError -> Bool # | |
Show MatrixError Source # | |
Defined in Network.Matrix.Internal showsPrec :: Int -> MatrixError -> ShowS # show :: MatrixError -> String # showList :: [MatrixError] -> ShowS # | |
FromJSON MatrixError Source # | |
Defined in Network.Matrix.Internal parseJSON :: Value -> Parser MatrixError # parseJSONList :: Value -> Parser [MatrixError] # |
:: (MonadMask m, MonadIO m) | |
=> Int | Maximum number of retry |
-> (Text -> m ()) | A log function, can be used to measure errors |
-> MatrixM m a | The action to retry |
-> MatrixM m a |
Retry a network action
User data
getTokenOwner :: ClientSession -> MatrixIO UserID Source #
getTokenOwner
gets information about the owner of a given access token.
Room management
data RoomCreatePreset Source #
Instances
Eq RoomCreatePreset Source # | |
Defined in Network.Matrix.Room (==) :: RoomCreatePreset -> RoomCreatePreset -> Bool # (/=) :: RoomCreatePreset -> RoomCreatePreset -> Bool # | |
Show RoomCreatePreset Source # | |
Defined in Network.Matrix.Room showsPrec :: Int -> RoomCreatePreset -> ShowS # show :: RoomCreatePreset -> String # showList :: [RoomCreatePreset] -> ShowS # | |
ToJSON RoomCreatePreset Source # | |
Defined in Network.Matrix.Room toJSON :: RoomCreatePreset -> Value # toEncoding :: RoomCreatePreset -> Encoding # toJSONList :: [RoomCreatePreset] -> Value # toEncodingList :: [RoomCreatePreset] -> Encoding # |
data RoomCreateRequest Source #
RoomCreateRequest | |
|
Instances
Room participation
sendMessage :: ClientSession -> RoomID -> Event -> TxnID -> MatrixIO EventID Source #
:: RoomID | The destination room, must match the original event |
-> RoomEvent | The original event |
-> MessageText | The reply message |
-> Event | The event to send |
Prepare a reply event
data MessageTextType Source #
Instances
Eq MessageTextType Source # | |
Defined in Network.Matrix.Events (==) :: MessageTextType -> MessageTextType -> Bool # (/=) :: MessageTextType -> MessageTextType -> Bool # | |
Show MessageTextType Source # | |
Defined in Network.Matrix.Events showsPrec :: Int -> MessageTextType -> ShowS # show :: MessageTextType -> String # showList :: [MessageTextType] -> ShowS # | |
ToJSON MessageTextType Source # | |
Defined in Network.Matrix.Events toJSON :: MessageTextType -> Value # toEncoding :: MessageTextType -> Encoding # toJSONList :: [MessageTextType] -> Value # toEncodingList :: [MessageTextType] -> Encoding # | |
FromJSON MessageTextType Source # | |
Defined in Network.Matrix.Events parseJSON :: Value -> Parser MessageTextType # parseJSONList :: Value -> Parser [MessageTextType] # |
data MessageText Source #
MessageText | |
|
Instances
Eq MessageText Source # | |
Defined in Network.Matrix.Events (==) :: MessageText -> MessageText -> Bool # (/=) :: MessageText -> MessageText -> Bool # | |
Show MessageText Source # | |
Defined in Network.Matrix.Events showsPrec :: Int -> MessageText -> ShowS # show :: MessageText -> String # showList :: [MessageText] -> ShowS # | |
ToJSON MessageText Source # | |
Defined in Network.Matrix.Events toJSON :: MessageText -> Value # toEncoding :: MessageText -> Encoding # toJSONList :: [MessageText] -> Value # toEncodingList :: [MessageText] -> Encoding # | |
FromJSON MessageText Source # | |
Defined in Network.Matrix.Events parseJSON :: Value -> Parser MessageText # parseJSONList :: Value -> Parser [MessageText] # |
newtype RoomMessage Source #
Instances
Eq RoomMessage Source # | |
Defined in Network.Matrix.Events (==) :: RoomMessage -> RoomMessage -> Bool # (/=) :: RoomMessage -> RoomMessage -> Bool # | |
Show RoomMessage Source # | |
Defined in Network.Matrix.Events showsPrec :: Int -> RoomMessage -> ShowS # show :: RoomMessage -> String # showList :: [RoomMessage] -> ShowS # | |
ToJSON RoomMessage Source # | |
Defined in Network.Matrix.Events toJSON :: RoomMessage -> Value # toEncoding :: RoomMessage -> Encoding # toJSONList :: [RoomMessage] -> Value # toEncodingList :: [RoomMessage] -> Encoding # | |
FromJSON RoomMessage Source # | |
Defined in Network.Matrix.Events parseJSON :: Value -> Parser RoomMessage # parseJSONList :: Value -> Parser [RoomMessage] # |
EventRoomMessage RoomMessage | |
EventRoomReply EventID RoomMessage | A reply defined by the parent event id and the reply message |
EventRoomEdit (EventID, RoomMessage) RoomMessage | An edit defined by the original message and the new message |
EventUnknown Object |
Room membership
getJoinedRooms :: ClientSession -> MatrixIO [RoomID] Source #
joinRoom :: ClientSession -> Text -> MatrixIO RoomID Source #
Note that this API takes either a room ID or alias, unlike joinRoomById
joinRoomById :: ClientSession -> RoomID -> MatrixIO RoomID Source #
leaveRoomById :: ClientSession -> RoomID -> MatrixIO () Source #
Filter
data EventFormat Source #
Instances
Eq EventFormat Source # | |
Defined in Network.Matrix.Client (==) :: EventFormat -> EventFormat -> Bool # (/=) :: EventFormat -> EventFormat -> Bool # | |
Show EventFormat Source # | |
Defined in Network.Matrix.Client showsPrec :: Int -> EventFormat -> ShowS # show :: EventFormat -> String # showList :: [EventFormat] -> ShowS # | |
ToJSON EventFormat Source # | |
Defined in Network.Matrix.Client toJSON :: EventFormat -> Value # toEncoding :: EventFormat -> Encoding # toJSONList :: [EventFormat] -> Value # toEncodingList :: [EventFormat] -> Encoding # | |
FromJSON EventFormat Source # | |
Defined in Network.Matrix.Client parseJSON :: Value -> Parser EventFormat # parseJSONList :: Value -> Parser [EventFormat] # |
data EventFilter Source #
Instances
eventFilterAll :: EventFilter Source #
A filter that should match nothing
data RoomEventFilter Source #
RoomEventFilter | |
|
Instances
roomEventFilterAll :: RoomEventFilter Source #
A filter that should match nothing
data StateFilter Source #
StateFilter | |
|
Instances
data RoomFilter Source #
Instances
Instances
Eq Filter Source # | |
Show Filter Source # | |
Generic Filter Source # | |
ToJSON Filter Source # | |
Defined in Network.Matrix.Client | |
FromJSON Filter Source # | |
type Rep Filter Source # | |
Defined in Network.Matrix.Client type Rep Filter = D1 ('MetaData "Filter" "Network.Matrix.Client" "matrix-client-0.1.2.0-IBEy2HWO5KfIiyHvD7KcGH" 'False) (C1 ('MetaCons "Filter" 'PrefixI 'True) ((S1 ('MetaSel ('Just "filterEventFields") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe [Text])) :*: S1 ('MetaSel ('Just "filterEventFormat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe EventFormat))) :*: (S1 ('MetaSel ('Just "filterPresence") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe EventFilter)) :*: (S1 ('MetaSel ('Just "filterAccountData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe EventFilter)) :*: S1 ('MetaSel ('Just "filterRoom") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe RoomFilter)))))) |
messageFilter :: Filter Source #
A filter to keep all the messages
:: ClientSession | The client session, use |
-> UserID | The userID, use |
-> Filter | The filter definition, use |
-> MatrixIO FilterID | The function returns a |
Upload a new filter definition to the homeserver https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-user-userid-filter
Events
sync :: ClientSession -> Maybe FilterID -> Maybe Text -> Maybe Presence -> Maybe Int -> MatrixIO SyncResult Source #
getTimelines :: SyncResult -> [(RoomID, NonEmpty RoomEvent)] Source #
Extract room events from a sync result
:: MonadIO m | |
=> ClientSession | The client session, use |
-> Maybe FilterID | A sync filter, use |
-> Maybe Text | A since value, get it from a previous sync result using the |
-> Maybe Presence | Set the session presence. |
-> (SyncResult -> m ()) | Your callback to handle sync result. |
-> MatrixM m () | This function does not return unless there is an error. |
Instances
Eq RoomEvent Source # | |
Show RoomEvent Source # | |
Generic RoomEvent Source # | |
ToJSON RoomEvent Source # | |
Defined in Network.Matrix.Client | |
FromJSON RoomEvent Source # | |
type Rep RoomEvent Source # | |
Defined in Network.Matrix.Client type Rep RoomEvent = D1 ('MetaData "RoomEvent" "Network.Matrix.Client" "matrix-client-0.1.2.0-IBEy2HWO5KfIiyHvD7KcGH" 'False) (C1 ('MetaCons "RoomEvent" 'PrefixI 'True) ((S1 ('MetaSel ('Just "reContent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Event) :*: S1 ('MetaSel ('Just "reType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "reEventId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EventID) :*: S1 ('MetaSel ('Just "reSender") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Author)))) |
data RoomSummary Source #
Instances
data TimelineSync Source #
Instances
data InvitedRoomSync Source #
Instances
Eq InvitedRoomSync Source # | |
Defined in Network.Matrix.Client (==) :: InvitedRoomSync -> InvitedRoomSync -> Bool # (/=) :: InvitedRoomSync -> InvitedRoomSync -> Bool # | |
Show InvitedRoomSync Source # | |
Defined in Network.Matrix.Client showsPrec :: Int -> InvitedRoomSync -> ShowS # show :: InvitedRoomSync -> String # showList :: [InvitedRoomSync] -> ShowS # | |
Generic InvitedRoomSync Source # | |
Defined in Network.Matrix.Client type Rep InvitedRoomSync :: Type -> Type # from :: InvitedRoomSync -> Rep InvitedRoomSync x # to :: Rep InvitedRoomSync x -> InvitedRoomSync # | |
ToJSON InvitedRoomSync Source # | |
Defined in Network.Matrix.Client toJSON :: InvitedRoomSync -> Value # toEncoding :: InvitedRoomSync -> Encoding # toJSONList :: [InvitedRoomSync] -> Value # toEncodingList :: [InvitedRoomSync] -> Encoding # | |
FromJSON InvitedRoomSync Source # | |
Defined in Network.Matrix.Client parseJSON :: Value -> Parser InvitedRoomSync # parseJSONList :: Value -> Parser [InvitedRoomSync] # | |
type Rep InvitedRoomSync Source # | |
data JoinedRoomSync Source #
Instances
data SyncResult Source #
Instances
data SyncResultRoom Source #
SyncResultRoom | |
|