Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix library warnings and compilation errors #89

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions examples/EchoBot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion examples/GameBot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
1 change: 0 additions & 1 deletion examples/TodoBot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/Telegram/Bot/API/Chat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion src/Telegram/Bot/API/MakingRequests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Bot/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/Telegram/Bot/Simple/Debug.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions src/Telegram/Bot/Simple/Reply.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand All @@ -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'.
Expand Down Expand Up @@ -104,6 +110,7 @@ editMessageToEditMessageTextRequest editMessageId EditMessage{..}
, editMessageTextParseMode = editMessageParseMode
, editMessageTextDisableWebPagePreview = editMessageDisableWebPagePreview
, editMessageTextReplyMarkup = editMessageReplyMarkup
, editMessageEntities = Nothing
, ..
}
where
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Telegram/Bot/Simple/UpdateParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down