mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-22 00:03:54 +00:00
upgrade up to 0.37.0
This commit is contained in:
parent
1b340d8db5
commit
d936bc4643
@ -17,7 +17,7 @@ data class StopState(override val context: ChatId) : BotState
|
||||
suspend fun main(args: Array<String>) {
|
||||
val botToken = args.first()
|
||||
|
||||
telegramBotWithBehaviourAndFSMAndStartLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
telegramBotWithBehaviourAndFSMAndStartLongPolling<BotState>(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
strictlyOn<ExpectContentOrStopState> {
|
||||
sendMessage(
|
||||
it.context,
|
||||
|
@ -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.telegramBotWithBehaviour
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
||||
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
|
||||
@ -17,7 +18,7 @@ suspend fun main(args: Array<String>) {
|
||||
val directoryOrFile = args.getOrNull(1) ?.let { File(it) } ?: File("")
|
||||
directoryOrFile.mkdirs()
|
||||
|
||||
telegramBotWithBehaviour(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
onMedia(initialFilter = null) {
|
||||
val pathedFile = bot.getFileAdditionalInfo(it.content.media)
|
||||
val file = File(directoryOrFile, pathedFile.filePath.filenameFromUrl).apply {
|
||||
|
@ -1,11 +1,8 @@
|
||||
import dev.inmo.micro_utils.coroutines.defaultSafelyExceptionHandler
|
||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviour
|
||||
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.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
||||
import dev.inmo.tgbotapi.types.message.*
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
@ -16,7 +13,7 @@ import kotlinx.coroutines.*
|
||||
suspend fun main(vararg args: String) {
|
||||
val botToken = args.first()
|
||||
|
||||
telegramBotWithBehaviour(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
onContentMessage(subcontextUpdatesFilter = { _, _ -> true }) {
|
||||
val toAnswer = buildEntities {
|
||||
when (val forwardInfo = it.forwardInfo) {
|
||||
|
@ -1,21 +1,15 @@
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
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.bot.Ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviour
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.asChannelChat
|
||||
import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
|
||||
import dev.inmo.tgbotapi.extensions.utils.formatting.textMentionMarkdownV2
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
||||
import dev.inmo.tgbotapi.types.User
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.*
|
||||
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Common
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
/**
|
||||
* The main purpose of this bot is just to answer "Oh, hi, " and add user mention here
|
||||
@ -23,7 +17,7 @@ import kotlinx.coroutines.flow.onEach
|
||||
suspend fun main(vararg args: String) {
|
||||
val botToken = args.first()
|
||||
|
||||
telegramBotWithBehaviour(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||
onContentMessage { message ->
|
||||
val chat = message.chat
|
||||
if (chat is ChannelChat) {
|
||||
|
@ -7,6 +7,7 @@ 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.buildBehaviour
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommandWithArgs
|
||||
import dev.inmo.tgbotapi.requests.abstracts.asMultipartFile
|
||||
@ -55,7 +56,7 @@ suspend fun main(args: Array<String>) {
|
||||
|
||||
val bot = telegramBot(botToken)
|
||||
|
||||
bot.buildBehaviour(defaultExceptionsHandler = { it.printStackTrace() }) {
|
||||
bot.buildBehaviourWithLongPolling (defaultExceptionsHandler = { it.printStackTrace() }) {
|
||||
onCommandWithArgs(command) { message, args ->
|
||||
|
||||
withUploadDocumentAction(message.chat) {
|
||||
|
@ -18,7 +18,7 @@ suspend fun activateResenderBot(
|
||||
|
||||
print(bot.getMe())
|
||||
|
||||
bot.buildBehaviour(CoroutineScope(coroutineContext + SupervisorJob())) {
|
||||
bot.buildBehaviourWithLongPolling(CoroutineScope(coroutineContext + SupervisorJob())) {
|
||||
onContentMessage(
|
||||
subcontextUpdatesFilter = MessageFilterByChat + BehaviourContextAndTwoTypesReceiver { it, _ -> it !is MediaGroupMessage<*> }
|
||||
) {
|
||||
|
@ -3,5 +3,5 @@ org.gradle.parallel=true
|
||||
|
||||
|
||||
kotlin_version=1.5.31
|
||||
telegram_bot_api_version=0.36.1
|
||||
micro_utils_version=0.7.2
|
||||
telegram_bot_api_version=0.37.0
|
||||
micro_utils_version=0.8.1
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
|
Loading…
Reference in New Issue
Block a user