mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-24 11:08:49 +00:00
improvements and fixes
This commit is contained in:
parent
a7fe62f4af
commit
a40c16fe05
@ -2,6 +2,7 @@ import dev.inmo.tgbotapi.extensions.api.files.downloadFile
|
||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onMedia
|
||||
import dev.inmo.tgbotapi.utils.filenameFromUrl
|
||||
@ -18,6 +19,9 @@ suspend fun main(args: Array<String>) {
|
||||
directoryOrFile.mkdirs()
|
||||
|
||||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
onCommand("start") {
|
||||
reply(it, "Send me any media (like photo or video) to download it")
|
||||
}
|
||||
onMedia(initialFilter = null) {
|
||||
val pathedFile = bot.getFileAdditionalInfo(it.content.media)
|
||||
val outFile = File(directoryOrFile, pathedFile.filePath.filenameFromUrl)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
|
||||
@ -12,6 +13,7 @@ import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestChatButton
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestGroupButton
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestUserButton
|
||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestUserOrBotButton
|
||||
import dev.inmo.tgbotapi.types.BotCommand
|
||||
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
||||
import dev.inmo.tgbotapi.types.message.textsources.mention
|
||||
import dev.inmo.tgbotapi.types.request.RequestId
|
||||
@ -210,5 +212,7 @@ suspend fun main(args: Array<String>) {
|
||||
+" (chat info: $chatInfo; chat id: $chatId)"
|
||||
}
|
||||
}
|
||||
|
||||
setMyCommands(BotCommand("start", "Trigger buttons"))
|
||||
}.join()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user