summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2026-05-08 01:05:09 +0200
committerTom Smeding <tom@tomsmeding.com>2026-05-08 01:05:09 +0200
commitb1429cd1cf064b69cd4bf8935885bba2e9dcfcb1 (patch)
treea32484c91b0650a97af3232ca65b483f35445afa
parent80ba594a6b44b9693eeaa27bf3bea225a57527ca (diff)
ZNC: fix notice parsing
-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