telegram-bot-0.5.4.0: Telegram Bot microframework for Haskell

CopyrightAlexander Krupenkin 2016
LicenseBSD3
Maintaineremail@something.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Web.Telegram.Bot

Contents

Description

Telegram Bot API microframework for creating story like command handlers:

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

Synopsis

Exported types

API types

Story types

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 BotConfig a where Source #

Telegram bot config

Minimal complete definition

authToken

Methods

pollTimeout :: a -> Timeout Source #

authToken :: a -> Token Source #

BotFather authentification token

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

newtype Token :: * #

Telegram Bot's Token

Constructors

Token Text 

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.

Story makers

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

Reply keyboard selection

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.

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

Bot text question.

Bot runners

storyBot :: (BotConfig a, ToBotMessage help) => help -> Map Text (Story a) -> Bot a () Source #

User story handler

runBot :: BotConfig a => a -> Bot a b -> IO b Source #

Run bot monad

Re-exports

lift :: MonadTrans t => forall m a. Monad m => m a -> t m a #

Lift a computation from the argument monad to the constructed monad.