From 2f500dc9a039902f6cdc58702cc704cd9dd83323 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Tue, 1 Feb 2022 23:21:49 +0100 Subject: [PATCH] Fix library warnings and compilation errors --- examples/EchoBot.hs | 20 +++++++++++--------- examples/GameBot.hs | 10 +++++++++- examples/TodoBot.hs | 1 - src/Telegram/Bot/API/Chat.hs | 2 -- src/Telegram/Bot/API/MakingRequests.hs | 1 - src/Telegram/Bot/API/Types.hs | 2 +- src/Telegram/Bot/Simple/Debug.hs | 1 - src/Telegram/Bot/Simple/Reply.hs | 13 ++++++++++--- src/Telegram/Bot/Simple/UpdateParser.hs | 1 - 9 files changed, 31 insertions(+), 20 deletions(-) diff --git a/examples/EchoBot.hs b/examples/EchoBot.hs index 645fae5..f1d7383 100644 --- a/examples/EchoBot.hs +++ b/examples/EchoBot.hs @@ -44,15 +44,17 @@ updateToAction update _ handleAction :: Action -> Model -> Eff Action Model handleAction action model = case action of InlineEcho queryId msg -> model <# do - _ <- liftClientM ( - answerInlineQuery ( - AnswerInlineQueryRequest - queryId - [ - InlineQueryResult InlineQueryResultArticle (InlineQueryResultId msg) (Just msg) (Just (defaultInputTextMessageContent msg)) - ] - ) - ) + let result = InlineQueryResult InlineQueryResultArticle (InlineQueryResultId msg) (Just msg) (Just (defaultInputTextMessageContent msg)) + answerInlineQueryRequest = AnswerInlineQueryRequest + { answerInlineQueryRequestInlineQueryId = queryId + , answerInlineQueryRequestResults = [result] + , answerInlineQueryCacheTime = Nothing + , answerInlineQueryIsPersonal = Nothing + , answerInlineQueryNextOffset = Nothing + , answerInlineQuerySwitchPmText = Nothing + , answerInlineQuerySwitchPmParameter = Nothing + } + _ <- liftClientM (answerInlineQuery answerInlineQueryRequest) return () StickerEcho file chat -> model <# do _ <- liftClientM diff --git a/examples/GameBot.hs b/examples/GameBot.hs index ffc1d72..f6feeba 100644 --- a/examples/GameBot.hs +++ b/examples/GameBot.hs @@ -108,7 +108,15 @@ handleAction BotSettings{..} action model = case action of (Just msg) (Just gameMsg) gameMsg = (defaultInputTextMessageContent gameMessageText) { inputMessageContentParseMode = Just "HTML" } - answerInlineQueryRequest = AnswerInlineQueryRequest queryId [inlineQueryResult] + answerInlineQueryRequest = AnswerInlineQueryRequest + { answerInlineQueryRequestInlineQueryId = queryId + , answerInlineQueryRequestResults = [inlineQueryResult] + , answerInlineQueryCacheTime = Nothing + , answerInlineQueryIsPersonal = Nothing + , answerInlineQueryNextOffset = Nothing + , answerInlineQuerySwitchPmText = Nothing + , answerInlineQuerySwitchPmParameter = Nothing + } _ <- liftClientM (answerInlineQuery answerInlineQueryRequest) return () diff --git a/examples/TodoBot.hs b/examples/TodoBot.hs index 2e63dd8..ed13acb 100644 --- a/examples/TodoBot.hs +++ b/examples/TodoBot.hs @@ -2,7 +2,6 @@ module Main where import Control.Applicative -import Data.Monoid import Data.Text (Text) import qualified Data.Text as Text import Data.HashMap.Strict (HashMap) diff --git a/src/Telegram/Bot/API/Chat.hs b/src/Telegram/Bot/API/Chat.hs index 2c562e1..45fa78d 100644 --- a/src/Telegram/Bot/API/Chat.hs +++ b/src/Telegram/Bot/API/Chat.hs @@ -3,12 +3,10 @@ {-# LANGUAGE TypeOperators #-} module Telegram.Bot.API.Chat where -import Data.Coerce (coerce) import Data.Proxy import Servant.API import Servant.Client hiding (Response) -import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types diff --git a/src/Telegram/Bot/API/MakingRequests.hs b/src/Telegram/Bot/API/MakingRequests.hs index c5e05ba..b1ac4d8 100644 --- a/src/Telegram/Bot/API/MakingRequests.hs +++ b/src/Telegram/Bot/API/MakingRequests.hs @@ -4,7 +4,6 @@ module Telegram.Bot.API.MakingRequests where import Data.Aeson (FromJSON (..), ToJSON (..)) -import Data.Monoid ((<>)) import Data.String (IsString) import Data.Text (Text) import qualified Data.Text as Text diff --git a/src/Telegram/Bot/API/Types.hs b/src/Telegram/Bot/API/Types.hs index 21009f5..3481f8e 100644 --- a/src/Telegram/Bot/API/Types.hs +++ b/src/Telegram/Bot/API/Types.hs @@ -1058,7 +1058,7 @@ instance ToJSON SomeChatId where toJSON = genericSomeToJSON instance FromJSON SomeChatId where parseJSON = genericSomeParseJSON instance ToHttpApiData SomeChatId where - toUrlPiece (SomeChatId id) = toUrlPiece id + toUrlPiece (SomeChatId chatid) = toUrlPiece chatid toUrlPiece (SomeChatUsername name) = name -- | This object represents a bot command. diff --git a/src/Telegram/Bot/Simple/Debug.hs b/src/Telegram/Bot/Simple/Debug.hs index 5ad6cfe..1950ef0 100644 --- a/src/Telegram/Bot/Simple/Debug.hs +++ b/src/Telegram/Bot/Simple/Debug.hs @@ -5,7 +5,6 @@ import Control.Monad.Trans (liftIO) import Control.Monad.Writer (tell) import Data.Aeson (ToJSON) import qualified Data.Aeson.Encode.Pretty as Aeson -import Data.Monoid ((<>)) import qualified Data.Text.Lazy as Text import qualified Data.Text.Lazy.Encoding as Text import Debug.Trace (trace) diff --git a/src/Telegram/Bot/Simple/Reply.hs b/src/Telegram/Bot/Simple/Reply.hs index d720203..7da54b7 100644 --- a/src/Telegram/Bot/Simple/Reply.hs +++ b/src/Telegram/Bot/Simple/Reply.hs @@ -8,7 +8,8 @@ import Data.String import Data.Text (Text) import GHC.Generics (Generic) -import Telegram.Bot.API as Telegram +import Telegram.Bot.API as Telegram hiding (editMessageText, editMessageReplyMarkup) +import qualified Telegram.Bot.API.UpdatingMessages as Update import Telegram.Bot.Simple.Eff -- | Get current 'ChatId' if possible. @@ -37,9 +38,11 @@ updateEditMessageId update data ReplyMessage = ReplyMessage { replyMessageText :: Text -- ^ Text of the message to be sent. , replyMessageParseMode :: Maybe ParseMode -- ^ Send 'Markdown' or 'HTML', if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. + , replyMessageEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in message text, which can be specified instead of /parse_mode/. , replyMessageDisableWebPagePreview :: Maybe Bool -- ^ Disables link previews for links in this message. , replyMessageDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound. , replyMessageReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message. + , replyMessageAllowSendingWithoutReply :: Maybe Bool -- ^ Pass 'True', if the message should be sent even if the specified replied-to message is not found. , replyMessageReplyMarkup :: Maybe SomeReplyMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. } deriving (Generic) @@ -48,17 +51,20 @@ instance IsString ReplyMessage where -- | Create a 'ReplyMessage' with just some 'Text' message. toReplyMessage :: Text -> ReplyMessage -toReplyMessage text = ReplyMessage text Nothing Nothing Nothing Nothing Nothing +toReplyMessage text + = ReplyMessage text Nothing Nothing Nothing Nothing Nothing Nothing Nothing replyMessageToSendMessageRequest :: SomeChatId -> ReplyMessage -> SendMessageRequest replyMessageToSendMessageRequest someChatId ReplyMessage{..} = SendMessageRequest { sendMessageChatId = someChatId , sendMessageText = replyMessageText , sendMessageParseMode = replyMessageParseMode + , sendMessageEntities = replyMessageEntities , sendMessageDisableWebPagePreview = replyMessageDisableWebPagePreview , sendMessageDisableNotification = replyMessageDisableNotification , sendMessageReplyToMessageId = replyMessageReplyToMessageId , sendMessageReplyMarkup = replyMessageReplyMarkup + , sendMessageAllowSendingWithoutReply = replyMessageAllowSendingWithoutReply } -- | Reply in a chat with a given 'SomeChatId'. @@ -104,6 +110,7 @@ editMessageToEditMessageTextRequest editMessageId EditMessage{..} , editMessageTextParseMode = editMessageParseMode , editMessageTextDisableWebPagePreview = editMessageDisableWebPagePreview , editMessageTextReplyMarkup = editMessageReplyMarkup + , editMessageEntities = Nothing , .. } where @@ -126,7 +133,7 @@ editMessageToReplyMessage EditMessage{..} = (toReplyMessage editMessageText) editMessage :: EditMessageId -> EditMessage -> BotM () editMessage editMessageId emsg = do let msg = editMessageToEditMessageTextRequest editMessageId emsg - void $ liftClientM $ Telegram.editMessageText msg + void $ liftClientM $ Update.editMessageText msg editUpdateMessage :: EditMessage -> BotM () editUpdateMessage emsg = do diff --git a/src/Telegram/Bot/Simple/UpdateParser.hs b/src/Telegram/Bot/Simple/UpdateParser.hs index 54bba6e..7aa85a3 100644 --- a/src/Telegram/Bot/Simple/UpdateParser.hs +++ b/src/Telegram/Bot/Simple/UpdateParser.hs @@ -5,7 +5,6 @@ module Telegram.Bot.Simple.UpdateParser where import Control.Applicative import Control.Monad.Reader -import Data.Monoid ((<>)) import Data.Text (Text) import qualified Data.Text as Text import Text.Read (readMaybe)