X-Git-Url: https://git.martlubbers.net/?p=cloogle-irc.git;a=blobdiff_plain;f=IRC.icl;h=39e3f5004111d345f997a9c438d405652e7b0991;hp=d0a0098775973b0c7b7dbeb36d619de46a1136ec;hb=1c65613d8732d28f6c6c11864ccbc761918ac594;hpb=73e3f056b86da6bd5ac20b0f14a28ac7f79512d1 diff --git a/IRC.icl b/IRC.icl index d0a0098..39e3f50 100644 --- a/IRC.icl +++ b/IRC.icl @@ -1,29 +1,18 @@ implementation module IRC -import StdList, StdTuple, StdOverloaded, StdFunc, StdString, StdChar, StdBool -import _SystemArray - -import GenPrint -import GenIRC +import StdEnv import Control.Applicative -import Control.Monad +import Control.Monad => qualified join import Data.Either +import Data.Func import Data.Maybe -import Data.Tuple +import Text +import Text.GenPrint import Text.Parsers.Simple.Chars import Text.Parsers.Simple.Core -import StdDebug - -from Data.Functor import <$> -from Data.Func import $ -from StdMisc import undef, abort -from Text import class Text(lpad,trim,rtrim,split,indexOf,concat), - instance Text String -import qualified Text - -jon :== 'Text'.join +import GenIRC derive gPrint IRCErrors, IRCReplies, Maybe, Either, IRCUser, IRCNumReply @@ -42,6 +31,7 @@ where , parseIRCMessage ":wilhelm.freenode.net 001 clooglebot :Welcome to the freenode Internet Relay Chat Network clooglebot\r\n" , parseIRCMessage "PING :orwell.freenode.net\r\n" , parseIRCMessage ":ChanServ!ChanServ@services. MODE #cloogle +o frobnicator\r\n" + , parseIRCMessage ":qbot_v01!~qbot@ip-213-124-170-20.ip.prioritytelecom.net PRIVMSG ##chinees :[link] Cloogle - https://cloogle.org" ] parseIRCMessage :: String -> Either [Error] IRCMessage @@ -78,11 +68,11 @@ where parseNick :: Parser Char String parseNick = pAlpha - >>= \c ->pMany (pAlpha <|> pDigit <|> pOneOf (fromString "-[]\\`^{}")) + >>= \c ->pMany (pAlpha <|> pDigit <|> pOneOf (fromString "_-[]\\`^{}")) >>= \cs->pure (toString [c:cs]) parseHost :: Parser Char String - parseHost = jon "." <$> (pSepBy parseName (pToken '.')) + parseHost = join "." <$> (pSepBy parseName (pToken '.')) >>= \s->optional (pToken '.') >>= pure o maybe s (\p->s+++toString s) where parseName :: Parser Char String @@ -96,7 +86,7 @@ parseCmd cs = fst $ gIRCParse{|*|} $ argfun $ split " " $ toString cs argfun [] = [] argfun [x:xs] # x = trim x - | x.[0] == ':' = [jon " " $ [x % (1, size x):map rtrim xs]] + | x.[0] == ':' = [join " " $ [x % (1, size x):map rtrim xs]] | otherwise = [x:argfun xs] //Reply @@ -132,7 +122,7 @@ instance toString IRCUser where toString m = m.irc_nick <+ maybe "" ((<+) "!") m.irc_user <+ maybe "" ((<+) "@") m.irc_host instance toString IRCCommand where - toString m = jon " " (gIRCPrint{|*|} m) +++ "\r\n" + toString m = join " " (gIRCPrint{|*|} m) +++ "\r\n" instance toString IRCReplies where toString r = printToString r instance toString IRCErrors where toString r = printToString r