mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-04-21 17:32:24 +00:00
build fix
This commit is contained in:
@@ -213,6 +213,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
firstName,
|
firstName,
|
||||||
secondName
|
secondName
|
||||||
)
|
)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse { false }
|
}.getOrElse { false }
|
||||||
reply(it) {
|
reply(it) {
|
||||||
if (set) {
|
if (set) {
|
||||||
@@ -230,6 +232,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
businessConnectionId,
|
businessConnectionId,
|
||||||
username
|
username
|
||||||
)
|
)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
false
|
false
|
||||||
@@ -267,6 +271,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
val transferred = runCatching {
|
val transferred = runCatching {
|
||||||
transferBusinessAccountStars(businessConnectionId, count)
|
transferBusinessAccountStars(businessConnectionId, count)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
false
|
false
|
||||||
@@ -310,6 +316,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
businessConnectionId,
|
businessConnectionId,
|
||||||
bio
|
bio
|
||||||
)
|
)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
false
|
false
|
||||||
@@ -327,6 +335,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
businessConnectionId,
|
businessConnectionId,
|
||||||
initialBio
|
initialBio
|
||||||
)
|
)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
false
|
false
|
||||||
@@ -358,6 +368,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
),
|
),
|
||||||
isPublic = isPublic
|
isPublic = isPublic
|
||||||
)
|
)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
false
|
false
|
||||||
@@ -376,6 +388,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
businessConnectionId,
|
businessConnectionId,
|
||||||
isPublic = isPublic
|
isPublic = isPublic
|
||||||
)
|
)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
false
|
false
|
||||||
@@ -461,6 +475,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
|
|
||||||
val deleted = runCatching {
|
val deleted = runCatching {
|
||||||
deleteStory(businessConnectionId, replyTo.content.story.id)
|
deleteStory(businessConnectionId, replyTo.content.story.id)
|
||||||
|
}.map {
|
||||||
|
true
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingLogging
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.modify.setChatPhoto
|
import dev.inmo.tgbotapi.extensions.api.chat.modify.setChatPhoto
|
||||||
@@ -15,17 +16,13 @@ suspend fun main(args: Array<String>) {
|
|||||||
bot.buildBehaviourWithLongPolling(scope = CoroutineScope(Dispatchers.IO)) {
|
bot.buildBehaviourWithLongPolling(scope = CoroutineScope(Dispatchers.IO)) {
|
||||||
onPhoto {
|
onPhoto {
|
||||||
val bytes = downloadFile(it.content)
|
val bytes = downloadFile(it.content)
|
||||||
runCatchingSafely {
|
runCatchingLogging {
|
||||||
setChatPhoto(
|
setChatPhoto(
|
||||||
it.chat.id,
|
it.chat.id,
|
||||||
bytes.asMultipartFile("sample.jpg")
|
bytes.asMultipartFile("sample.jpg")
|
||||||
)
|
)
|
||||||
}.onSuccess { b ->
|
}.onSuccess { _ ->
|
||||||
if (b) {
|
reply(it, "Done")
|
||||||
reply(it, "Done")
|
|
||||||
} else {
|
|
||||||
reply(it, "Something went wrong")
|
|
||||||
}
|
|
||||||
}.onFailure { e ->
|
}.onFailure { e ->
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|
||||||
|
|||||||
@@ -70,21 +70,18 @@ suspend fun main(vararg args: String) {
|
|||||||
|
|
||||||
draftMessagesChannel.send("Photo file have been downloaded. Start set my profile photo")
|
draftMessagesChannel.send("Photo file have been downloaded. Start set my profile photo")
|
||||||
|
|
||||||
val setResult = setMyProfilePhoto(
|
setMyProfilePhoto(
|
||||||
InputProfilePhoto.Static(
|
InputProfilePhoto.Static(
|
||||||
photoFile.asMultipartFile()
|
photoFile.asMultipartFile()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if (setResult) {
|
reply(commandMessage, "New photo have been set")
|
||||||
reply(commandMessage, "New photo have been set")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCommand("removeMyProfilePhoto") {
|
onCommand("removeMyProfilePhoto") {
|
||||||
runCatchingLogging {
|
runCatchingLogging {
|
||||||
if (removeMyProfilePhoto()) {
|
removeMyProfilePhoto()
|
||||||
reply(it, "Photo have been removed")
|
reply(it, "Photo have been removed")
|
||||||
}
|
|
||||||
}.onFailure { e ->
|
}.onFailure { e ->
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
reply(it, "Something web wrong. See logs for details.")
|
reply(it, "Something web wrong. See logs for details.")
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ suspend fun main(vararg args: String) {
|
|||||||
isAnonymous = false,
|
isAnonymous = false,
|
||||||
replyParameters = ReplyParameters(it),
|
replyParameters = ReplyParameters(it),
|
||||||
correctOptionIds = correctAnswer.sorted(),
|
correctOptionIds = correctAnswer.sorted(),
|
||||||
allowMultipleAnswers = correctAnswer.size > 1,
|
allowsMultipleAnswers = correctAnswer.size > 1,
|
||||||
allowsRevoting = true,
|
allowsRevoting = true,
|
||||||
shuffleOptions = true,
|
shuffleOptions = true,
|
||||||
hideResultsUntilCloses = true,
|
hideResultsUntilCloses = true,
|
||||||
|
|||||||
@@ -44,7 +44,11 @@ suspend fun main(args: Array<String>) {
|
|||||||
onCommand("delete") {
|
onCommand("delete") {
|
||||||
val deleted = runCatchingSafely {
|
val deleted = runCatchingSafely {
|
||||||
deleteStickerSet(it.chat.stickerSetName())
|
deleteStickerSet(it.chat.stickerSetName())
|
||||||
}.getOrElse { false }
|
}.map {
|
||||||
|
true
|
||||||
|
}.getOrElse {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
reply(it, "Deleted")
|
reply(it, "Deleted")
|
||||||
|
|||||||
Reference in New Issue
Block a user