summaryrefslogtreecommitdiff
path: root/src/ZNC.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ZNC.hs')
-rw-r--r--src/ZNC.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ZNC.hs b/src/ZNC.hs
index 4618025..7cfeb72 100644
--- a/src/ZNC.hs
+++ b/src/ZNC.hs
@@ -16,6 +16,7 @@ import Data.Char (ord)
import Data.Either (fromRight)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
+import Data.Text qualified as T
import Data.Text.Encoding qualified as TE
import Data.Vector.Storable qualified as VS
import Data.Word (Word8, Word32)
@@ -116,7 +117,7 @@ parseEvent = asum
, Topic <$> (nick <* P.string " changes topic to ") <*> encloseTail '\'' '\''
]
, Talk <$ P.char '<' <*> nick <* P.string "> " <*> remaining
- , Notice <$ P.char '-' <*> nick <*> remaining -- FIXME: parse host
+ , Notice <$ P.char '-' <*> (stripFinalDash =<< nick) <*> (P.char ' ' *> remaining)
, Act <$ P.string "* " <*> nick <* P.char ' ' <*> remaining
] where
nick = utf8 <$> P.takeWhile (not . P.inClass " \n\r\t\v<>")
@@ -128,6 +129,9 @@ parseEvent = asum
case BS.unsnoc bs of
Just (s, c) | c == fromIntegral (ord c2) -> return (utf8 s)
_ -> fail "Wrong end char"
+ stripFinalDash n = case T.unsnoc n of
+ Just (n', '-') -> return n'
+ _ -> empty
utf8 = TE.decodeUtf8Lenient
remaining = utf8 <$> P.takeByteString