aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Data/Char/Extended.hs12
-rw-r--r--src/Reaktor/Plugins/Mention.hs4
2 files changed, 13 insertions, 3 deletions
diff --git a/src/Data/Char/Extended.hs b/src/Data/Char/Extended.hs
index add079d..34d0c3e 100644
--- a/src/Data/Char/Extended.hs
+++ b/src/Data/Char/Extended.hs
@@ -1,9 +1,19 @@
module Data.Char.Extended
( module Data.Char
, isAsciiLetter
+ , isNick
) where
import Data.Char
isAsciiLetter :: Char -> Bool
-isAsciiLetter c = Data.Char.isAsciiUpper c || Data.Char.isAsciiLower c
+isAsciiLetter c = isAsciiUpper c || isAsciiLower c
+
+-- RFC1459
+isNick :: Char -> Bool
+isNick c =
+ 0x41 <= i && i <= 0x7D || -- letters / specials
+ 0x30 <= i && i <= 0x39 || -- digits
+ 0x2D == i -- minus
+ where
+ i = ord c
diff --git a/src/Reaktor/Plugins/Mention.hs b/src/Reaktor/Plugins/Mention.hs
index b288fdb..b0dcca1 100644
--- a/src/Reaktor/Plugins/Mention.hs
+++ b/src/Reaktor/Plugins/Mention.hs
@@ -3,7 +3,7 @@
{-# LANGUAGE RecordWildCards #-}
module Reaktor.Plugins.Mention (new) where
-import qualified Data.Char
+import qualified Data.Char.Extended as C
import qualified Data.Text as T
import Prelude.Extended
import Reaktor
@@ -20,4 +20,4 @@ new Actions{..} = do
where
isMention nick text =
not (T.isPrefixOf (nick <> ":") text) &&
- any (==nick) (T.split (not . Data.Char.isAlphaNum) text)
+ any (==nick) (T.split (not . C.isNick) text)