packages feed

tellbot 0.6.0.8 → 0.6.0.10

raw patch · 4 files changed

+23/−9 lines, 4 files

Files

CHANGELOG.md view
@@ -1,6 +1,14 @@ tellbot CHANGELOG ================= +### 0.6.0.10++- Fixed exception reading stream (UTF-8 fail).++### 0.6.0.8++- Fixed IRC colors change in HTML title.+ ### 0.6.0.8  - Fixed IRC colors change in HTML title.
src/HTML.hs view
@@ -1,6 +1,6 @@ module HTML where -import Control.Exception ( SomeException, catch )+import Control.Exception ( SomeException, catch, evaluate ) import Data.ByteString.Lazy ( toStrict ) import Data.Char import Network.HTTP.Conduit@@ -14,17 +14,20 @@     regexps <- fmap Prelude.lines $ readFile regPath      if (safeHost regexps url) then do       putStrLn $ url ++ " is safe"-      fmap (extractTitle . unpack . T.concat . T.lines . decodeUtf8 . toStrict) (simpleHttp url)+      resp <- simpleHttp url+      evaluate $ extractTitle . unpack . T.concat . T.lines . decodeUtf8 $ toStrict resp       else         pure Nothing   where     handleException :: SomeException -> IO (Maybe String)-    handleException _ = pure mempty+    handleException e = do+      putStrLn $ "Exception: " ++ show e+      pure Nothing      extractTitle :: String -> Maybe String extractTitle body =   case dropTillTitle (parseTags body) of-    (TagText title:TagClose "title":_) -> pure ("\ETX7« \ETX6" ++ chomp title ++ " \ETX7»\SI")+    (TagText title:TagClose "title":_) -> pure ("\ETX7«\ETX6 " ++ chomp title ++ " \ETX7»\SI")     _ -> Nothing  dropTillTitle :: [Tag String] -> [Tag String]@@ -33,7 +36,7 @@ dropTillTitle (_:xs) = dropTillTitle xs  chomp :: String -> String-chomp = filter (\c -> isAlphaNum c || isPunctuation c || c == ' ') . unpack . strip . pack+chomp = filter (\c -> ord c >= 32 && (isAlphaNum c || isPunctuation c || c == ' ')) . unpack . strip . pack  -- Filter an URL so that we don’t make overviews of unknown hosts. Pretty -- cool to prevent people from going onto sensitive websites.
src/Main.hs view
@@ -1,5 +1,5 @@ import Control.Concurrent ( threadDelay )-import Control.Exception ( SomeException, try )+import Control.Exception ( SomeException, catch, try ) import Control.Monad import Control.Monad.Except import Control.Monad.Trans.RWS@@ -19,7 +19,7 @@ import System.IO  version :: Version-version = Version [0,6,0,7] ["Apfelschorle"]+version = Version [0,6,0,9] ["Apfelschorle"]  type Server     = String type Chan       = String@@ -81,7 +81,10 @@  -- Receive a line from IRC. The line is formatted using the IRC protocol (RFC 1459). fromIRC :: Session String-fromIRC = asks conHandle >>= lift . hGetLine+fromIRC = asks conHandle >>= \h -> lift $ catch (hGetLine h) handleError+  where+    handleError :: SomeException -> IO String+    handleError _ = pure ""  -- Send a message to someone in the current IRC session. msgIRC :: String -> String -> Session ()
tellbot.cabal view
@@ -1,5 +1,5 @@ name:                tellbot-version:             0.6.0.8+version:             0.6.0.10 synopsis:            IRC tellbot description:         An IRC bot that can be used to create queuing message.                      It also offers a simple administration IRC bot interface.