discord-haskell 0.7.0 → 0.7.1
raw patch · 5 files changed
+37/−22 lines, 5 files
Files
- discord-haskell.cabal +1/−1
- src/Discord/Gateway/EventLoop.hs +2/−1
- src/Discord/Rest/Prelude.hs +1/−1
- src/Discord/Types/Gateway.hs +30/−16
- src/Discord/Types/Prelude.hs +3/−3
discord-haskell.cabal view
@@ -1,6 +1,6 @@ name: discord-haskell -- library version is also noted at src/Discord/Rest/Prelude.hs-version: 0.7.0+version: 0.7.1 synopsis: Write bots for Discord in Haskell description: Functions and data types to write discord bots. Official discord docs <https://discordapp.com/developers/docs/reference>.
src/Discord/Gateway/EventLoop.hs view
@@ -174,8 +174,9 @@ eitherPayload <- getPayloadTimeout conn interval log case eitherPayload :: Either ConnectionException GatewayReceivable of Left (CloseRequest code str) -> case code of- -- see discord documentation on gateway close event codes+ -- see Discord and MDN documentation on gateway close event codes 1000 -> ConnReconnect auth seshID <$> readIORef seqKey+ 1001 -> ConnReconnect auth seshID <$> readIORef seqKey 4000 -> ConnReconnect auth seshID <$> readIORef seqKey 4006 -> pure ConnStart 4007 -> ConnReconnect auth seshID <$> readIORef seqKey
src/Discord/Rest/Prelude.hs view
@@ -24,7 +24,7 @@ where -- | https://discordapp.com/developers/docs/reference#user-agent -- Second place where the library version is noted- agent = "DiscordBot (https://github.com/aquarial/discord-haskell, 0.7.0)"+ agent = "DiscordBot (https://github.com/aquarial/discord-haskell, 0.7.1)" -- Append to an URL infixl 5 //
src/Discord/Types/Gateway.hs view
@@ -40,9 +40,9 @@ deriving (Show) data RequestGuildMembersOpts = RequestGuildMembersOpts- { requestGuildMemersGuildId :: Snowflake- , requestGuildMemersSearchQuery :: T.Text- , requestGuildMemersLimit :: Integer }+ { requestGuildMembersGuildId :: Snowflake+ , requestGuildMembersSearchQuery :: T.Text+ , requestGuildMembersLimit :: Integer } deriving (Show) data UpdateStatusVoiceOpts = UpdateStatusVoiceOpts@@ -55,20 +55,32 @@ data UpdateStatusOpts = UpdateStatusOpts { updateStatusSince :: Maybe UTCTime- -- todo , updateStatusGame :: Activity- , updateStatusNewStatus :: UpdateStatusTypes+ , updateStatusGame :: Maybe Activity+ , updateStatusNewStatus :: UpdateStatusType , updateStatusAFK :: Bool } deriving (Show) -data UpdateStatusTypes = UpdateStatusOnline- | UpdateStatusDoNotDisturb- | UpdateStatusAwayFromKeyboard- | UpdateStatusInvisibleOffline- | UpdateStatusOffline+data Activity = Activity+ { activityName :: T.Text+ , activityType :: ActivityType+ , activityUrl :: Maybe T.Text+ } deriving (Show) -statusString :: UpdateStatusTypes -> T.Text+data ActivityType = ActivityTypeGame+ | ActivityTypeStreaming+ | ActivityTypeListening+ deriving (Enum, Show)++data UpdateStatusType = UpdateStatusOnline+ | UpdateStatusDoNotDisturb+ | UpdateStatusAwayFromKeyboard+ | UpdateStatusInvisibleOffline+ | UpdateStatusOffline+ deriving (Show)++statusString :: UpdateStatusType -> T.Text statusString s = case s of UpdateStatusOnline -> "online" UpdateStatusDoNotDisturb -> "dnd"@@ -124,17 +136,19 @@ , "shard" .= shard ] ]- toJSON (UpdateStatus (UpdateStatusOpts since status afk)) = object [+ toJSON (UpdateStatus (UpdateStatusOpts since game status afk)) = object [ "op" .= (3 :: Int) , "d" .= object [ "since" .= case since of Nothing -> Nothing Just s -> Just ((10^6) * (utcTimeToPOSIXSeconds s)) , "afk" .= afk , "status" .= statusString status- , "game" .= (Nothing :: Maybe ())- -- todo , "game" .= object [- -- "name" .= game- -- ]+ , "game" .= case game of Nothing -> Nothing+ Just a -> Just $ object [+ "name" .= activityName a+ , "type" .= (fromEnum $ activityType a :: Int)+ , "url" .= activityUrl a+ ] ] ] toJSON (UpdateStatusVoice (UpdateStatusVoiceOpts guild channel mute deaf)) =
src/Discord/Types/Prelude.hs view
@@ -23,9 +23,9 @@ -- | Formats the token for use with the REST API formatAuth :: Auth -> Q.ByteString-formatAuth (Auth token) = TE.encodeUtf8 $ bot <> token- where- bot = if "Bot " `T.isPrefixOf` token then "" else "Bot "+formatAuth (Auth givenTok) = let token = T.strip givenTok+ bot = if "Bot " `T.isPrefixOf` token then "" else "Bot "+ in TE.encodeUtf8 $ bot <> token -- | Get the raw token formatted for use with the websocket gateway authToken :: Auth -> T.Text