-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from Seteh/feature/my-descriptions
[gs]etMy(Short)?Description support.
- Loading branch information
Showing
10 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
telegram-bot-api/src/Telegram/Bot/API/Methods/GetMyDescription.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
module Telegram.Bot.API.Methods.GetMyDescription where | ||
|
||
import Data.Aeson (FromJSON (..), ToJSON (..)) | ||
import Data.Proxy | ||
import GHC.Generics (Generic) | ||
import Data.Text (Text) | ||
import Servant.API | ||
import Servant.Client hiding (Response) | ||
|
||
import Telegram.Bot.API.Internal.Utils | ||
import Telegram.Bot.API.MakingRequests | ||
import Telegram.Bot.API.Types | ||
import Telegram.Bot.API.Internal.TH | ||
|
||
-- ** 'GetMyDescription' | ||
|
||
newtype GetMyDescriptionRequest = GetMyDescriptionRequest | ||
{ getMyDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code or an empty string. | ||
} | ||
deriving Generic | ||
|
||
instance ToJSON GetMyDescriptionRequest where toJSON = gtoJSON | ||
instance FromJSON GetMyDescriptionRequest where parseJSON = gparseJSON | ||
|
||
type GetMyDescription = "getMyDescription" | ||
:> ReqBody '[JSON] GetMyDescriptionRequest | ||
:> Post '[JSON] (Response BotDescription) | ||
|
||
-- | Use this method to get the current bot description for the given user language. | ||
-- Returns 'BotDescription' on success. | ||
getMyDescription :: GetMyDescriptionRequest -> ClientM (Response BotDescription) | ||
getMyDescription = client (Proxy @GetMyDescription) | ||
|
||
makeDefault ''GetMyDescriptionRequest |
38 changes: 38 additions & 0 deletions
38
telegram-bot-api/src/Telegram/Bot/API/Methods/GetMyShortDescription.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
module Telegram.Bot.API.Methods.GetMyShortDescription where | ||
|
||
import Data.Aeson (FromJSON (..), ToJSON (..)) | ||
import Data.Proxy | ||
import GHC.Generics (Generic) | ||
import Data.Text (Text) | ||
import Servant.API | ||
import Servant.Client hiding (Response) | ||
|
||
import Telegram.Bot.API.Internal.Utils | ||
import Telegram.Bot.API.MakingRequests | ||
import Telegram.Bot.API.Types | ||
import Telegram.Bot.API.Internal.TH | ||
|
||
-- ** 'GetMyShortDescription' | ||
|
||
newtype GetMyShortDescriptionRequest = GetMyShortDescriptionRequest | ||
{ getMyShortDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code or an empty string. | ||
} | ||
deriving Generic | ||
|
||
instance ToJSON GetMyShortDescriptionRequest where toJSON = gtoJSON | ||
instance FromJSON GetMyShortDescriptionRequest where parseJSON = gparseJSON | ||
|
||
type GetMyShortDescription = "getMyShortDescription" | ||
:> ReqBody '[JSON] GetMyShortDescriptionRequest | ||
:> Post '[JSON] (Response BotShortDescription) | ||
|
||
-- | Use this method to get the current bot short description for the given user language. | ||
-- Returns 'BotShortDescription' on success. | ||
getMyShortDescription :: GetMyShortDescriptionRequest -> ClientM (Response BotShortDescription) | ||
getMyShortDescription = client (Proxy @GetMyShortDescription) | ||
|
||
makeDefault ''GetMyShortDescriptionRequest |
39 changes: 39 additions & 0 deletions
39
telegram-bot-api/src/Telegram/Bot/API/Methods/SetMyDescription.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
module Telegram.Bot.API.Methods.SetMyDescription where | ||
|
||
import Data.Aeson (FromJSON (..), ToJSON (..)) | ||
import Data.Proxy | ||
import GHC.Generics (Generic) | ||
import Data.Text (Text) | ||
import Servant.API | ||
import Servant.Client hiding (Response) | ||
|
||
import Telegram.Bot.API.Internal.Utils | ||
import Telegram.Bot.API.MakingRequests | ||
import Telegram.Bot.API.Internal.TH | ||
|
||
-- ** 'setMyDescription' | ||
|
||
data SetMyDescriptionRequest = SetMyDescriptionRequest | ||
{ setMyDescriptionDescription :: Maybe Text -- ^ New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. | ||
, setMyDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. | ||
} | ||
deriving Generic | ||
|
||
instance ToJSON SetMyDescriptionRequest where toJSON = gtoJSON | ||
instance FromJSON SetMyDescriptionRequest where parseJSON = gparseJSON | ||
|
||
type SetMyDescription = "setMyDescription" | ||
:> ReqBody '[JSON] SetMyDescriptionRequest | ||
:> Post '[JSON] (Response Bool) | ||
|
||
-- | Use this method to change the bot's description, | ||
-- which is shown in the chat with the bot if the chat is empty. | ||
-- Returns 'True' on success. | ||
setMyDescription :: SetMyDescriptionRequest -> ClientM (Response Bool) | ||
setMyDescription = client (Proxy @SetMyDescription) | ||
|
||
makeDefault ''SetMyDescriptionRequest |
40 changes: 40 additions & 0 deletions
40
telegram-bot-api/src/Telegram/Bot/API/Methods/SetMyShortDescription.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
module Telegram.Bot.API.Methods.SetMyShortDescription where | ||
|
||
import Data.Aeson (FromJSON (..), ToJSON (..)) | ||
import Data.Proxy | ||
import GHC.Generics (Generic) | ||
import Data.Text (Text) | ||
import Servant.API | ||
import Servant.Client hiding (Response) | ||
|
||
import Telegram.Bot.API.Internal.Utils | ||
import Telegram.Bot.API.MakingRequests | ||
import Telegram.Bot.API.Internal.TH | ||
|
||
-- ** 'setMyShortDescription' | ||
|
||
data SetMyShortDescriptionRequest = SetMyShortDescriptionRequest | ||
{ setMyShortDescriptionDescription :: Maybe Text -- ^ New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language. | ||
, setMyShortDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description. | ||
} | ||
deriving Generic | ||
|
||
instance ToJSON SetMyShortDescriptionRequest where toJSON = gtoJSON | ||
instance FromJSON SetMyShortDescriptionRequest where parseJSON = gparseJSON | ||
|
||
type SetMyShortDescription = "setMyShortDescription" | ||
:> ReqBody '[JSON] SetMyShortDescriptionRequest | ||
:> Post '[JSON] (Response Bool) | ||
|
||
-- | Use this method to change the bot's short description, | ||
-- which is shown on the bot's profile page and | ||
-- is sent together with the link when users share the bot. | ||
-- Returns 'True' on success. | ||
setMyShortDescription :: SetMyShortDescriptionRequest -> ClientM (Response Bool) | ||
setMyShortDescription = client (Proxy @SetMyShortDescription) | ||
|
||
makeDefault ''SetMyShortDescriptionRequest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
telegram-bot-api/src/Telegram/Bot/API/Types/BotDescription.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
module Telegram.Bot.API.Types.BotDescription where | ||
|
||
import Data.Aeson (FromJSON (..), ToJSON (..)) | ||
import Data.Text (Text) | ||
import GHC.Generics (Generic) | ||
import Telegram.Bot.API.Internal.Utils | ||
|
||
-- ** 'BotDescription' | ||
|
||
-- | This object represents the bot's description. | ||
data BotDescription = BotDescription | ||
{ botDescriptionDescription :: Text -- ^ The bot's description. | ||
} | ||
deriving (Generic, Show) | ||
|
||
instance ToJSON BotDescription where toJSON = gtoJSON | ||
instance FromJSON BotDescription where parseJSON = gparseJSON |
18 changes: 18 additions & 0 deletions
18
telegram-bot-api/src/Telegram/Bot/API/Types/BotShortDescription.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
module Telegram.Bot.API.Types.BotShortDescription where | ||
|
||
import Data.Aeson (FromJSON (..), ToJSON (..)) | ||
import Data.Text (Text) | ||
import GHC.Generics (Generic) | ||
import Telegram.Bot.API.Internal.Utils | ||
|
||
-- ** 'BotShortDescription' | ||
|
||
-- | This object represents the bot's short description. | ||
data BotShortDescription = BotShortDescription | ||
{ botShortDescriptionShortDescription :: Text -- ^ The bot's short description. | ||
} | ||
deriving (Generic, Show) | ||
|
||
instance ToJSON BotShortDescription where toJSON = gtoJSON | ||
instance FromJSON BotShortDescription where parseJSON = gparseJSON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters