From e7bdc852797f7cbb7af9406431b988edaecbcf16 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 7 Feb 2020 00:29:50 +0600 Subject: [PATCH] precomplete of games extensions --- .../requests/games/GetGameHighScoresByChat.kt | 51 +++++++++++++++++++ .../GetGameHighScoresByInlineMessageId.kt | 15 ++++++ .../games/SetGameScoreByInlineMessageId.kt | 21 ++++++++ 3 files changed, 87 insertions(+) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt index d1cd6effd5..ca2f1256ec 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByChat.kt @@ -1,8 +1,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction +import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores import com.github.insanusmokrassar.TelegramBotAPI.types.* +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent import kotlinx.serialization.* @Serializable @@ -17,3 +21,50 @@ data class GetGameHighScoresByChat ( override val requestSerializer: SerializationStrategy<*> get() = serializer() } + + +suspend fun RequestsExecutor.getGameScore( + userId: UserId, + chatId: ChatId, + messageId: MessageIdentifier +) = execute( + GetGameHighScoresByChat(userId, chatId, messageId) +) + +suspend fun RequestsExecutor.getGameScore( + user: CommonUser, + chatId: ChatId, + messageId: MessageIdentifier +) = getGameScore( + user.id, chatId, messageId +) + +suspend fun RequestsExecutor.getGameScore( + userId: UserId, + chat: Chat, + messageId: MessageIdentifier +) = getGameScore( + userId, chat.id, messageId +) + +suspend fun RequestsExecutor.getGameScore( + user: CommonUser, + chat: Chat, + messageId: MessageIdentifier +) = getGameScore( + user.id, chat.id, messageId +) + +suspend fun RequestsExecutor.getGameScore( + userId: UserId, + message: ContentMessage +) = getGameScore( + userId, message.chat.id, message.messageId +) + +suspend fun RequestsExecutor.getGameScore( + user: CommonUser, + message: ContentMessage +) = getGameScore( + user.id, message.chat.id, message.messageId +) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt index 7e35cbce06..c7938b5347 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/GetGameHighScoresByInlineMessageId.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction +import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* @@ -15,3 +16,17 @@ data class GetGameHighScoresByInlineMessageId ( override val requestSerializer: SerializationStrategy<*> get() = serializer() } + +suspend fun RequestsExecutor.getGameScore( + userId: UserId, + inlineMessageId: InlineMessageIdentifier +) = execute( + GetGameHighScoresByInlineMessageId( + userId, inlineMessageId + ) +) + +suspend fun RequestsExecutor.getGameScore( + user: CommonUser, + inlineMessageId: InlineMessageIdentifier +) = getGameScore(user.id, inlineMessageId) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt index 23deee5967..9a6794c826 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/games/SetGameScoreByInlineMessageId.kt @@ -1,6 +1,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.games import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction +import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore import com.github.insanusmokrassar.TelegramBotAPI.types.* import kotlinx.serialization.* @@ -21,3 +22,23 @@ data class SetGameScoreByInlineMessageId ( override val requestSerializer: SerializationStrategy<*> get() = serializer() } + +suspend fun RequestsExecutor.setGameScore( + userId: UserId, + score: Long, + inlineMessageId: InlineMessageIdentifier, + force: Boolean = false, + disableEditMessage: Boolean = false +) = execute( + SetGameScoreByInlineMessageId( + userId, score, inlineMessageId, force, disableEditMessage + ) +) + +suspend fun RequestsExecutor.setGameScore( + user: CommonUser, + score: Long, + inlineMessageId: InlineMessageIdentifier, + force: Boolean = false, + disableEditMessage: Boolean = false +) = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)