mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-12-22 00:27:19 +00:00
add sendPaid in StarTransactions bot
This commit is contained in:
parent
481533bee2
commit
f750589fd3
@ -7,25 +7,32 @@ import dev.inmo.tgbotapi.extensions.api.answers.answer
|
||||
import dev.inmo.tgbotapi.extensions.api.answers.payments.answerPreCheckoutQueryOk
|
||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.edit
|
||||
import dev.inmo.tgbotapi.extensions.api.files.downloadFile
|
||||
import dev.inmo.tgbotapi.extensions.api.files.downloadFileToTemp
|
||||
import dev.inmo.tgbotapi.extensions.api.get.getStarTransactions
|
||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||
import dev.inmo.tgbotapi.extensions.api.send.send
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.command
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onMessageDataCallbackQuery
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onPreCheckoutQuery
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sameChat
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.dataButton
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.flatInlineKeyboard
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.payButton
|
||||
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.asMultipartFile
|
||||
import dev.inmo.tgbotapi.types.RawChatId
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.files.*
|
||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMediaPhoto
|
||||
import dev.inmo.tgbotapi.types.media.TelegramPaidMediaVideo
|
||||
import dev.inmo.tgbotapi.types.media.toTelegramPaidMediaPhoto
|
||||
import dev.inmo.tgbotapi.types.media.toTelegramPaidMediaVideo
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.textsources.textSourcesOrElse
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||
import dev.inmo.tgbotapi.types.payments.stars.StarTransaction
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
@ -126,6 +133,47 @@ suspend fun main(vararg args: String) {
|
||||
)
|
||||
}
|
||||
|
||||
onVisualGalleryMessages {
|
||||
send(
|
||||
it.chat,
|
||||
1,
|
||||
it.content.group.mapNotNull {
|
||||
val file = downloadFileToTemp(it.content.media)
|
||||
when (it.content.media) {
|
||||
is VideoFile -> {
|
||||
TelegramPaidMediaVideo(
|
||||
file.asMultipartFile()
|
||||
)
|
||||
}
|
||||
is PhotoSize -> {
|
||||
TelegramPaidMediaPhoto(
|
||||
file.asMultipartFile()
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
},
|
||||
it.content.textSources,
|
||||
showCaptionAboveMedia = true
|
||||
)
|
||||
}
|
||||
|
||||
onPhoto {
|
||||
send(
|
||||
it.chat,
|
||||
1,
|
||||
listOf(it.content.media.toTelegramPaidMediaPhoto())
|
||||
)
|
||||
}
|
||||
|
||||
onVideo {
|
||||
send(
|
||||
it.chat,
|
||||
1,
|
||||
listOf(it.content.media.toTelegramPaidMediaVideo())
|
||||
)
|
||||
}
|
||||
|
||||
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { println(it) }
|
||||
}.second.join()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user