slack-api 0.3 → 0.4
raw patch · 21 files changed
+46/−27 lines, 21 filesdep +time-locale-compatdep ~time
Dependencies added: time-locale-compat
Dependency ranges changed: time
Files
- slack-api.cabal +5/−4
- src/Web/Slack/Message.hs +2/−0
- src/Web/Slack/State.hs +1/−0
- src/Web/Slack/Types/Bot.hs +5/−5
- src/Web/Slack/Types/Channel.hs +1/−0
- src/Web/Slack/Types/ChannelOpt.hs +2/−0
- src/Web/Slack/Types/Comment.hs +1/−0
- src/Web/Slack/Types/Event.hs +1/−0
- src/Web/Slack/Types/File.hs +2/−0
- src/Web/Slack/Types/Group.hs +1/−0
- src/Web/Slack/Types/IM.hs +2/−0
- src/Web/Slack/Types/Id.hs +8/−8
- src/Web/Slack/Types/Item.hs +1/−0
- src/Web/Slack/Types/Preferences.hs +0/−4
- src/Web/Slack/Types/Presence.hs +1/−0
- src/Web/Slack/Types/Self.hs +2/−0
- src/Web/Slack/Types/Session.hs +1/−0
- src/Web/Slack/Types/Team.hs +1/−0
- src/Web/Slack/Types/Topic.hs +1/−0
- src/Web/Slack/Types/User.hs +3/−0
- tests/Tests/ConnectionTest.hs +5/−6
slack-api.cabal view
@@ -1,5 +1,5 @@ Name: slack-api-Version: 0.3+Version: 0.4 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`.@@ -78,15 +78,16 @@ io-streams >= 1.2, mtl >= 2.1, aeson >= 0.8 ,- time >= 1.4.2 && < 1.5,+ time-locale-compat >= 0.1 && < 0.2, errors >= 1.4, monad-loops >= 0.4,- transformers >= 0.3+ transformers >= 0.3,+ time >= 1.4 Test-Suite tests Type: exitcode-stdio-1.0 Main-Is: tests-main.hs- ghc-options: -threaded+ ghc-options: -Wall HS-Source-Dirs: tests . Build-Depends: slack-api, base Other-Modules: Tests.ConnectionTest
src/Web/Slack/Message.hs view
@@ -15,6 +15,8 @@ import Web.Slack.Types import Data.Time.Clock.POSIX +import Prelude+ data MessagePayload = MessagePayload { messageId :: Int , messageType :: T.Text
src/Web/Slack/State.hs view
@@ -16,6 +16,7 @@ import qualified Network.WebSockets as WS import Web.Slack.Types import Web.Slack.Config+import Prelude newtype Slack s a = Slack {runSlack :: S.StateT (SlackState s) IO a} deriving (Monad, Functor, Applicative, S.MonadState (SlackState s), MonadIO)
src/Web/Slack/Types/Bot.hs view
@@ -9,17 +9,17 @@ import Web.Slack.Types.Id import Web.Slack.Types.Base-+import Prelude data Bot = Bot { _botId :: BotId , _botName :: Text- , _botIcons :: BotIcons+ , _botIcons :: Maybe BotIcons } deriving (Show) data BotIcons = BotIcons- { _botIconImage48 :: URL+ { _botIconImage48 :: Maybe URL } deriving (Show) makeLenses ''Bot@@ -28,8 +28,8 @@ instance FromJSON BotIcons where parseJSON = withObject "icons" (\v ->- BotIcons <$> v .: "image_48")+ BotIcons <$> v .:? "image_48") instance FromJSON Bot where parseJSON = withObject "bot" (\v ->- Bot <$> v .: "id" <*> v .: "name" <*> v .: "icons")+ Bot <$> v .: "id" <*> v .: "name" <*> v .:? "icons")
src/Web/Slack/Types/Channel.hs view
@@ -11,6 +11,7 @@ import Web.Slack.Types.Time import Web.Slack.Types.Topic import {-# SOURCE #-} Web.Slack.Types.ChannelOpt (ChannelOpt)+import Prelude data Channel = Channel { _channelId :: ChannelId , _channelName :: Text
src/Web/Slack/Types/ChannelOpt.hs view
@@ -8,6 +8,8 @@ import Web.Slack.Types.Time +import Prelude+ data ChannelOpt = ChannelOpt { _channelOptLastRead :: SlackTimeStamp , _channelOptUnreadCount :: Int
src/Web/Slack/Types/Comment.hs view
@@ -8,6 +8,7 @@ import Web.Slack.Types.Id import Web.Slack.Types.Time+import Prelude data Comment = Comment { _commentId :: CommentId
src/Web/Slack/Types/Event.hs view
@@ -25,6 +25,7 @@ import Data.Text (Text) import qualified Data.Text as T import Data.Monoid+import Prelude type Domain = Text
src/Web/Slack/Types/File.hs view
@@ -14,6 +14,8 @@ import Web.Slack.Types.Time import Web.Slack.Types.Base +import Prelude+ data File = File { _fileId :: FileId , _fileTimestamp :: Time , _fileName :: Maybe Text
src/Web/Slack/Types/Group.hs view
@@ -12,6 +12,7 @@ import Control.Applicative import Data.Text (Text)+import Prelude data Group = Group { _groupId :: GroupId
src/Web/Slack/Types/IM.hs view
@@ -10,6 +10,8 @@ import Web.Slack.Types.Time import {-# SOURCE #-} Web.Slack.Types.ChannelOpt (ChannelOpt) +import Prelude+ data IM = IM { _imId :: IMId , _imUser :: UserId
src/Web/Slack/Types/Id.hs view
@@ -27,13 +27,13 @@ instance FromJSON (Id a) where parseJSON = withText "Id" (return . Id) -type UserId = Id TUser-type BotId = Id TBot-type ChannelId = Id TChannel-type FileId = Id TFile-type CommentId = Id TComment-type GroupId = Id TGroup-type IMId = Id TIM-type TeamId = Id TTeam+type UserId = Id 'TUser+type BotId = Id 'TBot+type ChannelId = Id 'TChannel+type FileId = Id 'TFile+type CommentId = Id 'TComment+type GroupId = Id 'TGroup+type IMId = Id 'TIM+type TeamId = Id 'TTeam makeLenses ''Id
src/Web/Slack/Types/Item.hs view
@@ -11,6 +11,7 @@ import Web.Slack.Types.Base import Control.Lens.TH+import Prelude data Item = MessageItem ChannelId MessageUpdate | FileItem File
src/Web/Slack/Types/Preferences.hs view
@@ -63,8 +63,6 @@ , _prefCollapsible :: Bool , _prefCollapsibleByClick :: Bool , _prefRequireAt :: Bool- , _prefMacSsbBullet :: Bool- , _prefWinSsbBullet :: Bool , _prefExpandNonMediaAttachments :: Bool , _prefShowTyping :: Bool , _prefPagekeysHandled :: Bool@@ -93,7 +91,6 @@ , _prefFullTextExtracts :: Bool , _prefNoTextInNotifications :: Bool , _prefMutedChannels :: Text- , _prefNoMacssb1Banner :: Bool , _prefPrivacyPolicySeen :: Bool , _prefSearchExcludeBots :: Bool , _prefFuzzyMatching :: Bool@@ -102,7 +99,6 @@ $(deriveJSON defaultOptions {fieldLabelModifier = \case "_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
src/Web/Slack/Types/Presence.hs view
@@ -4,6 +4,7 @@ import Data.Aeson import Control.Applicative import qualified Data.Text as T+import Prelude data Presence = Away | Active deriving Show
src/Web/Slack/Types/Self.hs view
@@ -11,6 +11,8 @@ import Control.Applicative import Control.Lens.TH +import Prelude+ data Self = Self { _selfUserId :: UserId , _selfName :: Text
src/Web/Slack/Types/Session.hs view
@@ -14,6 +14,7 @@ import Web.Slack.Types.Bot import Data.Text (Text) import Control.Lens.TH+import Prelude data SlackSession = SlackSession { _slackSelf :: Self
src/Web/Slack/Types/Team.hs view
@@ -9,6 +9,7 @@ import Control.Lens.TH import Data.Aeson import Control.Applicative+import Prelude data Team = Team { _teamId :: TeamId
src/Web/Slack/Types/Topic.hs view
@@ -5,6 +5,7 @@ import Data.Text (Text) import Control.Applicative import Control.Lens.TH+import Prelude type Purpose = Topic
src/Web/Slack/Types/User.hs view
@@ -11,7 +11,9 @@ import Web.Slack.Types.Id import Web.Slack.Types.Base +import Prelude + data User = User { _userId :: UserId , _userName :: Text@@ -78,6 +80,7 @@ makeLenses ''Profile makeLenses ''Permissions makeLenses ''Timezone+makeLenses ''User instance FromJSON Profile where parseJSON = withObject "Profile"
tests/Tests/ConnectionTest.hs view
@@ -1,10 +1,7 @@ module Tests.ConnectionTest (main) where import Web.Slack-import Web.Slack.Message import System.Environment (lookupEnv)-import Data.Maybe (fromMaybe)-import Control.Applicative import System.Exit import System.IO.Unsafe @@ -17,11 +14,13 @@ connectBot Hello = unsafePerformIO exitSuccess connectBot _ = return () + main :: IO () main = do- apiToken <- fromMaybe (unsafePerformIO exitFailure)- <$> lookupEnv "SLACK_API_TOKEN"- runBot (myConfig apiToken) connectBot ()+ apiToken <- lookupEnv "SLACK_API_TOKEN"+ case apiToken of+ Nothing -> exitFailure+ Just token -> runBot (myConfig token) connectBot ()