packages feed

slack-api 0.8 → 0.9

raw patch · 11 files changed

+29/−67 lines, 11 files

Files

slack-api.cabal view
@@ -1,5 +1,5 @@ Name:                slack-api-Version:             0.8+Version:             0.9 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`.@@ -42,7 +42,6 @@                    Web.Slack.Types.Channel,                    Web.Slack.Types.Event,                    Web.Slack.Types.Event.Subtype,-                   Web.Slack.Types.Group,                    Web.Slack.Types.Item,                    Web.Slack.Types.User,                    Web.Slack.Types.ChannelOpt,
src/Web/Slack/Types.hs view
@@ -6,7 +6,6 @@  module Web.Slack.Types.Topic,  module Web.Slack.Types.Channel,  module Web.Slack.Types.Event.Subtype,- module Web.Slack.Types.Group,  module Web.Slack.Types.Item,  module Web.Slack.Types.User,  module Web.Slack.Types.ChannelOpt,@@ -31,7 +30,6 @@ import Web.Slack.Types.Topic import Web.Slack.Types.Channel import Web.Slack.Types.Event.Subtype-import Web.Slack.Types.Group import Web.Slack.Types.Item import Web.Slack.Types.User import Web.Slack.Types.ChannelOpt
src/Web/Slack/Types/Channel.hs view
@@ -25,6 +25,7 @@                        , _channelPurpose    :: Maybe Purpose                        , _channelIsMember   :: Bool                        , _channelOpt        :: Maybe ChannelOpt+                       , _channelIsGroup    :: Bool                        } deriving Show  makeLenses ''Channel@@ -38,4 +39,5 @@                                                   <*> o .:? "is_archived" <*> defaultToFalse o "is_general"                                                   <*> o .:? "members" <*> o .:? "topic"                                                   <*> o .:? "purpose" <*> defaultToFalse o "is_member"-                                                  <*> (pure $ parseMaybe parseJSON (Object o) :: Parser (Maybe ChannelOpt)))+                                                  <*> (pure $ parseMaybe parseJSON (Object o) :: Parser (Maybe ChannelOpt))+                                                  <*> o .:? "is_group" .!= False)
src/Web/Slack/Types/Event.hs view
@@ -13,7 +13,6 @@ import Web.Slack.Types.Comment import Web.Slack.Types.Error import Web.Slack.Types.Event.Subtype-import Web.Slack.Types.Group import Web.Slack.Types.Time import Web.Slack.Types.Presence @@ -36,7 +35,7 @@   ChannelMarked :: ChannelId -> SlackTimeStamp -> Event   ChannelCreated :: Channel -> Event   ChannelJoined :: Channel -> Event-  ChannelLeft   :: Channel -> Event+  ChannelLeft   :: ChannelId -> Event   ChannelDeleted :: ChannelId -> Event   ChannelRename :: ChannelRenameInfo -> Event   ChannelArchive :: ChannelId -> UserId -> Event@@ -47,19 +46,19 @@   ImClose :: UserId -> IMId -> Event   ImMarked :: IMId -> SlackTimeStamp -> Event   ImHistoryChanged :: SlackTimeStamp -> SlackTimeStamp -> SlackTimeStamp -> Event-  GroupJoined :: Group -> Event-  GroupLeft :: Group -> Event-  GroupOpen :: UserId -> GroupId -> Event-  GroupClose :: UserId -> GroupId -> Event-  GroupArchive :: GroupId -> Event-  GroupUnarchive :: GroupId -> Event+  GroupJoined :: Channel -> Event+  GroupLeft :: Channel -> Event+  GroupOpen :: UserId -> ChannelId -> Event+  GroupClose :: UserId -> ChannelId -> Event+  GroupArchive :: ChannelId -> Event+  GroupUnarchive :: ChannelId -> Event   GroupRename :: ChannelRenameInfo -> Event-  GroupMarked :: GroupId -> SlackTimeStamp -> Event+  GroupMarked :: ChannelId -> SlackTimeStamp -> Event   GroupHistoryChanged :: SlackTimeStamp -> SlackTimeStamp -> SlackTimeStamp -> Event   FileCreated :: File -> Event-  FileShared :: File -> Event+  FileShared :: FileReference -> Event   FileUnshared :: File -> Event-  FilePublic :: File -> Event+  FilePublic :: FileReference -> Event   FilePrivate :: FileId -> Event   FileChange  :: File -> Event   FileDeleted :: FileId -> SlackTimeStamp -> Event
src/Web/Slack/Types/File.hs view
@@ -57,6 +57,8 @@                 <*> fmap (fromMaybe 0) (o .:? "num_stars") <*> o .: "comments_count" ) instance FromJSON FileUrl where   parseJSON = withObject "FileURL" (\o -> URL <$> o .: "url_private" <*> o .: "url_private_download")+instance FromJSON FileReference where+  parseJSON = withObject "FileReference" (\o -> FileReference <$> o .: "id") instance FromJSON Thumbnail where   parseJSON = withObject "Thumbnail" (\o -> Thumbnail <$> o .:? "thumb_64" <*> o .:? "thumb_80" <*>  o .:? "thumb_360" <*> o .:? "thumb_360_gif" <*> o .:? "thumb_360_w" <*> o .:? "thumb_360_h") instance FromJSON Preview where@@ -65,10 +67,12 @@  data Preview = Preview { _previewText :: Text, _previewHighlight :: Text, _lines :: Int, _linesMore :: Int } deriving Show data FileUrl = URL { _private :: Text, _privateDownload :: Text } deriving Show+data FileReference = FileReference { _fileReferenceId :: FileId } deriving Show data Thumbnail = Thumbnail { _w64 :: Maybe URL, _w80 :: Maybe URL, _w360 :: Maybe URL, _w360gif :: Maybe URL, _width :: Maybe Int, _height :: Maybe Int} deriving Show  makeLenses ''File makeLenses ''FileUrl+makeLenses ''FileReference makeLenses ''Thumbnail makeLenses ''Preview 
− src/Web/Slack/Types/Group.hs
@@ -1,41 +0,0 @@-{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}-module Web.Slack.Types.Group where--import Data.Aeson-import Data.Aeson.Types-import Control.Lens.TH-import Web.Slack.Types.Id-import Web.Slack.Types.Time-import Web.Slack.Types.Topic-import {-# SOURCE #-} Web.Slack.Types.ChannelOpt (ChannelOpt)--import Control.Applicative--import Data.Text (Text)-import Prelude--data Group = Group-           { _groupId         :: GroupId-           , _groupName       :: Text-           , _groupCreated    :: Time-           , _groupCreator    :: UserId-           , _groupIsArchived :: Bool-           , _groupIsOpen     :: Bool-           , _groupMembers    :: [UserId]-           , _groupTopic      :: Topic-           , _groupPurpose    :: Purpose-           , _groupOpt        :: Maybe ChannelOpt-           , _groupIsGroup    :: Bool-           } deriving (Show)--makeLenses ''Group--instance FromJSON Group where-  parseJSON = withObject "Group" (\o ->-               Group <$> o .: "id" <*> o .: "name"-                <*> o .: "created" <*> o .: "creator"-                <*> o .: "is_archived" <*> o .: "is_open"-                <*> o .: "members" <*> o .: "topic"-                <*> o .: "purpose"-                <*> (pure $ parseMaybe parseJSON (Object o) :: Parser (Maybe ChannelOpt))-                <*> o .: "is_group")
src/Web/Slack/Types/Id.hs view
@@ -5,10 +5,9 @@     ChannelId,     FileId,     CommentId,-    GroupId,     IMId,     TeamId,-    Id,+    Id(..),     getId   ) where @@ -16,7 +15,7 @@ import Data.Text (Text) import Control.Lens.TH -data FieldType = TUser | TBot | TChannel | TFile | TComment | TGroup | TIM | TTeam deriving (Eq, Show)+data FieldType = TUser | TBot | TChannel | TFile | TComment | TIM | TTeam deriving (Eq, Show)  newtype Id (a :: FieldType) = Id { _getId :: Text } deriving (Show, Eq) @@ -32,7 +31,6 @@ type ChannelId = Id 'TChannel type FileId    = Id 'TFile type CommentId = Id 'TComment-type GroupId   = Id 'TGroup type IMId      = Id 'TIM type TeamId    = Id 'TTeam 
src/Web/Slack/Types/Item.hs view
@@ -18,7 +18,7 @@           | FileCommentItem File Comment           | ChannelItem ChannelId           | IMItem ChannelId-          | GroupItem GroupId deriving Show+          | GroupItem ChannelId deriving Show  instance  FromJSON Item where   parseJSON = withObject "item" (\o -> do
src/Web/Slack/Types/Preferences.hs view
@@ -64,7 +64,6 @@                  , _prefEnterIsSpecialInTbt             :: Bool                  , _prefGraphicEmoticons                :: Bool                  , _prefConvertEmoticons                :: Bool-                 , _prefAutoplayChatSounds              :: Bool                  , _prefSsEmojis                        :: Bool                  , _prefSidebarBehavior                 :: Text                  , _prefMarkMsgsReadImmediately         :: Bool
src/Web/Slack/Types/Session.hs view
@@ -9,7 +9,6 @@ import Web.Slack.Types.Self import Web.Slack.Types.Team import Web.Slack.Types.Channel-import Web.Slack.Types.Group import Web.Slack.Types.IM import Web.Slack.Types.Bot import Data.Text (Text)@@ -22,7 +21,7 @@                 , _slackUsers         :: [User]                 , _slackLatestEventTs :: SlackTimeStamp                 , _slackChannels      :: [Channel]-                , _slackGroups        :: [Group]+                , _slackGroups        :: [Channel]                 , _slackIms           :: [IM]                 , _slackBots          :: [Bot]                 , _slackCacheVersion  :: Text
src/Web/Slack/Types/Time.hs view
@@ -23,8 +23,13 @@   parseJSON = withText "SlackTimeStamp"                 (\s -> let (ts, tail -> uid) = break (== '.') (T.unpack s) in                   SlackTimeStamp-                    <$> fmap (Time . realToFrac) (readZ ts :: Parser Integer)+                    <$> parseTimeString ts                     <*> readZ uid)  instance FromJSON Time where-  parseJSON = withScientific "Time" (return . Time . realToFrac)+  parseJSON (Number s) = return $ Time $ realToFrac s+  parseJSON (String t) = parseTimeString $ T.unpack t+  parseJSON _ = empty++parseTimeString :: String -> Parser Time+parseTimeString s = fmap (Time . realToFrac) (readZ s :: Parser Integer)