Copyright | Alexander Krupenkin 2016 |
---|---|
License | BSD3 |
Maintainer | email@something.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- class ToMessage a where
- class Answer a where
- data Message
- type StoryT = Pipe Message Message
- type Story a = User -> StoryT (Bot a) Message
- data User
- question :: (MonadIO m, Answer a) => Text -> StoryT m a
- replica :: (ToMessage a, MonadIO m, Answer b) => a -> StoryT m b
- select :: (MonadIO m, Answer a) => Text -> [[Text]] -> StoryT m a
- data Bot a b
- class Platform a where
- class Platform a => APIToken a where
- data Telegram
- class Platform a => Persist a where
- data Connection
- data ConnectInfo :: * = ConnectInfo {}
- storyBot :: (Persist a, APIToken a, ToMessage help) => help -> Map Message (Story a) -> Bot a ()
- forkBot :: APIToken a => Bot a () -> Bot a ThreadId
- runBot :: (APIToken a, MonadIO m) => Bot a b -> m b
- yield :: Monad m => a -> Producer' a m ()
- await :: Monad m => Consumer' a m a
- lift :: MonadTrans t => forall m a. Monad m => m a -> t m a
Story & message types
User message reply parser.
Generalized message type
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.
Show User Source # | |
PersistFieldSql User Source # | |
PersistEntity User Source # | |
PersistField User Source # | |
ToBackendKey SqlBackend User Source # | |
Eq (Key User) Source # | |
Ord (Key User) Source # | |
Read (Key User) Source # | |
Show (Key User) Source # | |
ToJSON (Key User) Source # | |
FromJSON (Key User) Source # | |
ToHttpApiData (Key User) Source # | |
FromHttpApiData (Key User) Source # | |
PathPiece (Key User) Source # | |
PersistFieldSql (Key User) Source # | |
PersistField (Key User) Source # | |
data Unique User Source # | |
data EntityField User Source # | |
data Key User Source # | |
type PersistEntityBackend User Source # | |
Story makers
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.
Bot monad & configuration classes
Message bot monad
class Platform a where Source #
Message bot platform. Different platforms provide message bot API, e.g. Telegram, Viber, Facebook Messenger etc. This is generalized interface to it.
trySelf :: APIToken a => Bot a () Source #
Try connection to platform API
sendMessage :: (ToMessage msg, APIToken a) => User -> msg -> Bot a () Source #
Send message to user by platform API
messageHandler :: APIToken a => (User -> Message -> Bot a b) -> Bot a c Source #
Get user updates by platform API
platformName :: a -> Text Source #
Short description of platform
class Platform a => APIToken a where Source #
Bot authentification in platform Instance of it should be writen by user
Bot platforms
Bot storage
class Platform a => Persist a where Source #
Connection info provider
persist :: Bot a Connection Source #
data Connection Source #
Database connection information
data ConnectInfo :: * #
ConnectInfo | |
|
Bot runners
storyBot :: (Persist a, APIToken a, ToMessage help) => help -> Map Message (Story a) -> Bot a () Source #
User story handler
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.