Copyright | (c) Justus Adam 2016 |
---|---|
License | BSD3 |
Maintainer | dev@justus.science |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- type RunWithAdapter a = EventHandler a -> AdapterM a ()
- type EventHandler a = Event a -> IO ()
- class IsAdapter a where
- data AdapterId a
- mkAdapterId :: Text -> Either String (AdapterId a)
- unwrapAdapterId :: AdapterId a -> Text
- data AdapterM a r
- data Event a
- = MessageEvent (User a) (Channel a) Message TimeStamp
- | CommandEvent (User a) (Channel a) Message TimeStamp
- | ChannelJoinEvent (User a) (Channel a) TimeStamp
- | ChannelLeaveEvent (User a) (Channel a) TimeStamp
- | TopicChangeEvent (User a) (Channel a) Topic TimeStamp
- lookupFromAdapterConfig :: (IsAdapter a, Configured v) => Name -> AdapterM a (Maybe v)
- requireFromAdapterConfig :: (IsAdapter a, Configured v) => Name -> AdapterM a v
- lookupFromAppConfig :: Configured v => Name -> AdapterM a (Maybe v)
- requireFromAppConfig :: Configured v => Name -> AdapterM a v
- getBotname :: AdapterM a Text
- getAdapterConfig :: forall a. IsAdapter a => AdapterM a Config
- getAppConfig :: AdapterM a Config
- getAdapter :: AccessAdapter m => m (AdapterT m)
- liftAdapterAction :: (MonadIO m, HasConfigAccess m, AccessAdapter m, IsAdapter a, a ~ AdapterT m) => AdapterM a r -> m r
Documentation
type RunWithAdapter a = EventHandler a -> AdapterM a () Source #
type EventHandler a = Event a -> IO () Source #
class IsAdapter a where Source #
Basic functionality required of any adapter
adapterId, messageChannel, initAdapter, runWithAdapter, getUsername, getChannelName, resolveChannel, resolveUser
Concrete, adapter specific representation of a user. Could be an id string or a full object for instance
Concrete, adapter specific representation of a channel. Could be an id string or a full object for instance
adapterId :: AdapterId a Source #
Used for scoping config and logging
messageChannel :: Channel a -> Text -> AdapterM a () Source #
Post a message to a channel given the internal channel identifier
initAdapter :: RunnerM a Source #
Initialize the adapter state
runWithAdapter :: RunWithAdapter a Source #
Run the bot
getUsername :: User a -> AdapterM a Text Source #
Resolve a username given the internal user identifier
getChannelName :: Channel a -> AdapterM a Text Source #
Resolve the human readable name for a channel given the internal channel identifier
resolveChannel :: Text -> AdapterM a (Maybe (Channel a)) Source #
Resolve to the internal channel structure given a human readable name
resolveUser :: Text -> AdapterM a (Maybe (User a)) Source #
Resolve to the internal user structure given a human readable name
A type, basically a String, which identifies an adapter to the config and the logging facilities.
For conversion please use mkAdapterId
and unwrapAdapterId
. They will perform necessary checks.
mkAdapterId :: Text -> Either String (AdapterId a) Source #
Attempt to create an adapter id from Text
unwrapAdapterId :: AdapterId a -> Text Source #
Monad in which adapter actions run in
MonadBaseControl IO (AdapterM a) Source # | |
MonadBase IO (AdapterM a) Source # | |
Monad (AdapterM a) Source # | |
Functor (AdapterM a) Source # | |
Applicative (AdapterM a) Source # | |
MonadIO (AdapterM a) Source # | |
MonadLogger (AdapterM a) Source # | |
MonadLoggerIO (AdapterM a) Source # | |
AccessAdapter (AdapterM a) Source # | |
type AdapterT (AdapterM a) Source # | |
type StM (AdapterM a) r Source # | |
Representation for the types of events which can occur
MessageEvent (User a) (Channel a) Message TimeStamp | |
CommandEvent (User a) (Channel a) Message TimeStamp | |
ChannelJoinEvent (User a) (Channel a) TimeStamp | |
ChannelLeaveEvent (User a) (Channel a) TimeStamp | |
TopicChangeEvent (User a) (Channel a) Topic TimeStamp |
lookupFromAdapterConfig :: (IsAdapter a, Configured v) => Name -> AdapterM a (Maybe v) Source #
requireFromAdapterConfig :: (IsAdapter a, Configured v) => Name -> AdapterM a v Source #
lookupFromAppConfig :: Configured v => Name -> AdapterM a (Maybe v) Source #
requireFromAppConfig :: Configured v => Name -> AdapterM a v Source #
getBotname :: AdapterM a Text Source #
getAppConfig :: AdapterM a Config Source #
getAdapter :: AccessAdapter m => m (AdapterT m) Source #
liftAdapterAction :: (MonadIO m, HasConfigAccess m, AccessAdapter m, IsAdapter a, a ~ AdapterT m) => AdapterM a r -> m r Source #