mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-21 15:53:47 +00:00
moving to an explicit API mode
refactored `get` package
This commit is contained in:
parent
cad6b26fdc
commit
b8837bffdc
@ -3,15 +3,16 @@ package dev.inmo.tgbotapi.extensions.api.get
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetBusinessConnection
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnection
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
|
||||
suspend fun TelegramBot.getBusinessConnection(
|
||||
public suspend fun TelegramBot.getBusinessConnection(
|
||||
id: BusinessConnectionId
|
||||
) = execute(GetBusinessConnection(businessConnectionId = id))
|
||||
): BusinessConnection = execute(GetBusinessConnection(businessConnectionId = id))
|
||||
|
||||
@Warning("This method may lead to error due to raw String type usage")
|
||||
suspend fun TelegramBot.getBusinessConnection(
|
||||
public suspend fun TelegramBot.getBusinessConnection(
|
||||
id: String
|
||||
) = getBusinessConnection(
|
||||
): BusinessConnection = getBusinessConnection(
|
||||
BusinessConnectionId(id)
|
||||
)
|
@ -4,34 +4,35 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetCustomEmojiStickers
|
||||
import dev.inmo.tgbotapi.requests.get.GetStickerSet
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.files.CustomEmojiSticker
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickers(
|
||||
public suspend fun TelegramBot.getCustomEmojiStickers(
|
||||
customEmojiIds: List<CustomEmojiId>
|
||||
) = execute(
|
||||
): List<CustomEmojiSticker> = execute(
|
||||
GetCustomEmojiStickers(customEmojiIds)
|
||||
)
|
||||
|
||||
@JvmName("getCustomEmojiStickersWithStringsList")
|
||||
@JsName("getCustomEmojiStickersWithStringsList")
|
||||
suspend fun TelegramBot.getCustomEmojiStickers(
|
||||
public suspend fun TelegramBot.getCustomEmojiStickers(
|
||||
customEmojiIds: List<String>
|
||||
) = getCustomEmojiStickers(customEmojiIds.map(::CustomEmojiId))
|
||||
): List<CustomEmojiSticker> = getCustomEmojiStickers(customEmojiIds.map(::CustomEmojiId))
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrNull(
|
||||
public suspend fun TelegramBot.getCustomEmojiStickerOrNull(
|
||||
customEmojiId: CustomEmojiId
|
||||
) = getCustomEmojiStickers(listOf(customEmojiId)).firstOrNull()
|
||||
): CustomEmojiSticker? = getCustomEmojiStickers(listOf(customEmojiId)).firstOrNull()
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrThrow(
|
||||
public suspend fun TelegramBot.getCustomEmojiStickerOrThrow(
|
||||
customEmojiId: CustomEmojiId
|
||||
) = getCustomEmojiStickers(listOf(customEmojiId)).first()
|
||||
): CustomEmojiSticker = getCustomEmojiStickers(listOf(customEmojiId)).first()
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrNull(
|
||||
public suspend fun TelegramBot.getCustomEmojiStickerOrNull(
|
||||
customEmojiId: String
|
||||
) = getCustomEmojiStickerOrNull(CustomEmojiId(customEmojiId))
|
||||
): CustomEmojiSticker? = getCustomEmojiStickerOrNull(CustomEmojiId(customEmojiId))
|
||||
|
||||
suspend fun TelegramBot.getCustomEmojiStickerOrThrow(
|
||||
public suspend fun TelegramBot.getCustomEmojiStickerOrThrow(
|
||||
customEmojiId: String
|
||||
) = getCustomEmojiStickerOrThrow(CustomEmojiId(customEmojiId))
|
||||
): CustomEmojiSticker = getCustomEmojiStickerOrThrow(CustomEmojiId(customEmojiId))
|
||||
|
@ -3,19 +3,20 @@ package dev.inmo.tgbotapi.extensions.api.get
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.get.GetFile
|
||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
public suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
fileId: FileId
|
||||
) = execute(
|
||||
): PathedFile = execute(
|
||||
GetFile(fileId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
public suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
file: TelegramMediaFile
|
||||
) = getFileAdditionalInfo(file.fileId)
|
||||
): PathedFile = getFileAdditionalInfo(file.fileId)
|
||||
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
public suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
content: MediaContent
|
||||
) = getFileAdditionalInfo(content.media)
|
||||
): PathedFile = getFileAdditionalInfo(content.media)
|
||||
|
@ -2,11 +2,12 @@ package dev.inmo.tgbotapi.extensions.api.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetStarTransactions
|
||||
import dev.inmo.tgbotapi.types.payments.stars.StarTransactions
|
||||
|
||||
suspend fun TelegramBot.getStarTransactions(
|
||||
public suspend fun TelegramBot.getStarTransactions(
|
||||
offset: Int? = null,
|
||||
limit: Int? = null,
|
||||
) = execute(
|
||||
): StarTransactions = execute(
|
||||
GetStarTransactions(
|
||||
offset = offset,
|
||||
limit = limit
|
||||
|
@ -4,27 +4,28 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetStickerSet
|
||||
import dev.inmo.tgbotapi.types.StickerSetName
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.getStickerSet(
|
||||
public suspend fun TelegramBot.getStickerSet(
|
||||
name: StickerSetName
|
||||
) = execute(
|
||||
): StickerSet = execute(
|
||||
GetStickerSet(name)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getStickerSet(
|
||||
public suspend fun TelegramBot.getStickerSet(
|
||||
name: String
|
||||
) = getStickerSet(
|
||||
): StickerSet = getStickerSet(
|
||||
StickerSetName(name)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getStickerSetOrNull(
|
||||
public suspend fun TelegramBot.getStickerSetOrNull(
|
||||
sticker: Sticker
|
||||
) = sticker.stickerSetName ?.let {
|
||||
): StickerSet? = sticker.stickerSetName ?.let {
|
||||
getStickerSet(it)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.getStickerSetOrThrow(
|
||||
public suspend fun TelegramBot.getStickerSetOrThrow(
|
||||
sticker: Sticker
|
||||
) = getStickerSet(
|
||||
): StickerSet = getStickerSet(
|
||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||
)
|
||||
|
@ -4,16 +4,17 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetUserChatBoosts
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.boosts.UserChatBoosts
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.getUserChatBoosts(
|
||||
public suspend fun TelegramBot.getUserChatBoosts(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(
|
||||
): UserChatBoosts = execute(
|
||||
GetUserChatBoosts(chatId = chatId, userId = userId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getUserChatBoosts(
|
||||
public suspend fun TelegramBot.getUserChatBoosts(
|
||||
chat: Chat,
|
||||
userId: UserId
|
||||
) = getUserChatBoosts(chatId = chat.id, userId = userId)
|
||||
): UserChatBoosts = getUserChatBoosts(chatId = chat.id, userId = userId)
|
@ -4,19 +4,20 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetUserProfilePhotos
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.UserProfilePhotos
|
||||
|
||||
suspend fun TelegramBot.getUserProfilePhotos(
|
||||
public suspend fun TelegramBot.getUserProfilePhotos(
|
||||
userId: UserId,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = execute(
|
||||
): UserProfilePhotos = execute(
|
||||
GetUserProfilePhotos(
|
||||
userId, offset, limit
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getUserProfilePhotos(
|
||||
public suspend fun TelegramBot.getUserProfilePhotos(
|
||||
user: CommonUser,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = getUserProfilePhotos(user.id, offset, limit)
|
||||
): UserProfilePhotos = getUserProfilePhotos(user.id, offset, limit)
|
||||
|
Loading…
Reference in New Issue
Block a user