habit-0.2.2.0: Haskell message bot framework

CopyrightAlexander Krupenkin 2016
LicenseBSD3
Maintainermail@akru.me
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Web.Bot.Story

Description

Story is a dialog like abstraction for processing sparsed by messages data from user.

     hello :: Monad m => Text -> Text -> Int -> m BotMessage
     hello name surname age = toMessage $
         "Hello, " <> name <> " " <> surname <> "!n"
      <> "You lost " <> (T.pack $ show age) <> " years =)"

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

Synopsis

Documentation

type Story a = User -> StoryT (Bot a) Message Source #

Story is a pipe from user message to bot message and result is a final bot message.

type StoryT = Pipe Message Message Source #

Story transformer is based on Pipe with fixed Message in/out.

class Answer a where Source #

User message reply parser.

Minimal complete definition

parse

Methods

parse :: MonadIO m => Message -> ExceptT Text m a Source #

select :: (MonadIO m, Answer a) => Text -> [[Text]] -> StoryT m a Source #

Reply keyboard selection

question :: (MonadIO m, Answer a) => Text -> StoryT m a Source #

Bot text question.

replica :: (ToMessage a, MonadIO m, Answer b) => a -> StoryT m b Source #

Generalized story maker. The replica send message to user, when answer isn't parsed the error be sended and wait for correct answer.