packages feed

slack-api 0.1 → 0.2

raw patch · 5 files changed

+14/−10 lines, 5 files

Files

slack-api.cabal view
@@ -1,5 +1,5 @@ Name:                slack-api-Version:             0.1+Version:             0.2 Synopsis:            Bindings to the Slack RTM API. Description:         This library provides bindings to the <https://api.slack.com/rtm Slack Real Time Messaging API>.                      Users should find it easy to program their own Slack bots using the functionality found in `Web.Slack`.
src/Web/Slack.hs view
@@ -80,7 +80,7 @@   let Just url = r ^? responseBody . key "url" . _String   (sessionInfo :: SlackSession) <-     case eitherDecode (r ^. responseBody) of-      Left e -> ioError . userError $ e+      Left e -> (print (r ^. responseBody)) >> (ioError . userError $ e)       Right res -> return res   putStrLn "rtm.start call successful"   let (host, path) = splitAt 19 (drop 6 $ T.unpack url)
src/Web/Slack/Types/Preferences.hs view
@@ -101,9 +101,9 @@   $(deriveJSON defaultOptions {fieldLabelModifier = \case-                                                    "prefTime24" -> "time24"-                                                    "prefNoMacssb1Banner" -> "no_macssb1_banner"-                                                    s -> toSnake . drop 4 $ s} ''Preferences)+                                                    "_prefTime24" -> "time24"+                                                    "_prefNoMacssb1Banner" -> "no_macssb1_banner"+                                                    s -> toSnake . drop (length "_pref") $ s} ''Preferences)  -- Bad performance regression from lens 4.6 causes GHC to run out of memory -- on compilation
src/Web/Slack/Types/TeamPreferences.hs view
@@ -48,7 +48,7 @@                      } deriving Show  -$(deriveJSON defaultOptions {fieldLabelModifier = toSnake . drop 4} ''TeamPreferences)+$(deriveJSON defaultOptions {fieldLabelModifier = toSnake . drop 5} ''TeamPreferences)  --makeLensesWith abbreviatedFields ''TeamPreferences makeLenses ''TeamPreferences
src/Web/Slack/Types/User.hs view
@@ -26,13 +26,17 @@  instance FromJSON User where   parseJSON = withObject "User" (\o -> User <$> o .: "id" <*> o .: "name" <*> o .: "deleted"-                                        <*> o .:? "status" <*> o .: "color"+                                        <*> o .:? "status" <*> (o .:? "color" .!= "000000")                                         <*> o .: "profile" <*> (parseJSON (Object o) :: Parser Permissions)                                         <*> fmap (fromMaybe False) (o .:? "has_files")-                                        <*> (parseJSON (Object o) :: Parser Timezone))+                                        <*> ((return $ fromMaybe defaultTimezone (parseMaybe parseJSON (Object o))) :: Parser Timezone)) +defaultTimezone :: Timezone+defaultTimezone = Timezone Nothing "Pacific Standard Time" (-28800)++ instance FromJSON Permissions where-  parseJSON = withObject "Permissions" (\o -> let v = (o .:) in+  parseJSON = withObject "Permissions" (\o -> let v x = (o .:? x .!= False) in                                         Permissions <$> v "is_admin" <*> v "is_owner"                                           <*> v "is_primary_owner" <*> v "is_restricted"                                           <*> v "is_ultra_restricted" <*> v "is_bot")@@ -44,7 +48,7 @@               } deriving Show  instance FromJSON Timezone where-  parseJSON = withObject "timezone" (\o -> Timezone <$> o .: "tz" <*> o .: "tz_label" <*> o .: "tz_offset")+  parseJSON = withObject "timezone" (\o -> Timezone <$> o .:? "tz" <*> o .: "tz_label" <*> o .: "tz_offset")  data Permissions = Permissions                  { _isAdmin           :: Bool