telegram-bot-0.5.4.0: Telegram Bot microframework for Haskell

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

Web.Telegram.Bot.Story

Description

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

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

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

Synopsis

Documentation

type Story a = (User, Chat) -> StoryT (Bot a) BotMessage Source #

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

class ToBotMessage a where Source #

Bot message typeclass for conversion.

Minimal complete definition

toMessage

Methods

toMessage :: a -> BotMessage Source #

Instances

ToBotMessage Text Source #

Simple text question send text message from bot

ToBotMessage BotMessage Source #

Idenity instance

class Answer a where Source #

The value can be passed to story handler function.

Minimal complete definition

parse

Methods

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

Instances

Answer Double Source # 
Answer Int Source # 

Methods

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

Answer Integer Source # 
Answer Word Source # 
Answer Text Source #

Simple text answer, pass any text message

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 :: (ToBotMessage a, MonadIO m, Answer b) => a -> StoryT m b Source #

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