Welcome to marvin’s documentation!

Marvin is a Haskell framework for creating chat bots, inspired by Hubot. Marvin aims to recreate the ease of use and straightforward API of Hubot, and combine it with the safety guarantees and purity of Haskell and the higher efficiency.

If you are new to marvin you may want to begin with the Getting started section or the how to script with marvin section to get a sense of how scripting works with marvin.

A quick snippet of code

module MyScript where

import Marvin.Prelude

script :: IsAdapter a => ScriptInit a
script = defineScript "my-script" $ do
    hear "sudo (.+)" $ do
        match <- getMatch

        reply $(isL "All right, i'll do #{match !! 1}")

    respond "repeat" $ do
        message <- getMessage

        send $(isL "You wrote #{message}")

    respond "what is in file ([\\w\\._/-]+)\\??" $ do
        match <- getMatch
        let file = match !! 1

        contents <- liftIO $ readFile file

        send contents

    respond "upload file ([\\w\\._/-]+)" $ do
        [_, filepath] <- getMatch
        chan <- getChannel
        f <- sendFile filepath
        case res of
            Left err -> reporter $(isL "Failed to share file: #{err}")
            Right _  -> reporter "File successfully uploaded"

    enterIn "random" $ do
        user <- getUser
        send $(isL "Hello #{user^.username} welcome to the random channel!")

    fileSharedIn "announcements" $ do
        file <- getFile
        safeFileToDir file "shared-files"

Testing and Talking

There’s a slack channel where you can ask questions or play around with a test instance of marvin.

It’s currently invite-only, so send me an email if you would like to join.

Indices and tables