hzulip-0.4.1.0: A haskell wrapper for the Zulip API.

Safe HaskellNone
LanguageHaskell2010

HZulip

Synopsis

Documentation

data Event Source

Represents zulip events

Constructors

Event 

data Queue Source

Represents some event queue

Constructors

Queue 

Fields

queueId :: String
 
lastEventId :: Int
 

Instances

data User Source

Represents a zulip user account - for both display_recipient and message_sender representations

data ZulipClient Source

Represents a Zulip API client

type EventCallback = Event -> IO () Source

The root type for Event callbacks

type MessageCallback = Message -> IO () Source

Type for message callbacks

defaultBaseUrl :: String Source

The default zulip API URL

eventTypes :: [String] Source

The list of all avaiable event types

getEvents :: ZulipClient -> Queue -> Bool -> IO (Queue, [Event]) Source

Fetches new set of events from a Queue.

getSubscriptions :: ZulipClient -> IO [String] Source

Get a list of the streams the client is currently subscribed to.

newZulip :: String -> String -> ZulipClient Source

Helper for creating a ZulipClient with the baseUrl set to defaultBaseUrl

onNewEvent :: ZulipClient -> [String] -> EventCallback -> IO () Source

Registers an event callback for specified events and keeps executing it over events as they come in. Will loop forever

onNewMessage :: ZulipClient -> MessageCallback -> IO () Source

Registers a callback to be executed whenever a message comes in. Will loop forever

registerQueue :: ZulipClient -> [String] -> Bool -> IO Queue Source

This registers a new event queue with the zulip API. It's a lower level function, which shouldn't be used unless you know what you're doing. It takes a ZulipClient, a list of names of the events you want to listen for and whether you'd like for the content to be rendered in HTML format (if you set the last parameter to False it will be kept as typed, in markdown format)

sendMessage :: ZulipClient -> String -> [String] -> String -> String -> IO Int Source

This wraps `POST https://api.zulip.com/v1/messages` with a nicer root API. Simpler helpers for each specific case of this somewhat overloaded endpoint will also be provided in the future.

It takes the message mtype, mrecipients, msubject and mcontent and returns the created message's id in the IO monad.

sendPrivateMessage :: ZulipClient -> [String] -> String -> IO Int Source

Helper for sending private messages. Takes the list of recipients and the message's content.

sendStreamMessage :: ZulipClient -> String -> String -> String -> IO Int Source

Helper for sending stream messages. Takes the stream name, the subject and the message.