Giter Site home page Giter Site logo

m4lvin / hzulip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nh2/hzulip

0.0 1.0 0.0 190 KB

A haskell wrapper for the Zulip API.

Home Page: https://yamadapc.github.io/hzulip

License: GNU General Public License v2.0

Shell 2.53% Haskell 95.87% Dockerfile 1.61%

hzulip's Introduction

hzulip

Build Status Hackage Dependencies Status Gitter chat


A haskell wrapper for the zulip API.

Installing

Simply installing through cabal with cabal install hzulip should do it.

Usage

Getting started

import Web.HZulip

main :: IO ()
main = withZulipCreds "zulip-api-user" "zulip-api-key" $ do
    -- Since we are inside the ZulipM ReaderT monad transformer, we
    -- don't need to pass options around. The above function already
    -- created an HTTP manager, for connection pooling and wrapped the
    -- default configuration options with the Monad:
    print =<< getSubscriptions
    -- >> ["haskell"]

    -- Sending messages is as easy as:
    void $ sendStreamMessage "haskell"              -- message stream
                             "hzulip"               -- message topic
                             "Message from Haskell" -- message content

    -- Before receiving messages, our client needs to be subscribed to streams
    addAllSubscriptions

    -- Listening for events works with a callback based API:
    onNewMessage $ \msg -> do
        lift $ putStrLn "Got a new message!"
        let usr = messageSender msg
            fn = userFullName usr
            e = userEmail usr

       sendPrivateMessage [e] $ "Thanks for the message " ++ fn ++ "!!"

Documentation

The best resource on this is naturally its haddock documentation, available at yamadapc.github.io/hzulip. You might also be interested in the zulip API documentation as well.

Examples

There are a couple of example bots and applications on the examples directory. If you're getting started with Haskell, I'd suggest looking at the ZulipLogger and ZulipEchoBot which show of basic API usage with minimal noise from anything else.

A higher-level API

A Conduit API is provided as well and an "echo" example is available for it in the examples directory; here. You can compare the evented implementation and see which you like best. Right now using streams to handle output is a bit unhandy, but it provides a nice composable high-level interface for the events.


Other than the echo and logger examples; there's also a pretty logger at ZulipCli.

A remote evaluation bot

Though slightly outdated, there's a remote evaluation Zulip bot using this library at zulip-eval-bot, which might be worth taking a look at as well.

License

This code is licensed under the GPLv2 license for Pedro Tacla Yamada. Plese refer to LICENSE for more information.

Donations

Would you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y

hzulip's People

Contributors

yamadapc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.