Copyright | (c) 2016 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | experimental |
Portability | CPP, OverloadedStrings, RankNTypes, ScopedTypeVariables |
Safe Haskell | None |
Language | Haskell2010 |
Most of the hairy code. This isn't all internal, due to messy dependencies, but I've tried to make this as "internal" as reasonably possible.
This module is NOT considered to form part of the public interface of this library.
- connectInternal :: MonadIO m => (IO () -> Consumer (Either ByteString IrcEvent) IO () -> Producer IO IrcMessage -> IO ()) -> StatefulIRC s () -> StatefulIRC s () -> (Origin -> ByteString -> IO ()) -> ByteString -> Int -> NominalDiffTime -> m (ConnectionConfig s)
- runner :: StatefulIRC s ()
- forgetful :: Monad m => Conduit (Either a b) m b
- eventSink :: MonadIO m => IRCState s -> Consumer IrcEvent m ()
- isIgnored :: MonadIO m => IRCState s -> UnicodeEvent -> m Bool
- getHandlersFor :: Event a -> [EventHandler s] -> [UnicodeEvent -> StatefulIRC s ()]
- logConduit :: MonadIO m => (a -> IO ()) -> Conduit a m a
- stdoutLogger :: Origin -> ByteString -> IO ()
- fileLogger :: FilePath -> Origin -> ByteString -> IO ()
- noopLogger :: a -> b -> IO ()
- send :: UnicodeMessage -> StatefulIRC s ()
- sendBS :: IrcMessage -> StatefulIRC s ()
- disconnect :: StatefulIRC s ()
- disconnectNow :: StatefulIRC s ()
- timeout :: MonadIO m => NominalDiffTime -> IO Bool -> m ()
Connecting to an IRC network
:: MonadIO m | |
=> (IO () -> Consumer (Either ByteString IrcEvent) IO () -> Producer IO IrcMessage -> IO ()) | Function to start the network conduits. |
-> StatefulIRC s () | Connect handler |
-> StatefulIRC s () | Disconnect handler |
-> (Origin -> ByteString -> IO ()) | Logging function |
-> ByteString | Server hostname |
-> Int | Server port |
-> NominalDiffTime | Flood timeout |
-> m (ConnectionConfig s) |
Connect to a server using the supplied connection function.
Event loop
runner :: StatefulIRC s () Source #
The event loop.
eventSink :: MonadIO m => IRCState s -> Consumer IrcEvent m () Source #
Block on receiving a message and invoke all matching handlers concurrently.
isIgnored :: MonadIO m => IRCState s -> UnicodeEvent -> m Bool Source #
Check if an event is ignored or not.
getHandlersFor :: Event a -> [EventHandler s] -> [UnicodeEvent -> StatefulIRC s ()] Source #
Get the event handlers for an event.
logConduit :: MonadIO m => (a -> IO ()) -> Conduit a m a Source #
A conduit which logs everything which goes through it.
stdoutLogger :: Origin -> ByteString -> IO () Source #
Print messages to stdout, with the current time.
fileLogger :: FilePath -> Origin -> ByteString -> IO () Source #
Append messages to a file, with the current time.
noopLogger :: a -> b -> IO () Source #
Do no logging.
Messaging
send :: UnicodeMessage -> StatefulIRC s () Source #
Send a message as UTF-8, using TLS if enabled. This blocks if messages are sent too rapidly.
sendBS :: IrcMessage -> StatefulIRC s () Source #
Send a message, using TLS if enabled. This blocks if messages are sent too rapidly.
Disconnecting
disconnect :: StatefulIRC s () Source #
Disconnect from the server, properly tearing down the TLS session (if there is one).
disconnectNow :: StatefulIRC s () Source #
Disconnect immediately, without waiting for messages to be sent.