| Copyright | Alexander Krupenkin 2016 |
|---|---|
| License | BSD3 |
| Maintainer | mail@akru.me |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
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?"
- type Story a = (User, Chat) -> StoryT (Bot a) BotMessage
- type StoryT = Pipe Message BotMessage
- data BotMessage
- class ToBotMessage a where
- class Answer a where
- select :: (MonadIO m, Answer a) => Text -> [[Text]] -> StoryT m a
- question :: (MonadIO m, Answer a) => Text -> StoryT m a
- replica :: (ToBotMessage a, MonadIO m, Answer b) => a -> StoryT m b
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.
data BotMessage Source #
Bot message data.
Instances
| Show BotMessage Source # | |
| ToBotMessage BotMessage Source # | Idenity instance |
class ToBotMessage a where Source #
Bot message typeclass for conversion.
Minimal complete definition
Methods
toMessage :: a -> BotMessage Source #
Instances
| ToBotMessage Text Source # | Simple text question send text message from bot |
| ToBotMessage BotMessage Source # | Idenity instance |
The value can be passed to story handler function.
Minimal complete definition