1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

moving to an explicit API mode

refactored `games` package
This commit is contained in:
bpavuk 2024-07-12 22:07:36 +03:00
parent 52f17178ab
commit cad6b26fdc
No known key found for this signature in database
GPG Key ID: B501D26D9DEA9CFE
4 changed files with 34 additions and 32 deletions

View File

@ -5,51 +5,52 @@ import dev.inmo.tgbotapi.requests.games.GetGameHighScoresByChat
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.games.GameHighScore
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.GameContent import dev.inmo.tgbotapi.types.message.content.GameContent
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
userId: UserId, userId: UserId,
chatId: IdChatIdentifier, chatId: IdChatIdentifier,
messageId: MessageId messageId: MessageId
) = execute( ): List<GameHighScore> = execute(
GetGameHighScoresByChat(userId, chatId, messageId) GetGameHighScoresByChat(userId, chatId, messageId)
) )
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
user: CommonUser, user: CommonUser,
chatId: IdChatIdentifier, chatId: IdChatIdentifier,
messageId: MessageId messageId: MessageId
) = getGameScore( ): List<GameHighScore> = getGameScore(
user.id, chatId, messageId user.id, chatId, messageId
) )
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
userId: UserId, userId: UserId,
chat: Chat, chat: Chat,
messageId: MessageId messageId: MessageId
) = getGameScore( ): List<GameHighScore> = getGameScore(
userId, chat.id, messageId userId, chat.id, messageId
) )
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
user: CommonUser, user: CommonUser,
chat: Chat, chat: Chat,
messageId: MessageId messageId: MessageId
) = getGameScore( ): List<GameHighScore> = getGameScore(
user.id, chat.id, messageId user.id, chat.id, messageId
) )
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
userId: UserId, userId: UserId,
message: ContentMessage<GameContent> message: ContentMessage<GameContent>
) = getGameScore( ): List<GameHighScore> = getGameScore(
userId, message.chat.id, message.messageId userId, message.chat.id, message.messageId
) )
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
user: CommonUser, user: CommonUser,
message: ContentMessage<GameContent> message: ContentMessage<GameContent>
) = getGameScore( ): List<GameHighScore> = getGameScore(
user.id, message.chat.id, message.messageId user.id, message.chat.id, message.messageId
) )

View File

@ -4,17 +4,18 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.games.GetGameHighScoresByInlineMessageId import dev.inmo.tgbotapi.requests.games.GetGameHighScoresByInlineMessageId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.games.GameHighScore
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
userId: UserId, userId: UserId,
inlineMessageId: InlineMessageId inlineMessageId: InlineMessageId
) = execute( ): List<GameHighScore> = execute(
GetGameHighScoresByInlineMessageId( GetGameHighScoresByInlineMessageId(
userId, inlineMessageId userId, inlineMessageId
) )
) )
suspend fun TelegramBot.getGameScore( public suspend fun TelegramBot.getGameScore(
user: CommonUser, user: CommonUser,
inlineMessageId: InlineMessageId inlineMessageId: InlineMessageId
) = getGameScore(user.id, inlineMessageId) ): List<GameHighScore> = getGameScore(user.id, inlineMessageId)

View File

@ -8,66 +8,66 @@ import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.GameContent import dev.inmo.tgbotapi.types.message.content.GameContent
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
userId: UserId, userId: UserId,
score: Long, score: Long,
chatId: IdChatIdentifier, chatId: IdChatIdentifier,
messageId: MessageId, messageId: MessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = execute( ): Boolean = execute(
SetGameScoreByChatId(userId, score, chatId, messageId, force, disableEditMessage) SetGameScoreByChatId(userId, score, chatId, messageId, force, disableEditMessage)
) )
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
user: CommonUser, user: CommonUser,
score: Long, score: Long,
chatId: IdChatIdentifier, chatId: IdChatIdentifier,
messageId: MessageId, messageId: MessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = setGameScore( ): Boolean = setGameScore(
user.id, score, chatId, messageId, force, disableEditMessage user.id, score, chatId, messageId, force, disableEditMessage
) )
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
userId: UserId, userId: UserId,
score: Long, score: Long,
chat: Chat, chat: Chat,
messageId: MessageId, messageId: MessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = setGameScore( ): Boolean = setGameScore(
userId, score, chat.id, messageId, force, disableEditMessage userId, score, chat.id, messageId, force, disableEditMessage
) )
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
user: CommonUser, user: CommonUser,
score: Long, score: Long,
chat: Chat, chat: Chat,
messageId: MessageId, messageId: MessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = setGameScore( ): Boolean = setGameScore(
user.id, score, chat.id, messageId, force, disableEditMessage user.id, score, chat.id, messageId, force, disableEditMessage
) )
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
userId: UserId, userId: UserId,
score: Long, score: Long,
message: ContentMessage<GameContent>, message: ContentMessage<GameContent>,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = setGameScore( ): Boolean = setGameScore(
userId, score, message.chat.id, message.messageId, force, disableEditMessage userId, score, message.chat.id, message.messageId, force, disableEditMessage
) )
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
user: CommonUser, user: CommonUser,
score: Long, score: Long,
message: ContentMessage<GameContent>, message: ContentMessage<GameContent>,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = setGameScore( ): Boolean = setGameScore(
user.id, score, message.chat.id, message.messageId, force, disableEditMessage user.id, score, message.chat.id, message.messageId, force, disableEditMessage
) )

View File

@ -5,22 +5,22 @@ import dev.inmo.tgbotapi.requests.games.SetGameScoreByInlineMessageId
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.CommonUser import dev.inmo.tgbotapi.types.chat.CommonUser
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
userId: UserId, userId: UserId,
score: Long, score: Long,
inlineMessageId: InlineMessageId, inlineMessageId: InlineMessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = execute( ): Boolean = execute(
SetGameScoreByInlineMessageId( SetGameScoreByInlineMessageId(
userId, score, inlineMessageId, force, disableEditMessage userId, score, inlineMessageId, force, disableEditMessage
) )
) )
suspend fun TelegramBot.setGameScore( public suspend fun TelegramBot.setGameScore(
user: CommonUser, user: CommonUser,
score: Long, score: Long,
inlineMessageId: InlineMessageId, inlineMessageId: InlineMessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
) = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage) ): Boolean = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)