X-Git-Url: https://git.martlubbers.net/?p=cloogle-irc.git;a=blobdiff_plain;f=cloogleirc.icl;h=05aaa7d24e9f2ba0734814982173a6b8ce00a201;hp=3e89acc8f2d172f0810f6b8a7522ccca3f78f171;hb=6074fc23351ac06daad779b3ac6c09a36590de24;hpb=73e3f056b86da6bd5ac20b0f14a28ac7f79512d1 diff --git a/cloogleirc.icl b/cloogleirc.icl index 3e89acc..05aaa7d 100644 --- a/cloogleirc.icl +++ b/cloogleirc.icl @@ -20,7 +20,7 @@ import System.Time import Control.Applicative import qualified Control.Monad as CM import qualified Data.Map as DM -from Control.Monad import class Monad, instance Monad Maybe, >>= +from Control.Monad import class Monad(bind), instance Monad Maybe, >>= from Text.Encodings.UrlEncoding import urlEncode import System.CommandLine import Internet.HTTP @@ -56,7 +56,7 @@ shorten s w cloogle :: String *World -> (String, *World) cloogle data w -# (mer, w) = doHTTPRequestL +# (mer, w) = doHTTPRequestFollowRedirects { newHTTPRequest & req_path = "/api.php" , req_query = "?str=" + urlEncode data @@ -67,6 +67,7 @@ cloogle data w # resp = fromOk mer = case fromJSON $ fromString resp.HTTPResponse.rsp_data of Nothing = ("couldn't parse json", w) + Just {return=127} = ("No results for " + data, w) Just clr = ("Results for " + data + " -- https://cloogle.org/#" + replaceSubString "+" "%20" (urlEncode data) + "\n" + processResults clr, w) @@ -114,7 +115,7 @@ Start w //| isError bs = (Just $ "\n" +++ fromError bs +++ "\n", snd $ fclose io w) # (Ok bs) = bs # (merr, io, w) = bot (bs.bs_server, bs.bs_port) (startup bs) shutdown io (process bs.bs_strftime) w -= (Nothing, w)//= (merr, snd $ fclose io w) += (merr, snd $ fclose io w) where parseCLI :: [String] -> MaybeErrorString BotSettings parseCLI [] = Ok @@ -176,7 +177,7 @@ Start w (Nothing, w) = (Nothing, io, w) (Just cs, w) # msgs = map toPrefix cs - #! (io, w) = foldr (log strf " (s): ") (io, w) msgs +// #! (io, w) = foldr (log strf " (s): ") (io, w) msgs = (Just msgs, io, w) log :: String String IRCMessage (!*File, !*World) -> (!*File, !*World)