Last active
October 29, 2019 19:52
-
-
Save AngusP/b45bd2c5143e8fa230a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rfcToEntry :: String -> String -> Maybe Entry | |
rfcToEntry t str | |
| " PRIVMSG" `isPrefixOf` (dropWhile (/=' ') str) && ":ACTION" `isPrefixOf` (dropWhile (/=':') $ dropWhile (/=' ') str) | |
= Just ( t , takeWhile (/='!') $ drop 1 str , | |
(takeWhile (/='!') $ drop 1 str) ++ (dropWhile (/=' ') $ dropWhile (/=':') $ tail $ dropWhile (/=' ') $ tail str) ) | |
| " PRIVMSG" `isPrefixOf` (dropWhile (/=' ') str) = Just ( t , takeWhile (/='!') $ drop 1 str , | |
tail $ dropWhile (/=':') $ dropWhile (/=' ') $ tail str ) | |
| " PART" `isPrefixOf` (dropWhile (/=' ') str) = Just ( t , takeWhile (/='!') $ drop 1 str , "$left" ) | |
| " QUIT" `isPrefixOf` (dropWhile (/=' ') str) = Just ( t , takeWhile (/='!') $ drop 1 str , "$left" ) | |
| " JOIN" `isPrefixOf` (dropWhile (/=' ') str) = Just ( t , takeWhile (/='!') $ drop 1 str , "$joined" ) | |
| " KICK" `isPrefixOf` (dropWhile (/=' ') str) = Just ( t , "$kick" , | |
(takeWhile (/='!') $ drop 1 str) ++ " kicked " ++ (last (splitByDelim " " $ takeWhile (/=':') $ dropWhile (/=' ') $ tail str)) ) | |
| " NICK" `isPrefixOf` (dropWhile (/=' ') str) = Just ( t , takeWhile (/='!') $ drop 1 str , | |
head $ words $ tail $ dropWhile (/=':') $ tail str ) | |
| otherwise = Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment