summaryrefslogtreecommitdiff
path: root/Hsbot/IRCParser.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-05-16 00:01:00 +0200
committerJulien Dessaux2010-05-16 00:01:00 +0200
commitc1662ba7b982a8502dc9f32031b7cb518df7f60e (patch)
treef00dbd9cb39bf0fbc20949105ea2b93d9e868070 /Hsbot/IRCParser.hs
parentAdded the quote module. (diff)
downloadhsbot-c1662ba7b982a8502dc9f32031b7cb518df7f60e.tar.gz
hsbot-c1662ba7b982a8502dc9f32031b7cb518df7f60e.tar.bz2
hsbot-c1662ba7b982a8502dc9f32031b7cb518df7f60e.zip
Rewrote nearly everything!v0.2.0
* Rewrote the whole architecture to achieve extreme modularity * Added the ability to build a multiprotocol bot * Added cabal integration * Added configuration handling the XMonad style * Added configuration in ~/.hsbot * Refactored many many named and functions * Refactored data structures * Cleaned a big bunch of stuff
Diffstat (limited to 'Hsbot/IRCParser.hs')
-rw-r--r--Hsbot/IRCParser.hs51
1 files changed, 0 insertions, 51 deletions
diff --git a/Hsbot/IRCParser.hs b/Hsbot/IRCParser.hs
deleted file mode 100644
index d284377..0000000
--- a/Hsbot/IRCParser.hs
+++ /dev/null
@@ -1,51 +0,0 @@
-module Hsbot.IRCParser
- ( ParseError
- , parseIrcMsg
- , serializeIrcMsg
- ) where
-
-import Control.Monad.Identity
-import Text.Parsec
-
-import Hsbot.Types
-
--- | Parses an IrcInput
-parseIrcMsg :: String -> Either ParseError IrcMsg
-parseIrcMsg line = parse pMsg "" line
-
-pMsg :: ParsecT String u Identity IrcMsg
-pMsg = do
- pfx <- optionMaybe pPrefix
- cmd <- pCommand
- params <- many (char ' ' >> (pLongParam <|> pShortParam))
- _ <- char '\r'
- --eof
- return $ IrcMsg pfx cmd params
-
-pPrefix :: ParsecT String u Identity [Char]
-pPrefix = do
- _ <- char ':'
- pfx <- many1 (noneOf " ")
- _ <- space
- return pfx
-
-pCommand :: ParsecT String u Identity [Char]
-pCommand = count 3 digit <|> many1 upper
-
-pLongParam :: ParsecT String u Identity [Char]
-pLongParam = char ':' >> (many1 (noneOf "\r"))
-
-pShortParam :: ParsecT String u Identity [Char]
-pShortParam = many1 (noneOf " \r")
-
--- |Serialize an IRC message to a string.
-serializeIrcMsg :: IrcMsg -> String
-serializeIrcMsg (IrcMsg pfx cmd params) = pfxStr ++ cmd ++ paramStr
- where pfxStr = case pfx of
- Nothing -> ""
- Just pfx' -> ":" ++ pfx' ++ " "
- paramStr = concat (map paramToStr (init params)
- ++ [lastParamToStr (last params)])
- paramToStr p = " " ++ p
- lastParamToStr p = " :" ++ p
-