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.
Links¶
A quick snippet of code¶
module MyScript where
import Marvin.Prelude
script :: (IsAdapter a, SupportsFiles 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 [chan]
case res of
Left err -> send $(isL "Failed to share file: #{err}")
Right _ -> send "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.
Contents:¶
- Getting started
- Writing marvin scripts
- The abstract data model of marvin
- Runtime configuration
- Files
- External scripts
- Logging in marvin
- The marvin preprocessor (marvin-pp)
- Adapters
- Strings and String conversions (in Haskell)
- Lens quickstart
- marvin-interpolate, A simple string interpolation library
- API breaking changes
- FAQ