packages feed

telegram-bot-simple 0.3.6 → 0.3.7

raw patch · 8 files changed

+228/−11 lines, 8 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Telegram.Bot.API.GettingUpdates: [updateInlineQuery] :: Update -> Maybe InlineQuery
+ Telegram.Bot.API.InlineMode: AnswerInlineQueryRequest :: InlineQueryId -> [InlineQueryResult] -> AnswerInlineQueryRequest
+ Telegram.Bot.API.InlineMode: InlineQuery :: InlineQueryId -> User -> Maybe Location -> Text -> Text -> InlineQuery
+ Telegram.Bot.API.InlineMode: InlineQueryId :: Text -> InlineQueryId
+ Telegram.Bot.API.InlineMode: [answerInlineQueryRequestInlineQueryId] :: AnswerInlineQueryRequest -> InlineQueryId
+ Telegram.Bot.API.InlineMode: [answerInlineQueryRequestResults] :: AnswerInlineQueryRequest -> [InlineQueryResult]
+ Telegram.Bot.API.InlineMode: [inlineQueryFrom] :: InlineQuery -> User
+ Telegram.Bot.API.InlineMode: [inlineQueryId] :: InlineQuery -> InlineQueryId
+ Telegram.Bot.API.InlineMode: [inlineQueryLocation] :: InlineQuery -> Maybe Location
+ Telegram.Bot.API.InlineMode: [inlineQueryOffset] :: InlineQuery -> Text
+ Telegram.Bot.API.InlineMode: [inlineQueryQuery] :: InlineQuery -> Text
+ Telegram.Bot.API.InlineMode: answerInlineQuery :: AnswerInlineQueryRequest -> ClientM (Response Bool)
+ Telegram.Bot.API.InlineMode: data AnswerInlineQueryRequest
+ Telegram.Bot.API.InlineMode: data InlineQuery
+ Telegram.Bot.API.InlineMode: instance Data.Aeson.Types.FromJSON.FromJSON Telegram.Bot.API.InlineMode.AnswerInlineQueryRequest
+ Telegram.Bot.API.InlineMode: instance Data.Aeson.Types.FromJSON.FromJSON Telegram.Bot.API.InlineMode.InlineQuery
+ Telegram.Bot.API.InlineMode: instance Data.Aeson.Types.FromJSON.FromJSON Telegram.Bot.API.InlineMode.InlineQueryId
+ Telegram.Bot.API.InlineMode: instance Data.Aeson.Types.ToJSON.ToJSON Telegram.Bot.API.InlineMode.AnswerInlineQueryRequest
+ Telegram.Bot.API.InlineMode: instance Data.Aeson.Types.ToJSON.ToJSON Telegram.Bot.API.InlineMode.InlineQuery
+ Telegram.Bot.API.InlineMode: instance Data.Aeson.Types.ToJSON.ToJSON Telegram.Bot.API.InlineMode.InlineQueryId
+ Telegram.Bot.API.InlineMode: instance Data.Hashable.Class.Hashable Telegram.Bot.API.InlineMode.InlineQueryId
+ Telegram.Bot.API.InlineMode: instance GHC.Classes.Eq Telegram.Bot.API.InlineMode.InlineQueryId
+ Telegram.Bot.API.InlineMode: instance GHC.Generics.Generic Telegram.Bot.API.InlineMode.AnswerInlineQueryRequest
+ Telegram.Bot.API.InlineMode: instance GHC.Generics.Generic Telegram.Bot.API.InlineMode.InlineQuery
+ Telegram.Bot.API.InlineMode: instance GHC.Generics.Generic Telegram.Bot.API.InlineMode.InlineQueryId
+ Telegram.Bot.API.InlineMode: instance GHC.Show.Show Telegram.Bot.API.InlineMode.InlineQuery
+ Telegram.Bot.API.InlineMode: instance GHC.Show.Show Telegram.Bot.API.InlineMode.InlineQueryId
+ Telegram.Bot.API.InlineMode: newtype InlineQueryId
+ Telegram.Bot.API.InlineMode: type AnswerInlineQuery = "answerInlineQuery" :> ReqBody '[JSON] AnswerInlineQueryRequest :> Post '[JSON] (Response Bool)
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResult :: InlineQueryResultType -> InlineQueryResultId -> Maybe Text -> Maybe InputMessageContent -> InlineQueryResult
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultArticle :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultAudio :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedAudio :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedDocument :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedGif :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedMpeg4Gif :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedPhoto :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedSticker :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedVideo :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultCachedVoice :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultContact :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultDocument :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultGame :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultGif :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultId :: Text -> InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultLocation :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultMpeg4Gif :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultPhoto :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultVenue :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultVideo :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: InlineQueryResultVoice :: InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: [inlineQueryResultId] :: InlineQueryResult -> InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: [inlineQueryResultInputMessageContent] :: InlineQueryResult -> Maybe InputMessageContent
+ Telegram.Bot.API.InlineMode.InlineQueryResult: [inlineQueryResultTitle] :: InlineQueryResult -> Maybe Text
+ Telegram.Bot.API.InlineMode.InlineQueryResult: [inlineQueryResultType] :: InlineQueryResult -> InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: data InlineQueryResult
+ Telegram.Bot.API.InlineMode.InlineQueryResult: data InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: getType :: InlineQueryResultType -> Text
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance Data.Aeson.Types.FromJSON.FromJSON Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResult
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance Data.Aeson.Types.FromJSON.FromJSON Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance Data.Aeson.Types.FromJSON.FromJSON Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance Data.Aeson.Types.ToJSON.ToJSON Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResult
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance Data.Aeson.Types.ToJSON.ToJSON Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance Data.Aeson.Types.ToJSON.ToJSON Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance Data.Hashable.Class.Hashable Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Classes.Eq Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Classes.Eq Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Generics.Generic Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResult
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Generics.Generic Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Generics.Generic Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Show.Show Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResult
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Show.Show Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InlineQueryResult: instance GHC.Show.Show Telegram.Bot.API.InlineMode.InlineQueryResult.InlineQueryResultType
+ Telegram.Bot.API.InlineMode.InlineQueryResult: newtype InlineQueryResultId
+ Telegram.Bot.API.InlineMode.InputMessageContent: InputContactMessageContent :: Text -> Text -> Maybe Text -> Maybe Text -> InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: InputLocationMessageContent :: Float -> Float -> Maybe Float -> Maybe Integer -> Maybe Integer -> Maybe Integer -> InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: InputTextMessageContent :: Text -> Maybe Text -> Maybe Bool -> InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: InputVenueMessageContent :: Float -> Float -> Text -> Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentAddress] :: InputMessageContent -> Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentDisableWebPagePrefiew] :: InputMessageContent -> Maybe Bool
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentFirstName] :: InputMessageContent -> Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentFoursquareId] :: InputMessageContent -> Maybe Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentFoursquareType] :: InputMessageContent -> Maybe Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentGooglePlaceId] :: InputMessageContent -> Maybe Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentGooglePlaceType] :: InputMessageContent -> Maybe Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentHeading] :: InputMessageContent -> Maybe Integer
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentHorizontalAccuracy] :: InputMessageContent -> Maybe Float
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentLatitude] :: InputMessageContent -> Float
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentLivePeriod] :: InputMessageContent -> Maybe Integer
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentLongitude] :: InputMessageContent -> Float
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentMessageText] :: InputMessageContent -> Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentParseMode] :: InputMessageContent -> Maybe Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentPhoneNumber] :: InputMessageContent -> Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentProximityAlertRadius] :: InputMessageContent -> Maybe Integer
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentSecondName] :: InputMessageContent -> Maybe Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentTitle] :: InputMessageContent -> Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: [inputMessageContentVcard] :: InputMessageContent -> Maybe Text
+ Telegram.Bot.API.InlineMode.InputMessageContent: data InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: defaultInputLocationMessageContent :: Float -> Float -> InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: defaultInputTextMessageContent :: Text -> InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: instance Data.Aeson.Types.FromJSON.FromJSON Telegram.Bot.API.InlineMode.InputMessageContent.InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: instance Data.Aeson.Types.ToJSON.ToJSON Telegram.Bot.API.InlineMode.InputMessageContent.InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: instance GHC.Generics.Generic Telegram.Bot.API.InlineMode.InputMessageContent.InputMessageContent
+ Telegram.Bot.API.InlineMode.InputMessageContent: instance GHC.Show.Show Telegram.Bot.API.InlineMode.InputMessageContent.InputMessageContent
- Telegram.Bot.API.GettingUpdates: Update :: UpdateId -> Maybe Message -> Maybe Message -> Maybe Message -> Maybe Message -> Maybe CallbackQuery -> Update
+ Telegram.Bot.API.GettingUpdates: Update :: UpdateId -> Maybe Message -> Maybe Message -> Maybe Message -> Maybe Message -> Maybe InlineQuery -> Maybe CallbackQuery -> Update

Files

CHANGELOG.md view
@@ -1,8 +1,14 @@+0.3.7+---++- Add inline mode support (see [#45](https://github.com/fizruk/telegram-bot-simple/pull/45));+ 0.3.6 --- -- Remove extra spaces, restore Tested-with (see [#48]( https://github.com/fizruk/telegram-bot-simple/pull/48 ));+- Remove extra spaces, restore Tested-with (see [#48](https://github.com/fizruk/telegram-bot-simple/pull/48)); - Add support of ghc 9 (see [#47]( https://github.com/fizruk/telegram-bot-simple/pull/47 ));+ 0.3.5 --- 
examples/EchoBot.hs view
@@ -3,15 +3,19 @@  import           Data.Text                        (Text) import qualified Data.Text                        as Text+import           Data.Maybe  import           Telegram.Bot.API import           Telegram.Bot.Simple import           Telegram.Bot.Simple.UpdateParser (updateMessageText)+import           Telegram.Bot.API.InlineMode.InlineQueryResult+import           Telegram.Bot.API.InlineMode.InputMessageContent (defaultInputTextMessageContent)  type Model = ()  data Action   = NoOp+  | InlineEcho InlineQueryId Text   | Echo Text  echoBot :: BotApp Model Action@@ -23,14 +27,30 @@   }  updateToAction :: Update -> Model -> Maybe Action-updateToAction update _ =-  case updateMessageText update of-    Just text -> Just (Echo text)-    Nothing   -> Nothing+updateToAction update _+  | isJust $ updateInlineQuery update =  do+      query <- updateInlineQuery update+      let queryId = inlineQueryId query+      let msg =  inlineQueryQuery query+      Just $ InlineEcho queryId msg+  | otherwise = case updateMessageText update of+      Just text -> Just (Echo text)+      Nothing   -> Nothing  handleAction :: Action -> Model -> Eff Action Model handleAction action model = case action of   NoOp -> pure model+  InlineEcho queryId msg -> model <# do+    _ <- liftClientM (+      answerInlineQuery (+          AnswerInlineQueryRequest+            queryId+            [+              InlineQueryResult InlineQueryResultArticle (InlineQueryResultId msg) (Just msg) (Just (defaultInputTextMessageContent msg))+            ]+        )+      )+    return NoOp   Echo msg -> model <# do     replyText msg     return NoOp@@ -38,7 +58,7 @@ run :: Token -> IO () run token = do   env <- defaultTelegramClientEnv token-  startBot_ (conversationBot updateChatId echoBot) env+  startBot_ echoBot env  main :: IO () main = do
src/Telegram/Bot/API.hs view
@@ -11,8 +11,8 @@   module Telegram.Bot.API.UpdatingMessages, --   -- * Stickers --   module Telegram.Bot.API.Stickers,---   -- * Inline mode---   module Telegram.Bot.API.InlineMode,+  -- * Inline mode+  module Telegram.Bot.API.InlineMode, --   -- * Payments --   module Telegram.Bot.API.Payments, --   -- * Games@@ -25,6 +25,6 @@ import           Telegram.Bot.API.Types import           Telegram.Bot.API.UpdatingMessages -- import Telegram.Bot.API.Stickers--- import Telegram.Bot.API.InlineMode+import Telegram.Bot.API.InlineMode -- import Telegram.Bot.API.Payments -- import Telegram.Bot.API.Games
src/Telegram/Bot/API/GettingUpdates.hs view
@@ -18,6 +18,7 @@ import           Telegram.Bot.API.Internal.Utils import           Telegram.Bot.API.MakingRequests import           Telegram.Bot.API.Types+import           Telegram.Bot.API.InlineMode  -- ** 'Update' @@ -33,7 +34,7 @@   , updateChannelPost       :: Maybe Message -- ^ New incoming channel post of any kind — text, photo, sticker, etc.   , updateEditedChannelPost :: Maybe Message -- ^ New version of a channel post that is known to the bot and was edited ---  , updateInlineQuery :: Maybe InlineQuery -- ^ New incoming inline query+  , updateInlineQuery :: Maybe InlineQuery -- ^ New incoming inline query --   , updateChosenInlineResult :: Maybe ChosenInlineResult -- ^ The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.    , updateCallbackQuery     :: Maybe CallbackQuery -- ^ New incoming callback query
src/Telegram/Bot/API/InlineMode.hs view
@@ -1,1 +1,60 @@+{-# LANGUAGE DataKinds                  #-}+{-# LANGUAGE DeriveGeneric              #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings          #-}+{-# LANGUAGE TemplateHaskell            #-}+{-# LANGUAGE TypeApplications           #-}+{-# LANGUAGE TypeOperators              #-} module Telegram.Bot.API.InlineMode where++import           Data.Aeson                      (FromJSON (..), ToJSON (..))+import           Data.Hashable                   (Hashable)+import           Data.Proxy+import           Data.Text                       (Text)+import           GHC.Generics                    (Generic)++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.InlineMode.InlineQueryResult++-- * Available types+-- ** User+--+-- | This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.+--+-- <https://core.telegram.org/bots/api#inline-mode>+data InlineQuery = InlineQuery+  { inlineQueryId       :: InlineQueryId -- ^ Unique query identifier+  , inlineQueryFrom     :: User -- ^ Sender+  , inlineQueryLocation :: Maybe Location -- ^ For bots that require user location, sender location+  , inlineQueryQuery    :: Text -- ^ Text of the query, up to 256 characters+  , inlineQueryOffset   :: Text -- ^ Offset of the results to be returned, can be controlled by bot+  } deriving (Generic, Show)++-- | Unique identifier for this query+newtype InlineQueryId = InlineQueryId Text+  deriving (Eq, Show, ToJSON, FromJSON, Hashable, Generic)++-- * Available methods++-- ** answerInlineQuery++type AnswerInlineQuery+  = "answerInlineQuery" :> ReqBody '[JSON] AnswerInlineQueryRequest :> Post '[JSON] (Response Bool)++answerInlineQuery :: AnswerInlineQueryRequest -> ClientM (Response Bool)+answerInlineQuery = client (Proxy @AnswerInlineQuery)++data AnswerInlineQueryRequest = AnswerInlineQueryRequest+  { answerInlineQueryRequestInlineQueryId :: InlineQueryId+  , answerInlineQueryRequestResults       :: [InlineQueryResult]+  } deriving (Generic)++instance ToJSON AnswerInlineQueryRequest where toJSON = gtoJSON+instance FromJSON AnswerInlineQueryRequest where parseJSON = gparseJSON++deriveJSON' ''InlineQuery
+ src/Telegram/Bot/API/InlineMode/InlineQueryResult.hs view
@@ -0,0 +1,78 @@+{-# LANGUAGE DeriveGeneric              #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings          #-}+module Telegram.Bot.API.InlineMode.InlineQueryResult where++import           Data.Aeson                      (FromJSON (..), ToJSON (..), Value (String))+import           Data.Hashable                   (Hashable)+import           Data.Text                       (Text)+import           GHC.Generics                    (Generic)++import           Telegram.Bot.API.Internal.Utils+import           Telegram.Bot.API.InlineMode.InputMessageContent++-- | This object represents one result of an inline query+data InlineQueryResult = InlineQueryResult+  { inlineQueryResultType     :: InlineQueryResultType -- ^ Type of the result+  , inlineQueryResultId :: InlineQueryResultId -- ^ Unique identifier for this result, 1-64 Bytes+  , inlineQueryResultTitle :: Maybe Text -- ^ Title of the result (only valid for "Article", "Photo", "Gif", "Mpeg4Gif", "Video", "Audio", "Voice", "Document", "Location", "Venue", "CachedPhoto", "CachedGif", "CachedMpeg4Gif", "CachedDocument", "CachedVideo", "CachedVoice" types of results)+  , inlineQueryResultInputMessageContent :: Maybe InputMessageContent+--  , inlineQueryResultContact  :: Maybe Contact+  } deriving (Generic, Show)++newtype InlineQueryResultId = InlineQueryResultId Text+  deriving (Eq, Show, Generic, ToJSON, FromJSON, Hashable)++instance ToJSON InlineQueryResult where toJSON = gtoJSON+instance FromJSON InlineQueryResult where parseJSON = gparseJSON++-- | Type of inline query result+data InlineQueryResultType+  = InlineQueryResultCachedAudio+  | InlineQueryResultCachedDocument+  | InlineQueryResultCachedGif+  | InlineQueryResultCachedMpeg4Gif+  | InlineQueryResultCachedPhoto+  | InlineQueryResultCachedSticker+  | InlineQueryResultCachedVideo+  | InlineQueryResultCachedVoice+  | InlineQueryResultArticle+  | InlineQueryResultAudio+  | InlineQueryResultContact+  | InlineQueryResultGame+  | InlineQueryResultDocument+  | InlineQueryResultGif+  | InlineQueryResultLocation+  | InlineQueryResultMpeg4Gif+  | InlineQueryResultPhoto+  | InlineQueryResultVenue+  | InlineQueryResultVideo+  | InlineQueryResultVoice+  deriving (Eq, Show, Generic)++getType :: InlineQueryResultType -> Text+getType InlineQueryResultCachedAudio = "audio"+getType InlineQueryResultCachedDocument = "document"+getType InlineQueryResultCachedGif = "gif"+getType InlineQueryResultCachedMpeg4Gif = "mpeg4_gif"+getType InlineQueryResultCachedPhoto = "photo"+getType InlineQueryResultCachedSticker = "sticker"+getType InlineQueryResultCachedVideo = "video"+getType InlineQueryResultCachedVoice = "voice"+getType InlineQueryResultArticle = "article"+getType InlineQueryResultAudio = "audio"+getType InlineQueryResultContact = "contact"+getType InlineQueryResultGame = "game"+getType InlineQueryResultDocument = "document"+getType InlineQueryResultGif = "gif"+getType InlineQueryResultLocation = "location"+getType InlineQueryResultMpeg4Gif = "mpeg4_gif"+getType InlineQueryResultPhoto = "photo"+getType InlineQueryResultVenue = "venue"+getType InlineQueryResultVideo = "video"+getType InlineQueryResultVoice = "voice"++instance ToJSON InlineQueryResultType where+  toJSON = String . getType++instance FromJSON InlineQueryResultType where parseJSON = gparseJSON
+ src/Telegram/Bot/API/InlineMode/InputMessageContent.hs view
@@ -0,0 +1,51 @@+{-# LANGUAGE DeriveGeneric              #-}+module Telegram.Bot.API.InlineMode.InputMessageContent (InputMessageContent(..), defaultInputTextMessageContent, defaultInputLocationMessageContent) where++import           Data.Aeson                      (FromJSON (..), ToJSON (..))+import           Data.Text                       (Text)+import           GHC.Generics                    (Generic)++import           Telegram.Bot.API.Internal.Utils++-- | Represents the content of a text message to be sent as the result of an inline query.+data InputMessageContent =+  InputTextMessageContent -- ^ Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent) of a text message to be sent as the result of an inline query.+  { inputMessageContentMessageText :: Text -- ^ Text of the message to be sent, 1-4096 characters+  , inputMessageContentParseMode :: Maybe Text -- ^ Mode for parsing entities in the message text. See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details.+  , inputMessageContentDisableWebPagePrefiew :: Maybe Bool -- ^ Disables link previews for links in the sent message+  }+  | InputLocationMessageContent                                      -- ^ Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent) of a location message to be sent as the result of an inline query.+  { inputMessageContentLatitude :: Float                     -- ^ Latitude of the location in degrees+  , inputMessageContentLongitude :: Float                    -- ^ Longitude of the location in degrees+  , inputMessageContentHorizontalAccuracy :: Maybe Float     -- ^ The radius of uncertainty for the location, measured in meters; 0-1500+  , inputMessageContentLivePeriod :: Maybe Integer           -- ^ Period in seconds for which the location can be updated, should be between 60 and 86400.+  , inputMessageContentHeading :: Maybe Integer              -- ^ For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.+  , inputMessageContentProximityAlertRadius :: Maybe Integer -- ^ For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.+  }+  | InputVenueMessageContent                              -- ^ Represents the content of a [venue](https://core.telegram.org/bots/api#inputmessagecontent) message to be sent as the result of an inline query.+  { inputMessageContentLatitude :: Float             -- ^ Latitude of the venue in degrees+  , inputMessageContentLongitude :: Float            -- ^ Longitude of the venue in degrees+  , inputMessageContentTitle :: Text                 -- ^ Name of the venue+  , inputMessageContentAddress :: Text               -- ^ Address of the venue+  , inputMessageContentFoursquareId :: Maybe Text    -- ^ Foursquare identifier of the venue, if known+  , inputMessageContentFoursquareType :: Maybe Text  -- ^ Foursquare type of the venue, if known. (For example, “arts_entertainment\/default”, “arts_entertainment\/aquarium” or “food\/icecream”.)+  , inputMessageContentGooglePlaceId :: Maybe Text   -- ^ Google Places identifier of the venue+  , inputMessageContentGooglePlaceType :: Maybe Text -- ^ Google Places type of the venue. (See [supported types](https://developers.google.com/places/web-service/supported_types).)+  }+  | InputContactMessageContent                         -- ^ Represents the [content](https://core.telegram.org/bots/api#inputmessagecontent) of a contact message to be sent as the result of an inline query.+  { inputMessageContentPhoneNumber :: Text      -- ^ Contact's phone number+  , inputMessageContentFirstName :: Text        -- ^ Contact's first name+  , inputMessageContentSecondName :: Maybe Text -- ^ Contact's last name+  , inputMessageContentVcard :: Maybe Text      -- ^ Additional data about the contact in the form of a [vCard](https://en.wikipedia.org/wiki/VCard), 0-2048 bytes+  } deriving (Generic, Show)++-- ** Helper functions to easily construct 'InputMessageContent'++defaultInputTextMessageContent :: Text -> InputMessageContent+defaultInputTextMessageContent text = InputTextMessageContent text Nothing Nothing++defaultInputLocationMessageContent :: Float -> Float -> InputMessageContent+defaultInputLocationMessageContent lat long = InputLocationMessageContent lat long Nothing Nothing Nothing Nothing ++instance ToJSON InputMessageContent where toJSON = gtoJSON+instance FromJSON InputMessageContent where parseJSON = gparseJSON
telegram-bot-simple.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           telegram-bot-simple-version:        0.3.6+version:        0.3.7 synopsis:       Easy to use library for building Telegram bots. description:    Please see the README on Github at <https://github.com/fizruk/telegram-bot-simple#readme> category:       Web@@ -33,6 +33,8 @@       Telegram.Bot.API.Games       Telegram.Bot.API.GettingUpdates       Telegram.Bot.API.InlineMode+      Telegram.Bot.API.InlineMode.InlineQueryResult+      Telegram.Bot.API.InlineMode.InputMessageContent       Telegram.Bot.API.Internal.Utils       Telegram.Bot.API.MakingRequests       Telegram.Bot.API.Methods