@hackage habit0.2.2.0
Haskell message bot framework
Categories
License
BSD-3-Clause
Maintainer
mail@akru.me
Links
Versions
Installation
Dependencies (18)
- base >=4.9 && <4.10
- containers >=0.5.7.1 && <0.6
- cryptonite >=0.21 && <0.22
- http-client >=0.4.31.2 && <0.5
- http-client-tls >=0.2.4.1 && <0.3
- monad-control >=1.0.1.0 && <1.1 Show all…
Dependents (0)
Haskell Bot it :: Message bot framework
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.