Popularity
5.7
Stable
Activity
0.0
Stable
11
2
2

Monthly Downloads: 2
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Web    
Latest version: v0.2.2.0

habit alternatives and similar packages

Based on the "Web" category.
Alternatively, view habit alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of habit or a related project?

Add another 'Web' Package

README

Haskell Bot it :: Message bot framework

Build Status Build status Hackage Hackage Dependencies Haskell Programming Language BSD3 License

Install

$ git clone https://github.com/airalab/habit && cd habit
$ stack setup
$ stack ghci

Run your story

The Story is an abstraction about sparsed data getted from user though dialogue.

helloStory :: Story a
helloStory _ = hello <$> question "How your name?"
                     <*> question "How your surname?"
                     <*> question "How old are you?"

As you see the story handler hello is apply though the questions to user responses.

type Name    = Text
type Surname = Text
type Age     = Int

hello :: Monad m => Name -> Surname -> Age -> m BotMessage
hello name surname age = do
    return . toMessage $ "Hello, " <> name <> " " <> surname <> "!\n"
                      <> "You lost " <> (pack $ show age) <> " years =)"

To run the Story simple pass it to storyBot as value of mapping between command an story. APIToken type class defines token for given platform, e.g. Telegram platform.

instance APIToken Telegram where
    apiToken = "bot..."

main :: IO ()
main = runBot myBot
  where myBot :: Bot Telegram ()
        myBot = storyBot helpMsg [("/hello", helloStory)]

Full example [text](examples/Hello.hs).


*Note that all licence references and agreements mentioned in the habit README section above are relevant to that project's source code only.