Adds documentation for core.
This commit is contained in:
parent
ecb405a5bc
commit
1d34e15f7f
@ -42,7 +42,7 @@ data MessageParser = MessageParser
|
||||
|
||||
-- ** Command Formatting
|
||||
|
||||
-- | A command formatter which optinally formats commands to texts which are then sent to the server.
|
||||
-- | A command formatter which optionally formats commands to texts which are then sent to the server.
|
||||
type CommandFormatter = BotConfig -> Message -> Maybe Text
|
||||
|
||||
-- ** Bot
|
||||
@ -118,7 +118,7 @@ data BotStatus = Connected -- ^ Connected to the server
|
||||
| Idle -- ^ No communication with the server. The bot is idle.
|
||||
-- If the bot stays idle for 'botTimeout' seconds, it disconnects.
|
||||
| Interrupted -- ^ Interrupted using external signals like SIGINT.
|
||||
| NickNotAvailable -- ^ Bot's current nick already taken on the server.
|
||||
| NickNotAvailable -- ^ Bot's current nick is already taken on the server.
|
||||
| NickAvailable -- ^ Bot's original nick is available on the server.
|
||||
deriving (Show, Eq, Ord)
|
||||
|
||||
|
@ -35,8 +35,8 @@ data User
|
||||
-- | An message sent from the server to the bot or from the bot to the server
|
||||
-- or from a handler to another handler.
|
||||
data Message = Message
|
||||
{ msgTime :: !UTCTime -- ^ The time when the message was received/sent.
|
||||
, msgLine :: !Text -- ^ The raw message.
|
||||
{ msgTime :: !UTCTime -- ^ The time when the message was received/sent.
|
||||
, msgLine :: !Text -- ^ The raw message.
|
||||
, message :: !MessageW -- ^ The details of the parsed message.
|
||||
} deriving (Show, Eq)
|
||||
|
||||
@ -59,7 +59,7 @@ instance Eq MessageW where
|
||||
Just m1' -> m1' == m2
|
||||
_ -> False
|
||||
|
||||
-- | Creates a new message with current time and empty raw message.
|
||||
-- | Creates a new message with the current time and the given message details.
|
||||
newMessage :: (MessageC msg, MonadIO m)
|
||||
=> msg -- ^ Message details
|
||||
-> m Message
|
||||
@ -128,6 +128,7 @@ data ModeMsg = ModeMsg { modeUser :: !User
|
||||
} deriving (Typeable, Show, Eq, Ord)
|
||||
instance MessageC ModeMsg
|
||||
|
||||
-- | A message received as a response to a 'WhoisCmd'.
|
||||
data WhoisReplyMsg = WhoisNoSuchNick { whoisNick :: !Nick }
|
||||
| WhoisReplyMsg {
|
||||
whoisNick :: !Nick
|
||||
@ -140,7 +141,7 @@ data WhoisReplyMsg = WhoisNoSuchNick { whoisNick :: !Nick }
|
||||
} deriving (Typeable, Show, Eq, Ord)
|
||||
instance MessageC WhoisReplyMsg
|
||||
|
||||
-- | All other messages which are not parsed as any of the above types.
|
||||
-- | All other messages which are not parsed as any of the above message types.
|
||||
data OtherMsg = OtherMsg { msgSource :: !Text
|
||||
, msgCommand :: !Text
|
||||
, msgTarget :: !Text
|
||||
@ -185,5 +186,6 @@ instance MessageC QuitCmd
|
||||
data NamesCmd = NamesCmd deriving (Typeable, Show, Eq, Ord)
|
||||
instance MessageC NamesCmd
|
||||
|
||||
data WhoisCmd = WhoisCmd !Text deriving (Typeable, Show, Eq, Ord)
|
||||
-- | A /WHOIS/ command sent to ask for the status of a user nick.
|
||||
data WhoisCmd = WhoisCmd !Text deriving (Typeable, Show, Eq, Ord)
|
||||
instance MessageC WhoisCmd
|
||||
|
@ -51,7 +51,7 @@ sendMessageSTM (MessageChannel _ _ wChan) = writeTChan wChan
|
||||
receiveMessageSTM :: MessageChannel a -> STM a
|
||||
receiveMessageSTM (MessageChannel _ rChan _) = readTChan rChan
|
||||
|
||||
-- | Sends a message through a message channel
|
||||
-- | Sends a message through a message channel.
|
||||
sendMessage :: MessageChannel a -- ^ The channel
|
||||
-> a -- ^ The message to send
|
||||
-> IO ()
|
||||
|
@ -123,7 +123,7 @@ whoisParser = MessageParser "whois" go
|
||||
$ partMap
|
||||
splits312 = words . fromJust . lookup "312" $ partMap
|
||||
server = splits312 !! 4
|
||||
serverInfo = drop 1 $ splits312 !! 5
|
||||
serverInfo = drop 1 . unwords . drop 5 $ splits312
|
||||
in WhoisReplyMsg nick user host realName channels server serverInfo
|
||||
|
||||
defaultParsers :: [MessageParser]
|
||||
|
Loading…
Reference in New Issue
Block a user