migration onto 2.1.1

This commit is contained in:
InsanusMokrassar 2022-06-26 13:03:52 +06:00
parent 370fa45dba
commit 9cf8bd9f28
7 changed files with 15 additions and 14 deletions

View File

@ -1,5 +1,6 @@
import dev.inmo.micro_utils.coroutines.AccumulatorFlow
import dev.inmo.micro_utils.fsm.common.State
import dev.inmo.tgbotapi.extensions.api.send.send
import dev.inmo.tgbotapi.extensions.api.send.sendMessage
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.*
@ -55,7 +56,7 @@ suspend fun main(args: Array<String>) {
}
}
strictlyOn<StopState> {
sendMessage(it.context, "You have stopped sending of content")
send(it.context, "You have stopped sending of content")
null
}

View File

@ -1,7 +1,6 @@
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
import dev.inmo.tgbotapi.extensions.api.send.reply
import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
import dev.inmo.tgbotapi.extensions.api.send.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage
import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
@ -27,7 +26,7 @@ suspend fun main(vararg args: String) {
val chat = message.chat
if (chat is ChannelChat) {
val answer = "Hi everybody in this channel \"${chat.title}\""
sendTextMessage(chat, answer, MarkdownV2)
send(chat, answer, MarkdownV2)
return@onContentMessage
}
val answerText = "Oh, hi, " + when (chat) {

View File

@ -3,6 +3,7 @@ import dev.inmo.tgbotapi.extensions.api.bot.getMe
import dev.inmo.tgbotapi.bot.ktor.telegramBot
import dev.inmo.tgbotapi.extensions.api.answers.answer
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
import dev.inmo.tgbotapi.extensions.api.edit.common.edit
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
import dev.inmo.tgbotapi.extensions.api.send.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
@ -88,7 +89,7 @@ suspend fun activateKeyboardsBot(
val text = "This is $page of $count"
editMessageText(
edit(
it.message.withContent<TextContent>() ?: it.let {
answer(it, "Unsupported message type :(")
return@onMessageDataCallbackQuery

View File

@ -3,15 +3,15 @@ import dev.inmo.tgbotapi.bot.ktor.telegramBot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.bot.getMe
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
import dev.inmo.tgbotapi.extensions.api.send.*
import dev.inmo.tgbotapi.extensions.api.send.media.sendDocument
import dev.inmo.tgbotapi.extensions.api.send.media.sendDocumentsGroup
import dev.inmo.tgbotapi.extensions.api.send.reply
import dev.inmo.tgbotapi.extensions.api.send.withUploadDocumentAction
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommandWithArgs
import dev.inmo.tgbotapi.requests.abstracts.asMultipartFile
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.files.DocumentFile
import dev.inmo.tgbotapi.types.media.TelegramMediaDocument
import dev.inmo.tgbotapi.types.mediaCountInMediaGroup
import java.io.File
@ -81,7 +81,7 @@ suspend fun main(args: Array<String>) {
}
if (!sent) {
bot.reply(message, "Nothing selected :(")
reply(message, "Nothing selected :(")
}
}
}

View File

@ -31,19 +31,19 @@ suspend fun activateResenderBot(
onVisualGallery {
val chat = it.chat ?: return@onVisualGallery
withUploadPhotoAction(chat) {
sendVisualMediaGroup(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
send(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
}
}
onPlaylist {
val chat = it.chat ?: return@onPlaylist
withUploadDocumentAction(chat) {
sendPlaylist(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
send(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
}
}
onDocumentsGroup {
val chat = it.chat ?: return@onDocumentsGroup
withUploadDocumentAction(chat) {
sendDocumentsGroup(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
send(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
}
}

View File

@ -17,9 +17,9 @@ suspend fun main(args: Array<String>) {
if (diceType == SlotMachineDiceAnimationType) {
val result = dice.calculateSlotMachineResult() ?: return@onDice
bot.reply(it, "${result.leftReel}|${result.centerReel}|${result.rightReel}")
reply(it, "${result.leftReel}|${result.centerReel}|${result.rightReel}")
} else {
bot.reply(it, "There is no slot machine dice in message")
reply(it, "There is no slot machine dice in message")
}
}
}.join()

View File

@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx768m
kotlin_version=1.6.21
telegram_bot_api_version=2.1.0
telegram_bot_api_version=2.1.1
micro_utils_version=0.11.6
serialization_version=1.3.3
ktor_version=2.0.2