mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-24 19:18:49 +00:00
update
This commit is contained in:
parent
aa89a289ce
commit
9e0f43dcc0
@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.extensions.api.downloadFile
|
|||||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
||||||
import dev.inmo.tgbotapi.extensions.utils.flatMap
|
import dev.inmo.tgbotapi.extensions.utils.flatMap
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||||
import dev.inmo.tgbotapi.utils.filenameFromUrl
|
import dev.inmo.tgbotapi.utils.filenameFromUrl
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@ -22,7 +22,7 @@ suspend fun main(args: Array<String>) {
|
|||||||
val bot = telegramBot(botToken)
|
val bot = telegramBot(botToken)
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
|
||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
bot.longPolling(scope = scope) {
|
||||||
val flow = merge (
|
val flow = merge (
|
||||||
filterContentMessages<MediaContent>(),
|
filterContentMessages<MediaContent>(),
|
||||||
mediaGroupMessages().flatMap()
|
mediaGroupMessages().flatMap()
|
||||||
|
@ -7,10 +7,9 @@ import dev.inmo.tgbotapi.extensions.utils.formatting.codeMarkdownV2
|
|||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.regularMarkdownV2
|
import dev.inmo.tgbotapi.extensions.utils.formatting.regularMarkdownV2
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.mediaGroupMessages
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.mediaGroupMessages
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow
|
import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
||||||
import dev.inmo.tgbotapi.types.message.*
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ suspend fun main(vararg args: String) {
|
|||||||
|
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
|
||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
bot.longPolling(scope = scope) {
|
||||||
(merge(messageFlow.asContentMessagesFlow(), mediaGroupMessages(scope).flatMap())).mapNotNull { it.asPossiblyForwardedMessage() }.onEach { message ->
|
(merge(messageFlow.asContentMessagesFlow(), mediaGroupMessages(scope).flatMap())).mapNotNull { it.asPossiblyForwardedMessage() }.onEach { message ->
|
||||||
safely({ it.printStackTrace() }) {
|
safely({ it.printStackTrace() }) {
|
||||||
val toAnswer = when (val forwardInfo = message.forwardInfo) {
|
val toAnswer = when (val forwardInfo = message.forwardInfo) {
|
||||||
|
@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
|||||||
import dev.inmo.tgbotapi.extensions.utils.asChannelChat
|
import dev.inmo.tgbotapi.extensions.utils.asChannelChat
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
|
import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.textMentionMarkdownV2
|
import dev.inmo.tgbotapi.extensions.utils.formatting.textMentionMarkdownV2
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
||||||
import dev.inmo.tgbotapi.types.User
|
import dev.inmo.tgbotapi.types.User
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.*
|
import dev.inmo.tgbotapi.types.chat.abstracts.*
|
||||||
@ -25,7 +25,7 @@ suspend fun main(vararg args: String) {
|
|||||||
|
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
|
||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
bot.longPolling(scope = scope) {
|
||||||
messageFlow.onEach {
|
messageFlow.onEach {
|
||||||
safely {
|
safely {
|
||||||
val message = it.data
|
val message = it.data
|
||||||
|
@ -20,11 +20,7 @@ suspend fun activateResenderBot(
|
|||||||
onContentMessage(
|
onContentMessage(
|
||||||
additionalFilter = { it !is MediaGroupMessage<*> }
|
additionalFilter = { it !is MediaGroupMessage<*> }
|
||||||
) {
|
) {
|
||||||
it.content.createResends(it.chat.id, replyToMessageId = it.messageId).forEach {
|
executeUnsafe(it.content.createResend(it.chat.id, replyToMessageId = it.messageId))
|
||||||
executeUnsafe(it) {
|
|
||||||
it.forEach(print)
|
|
||||||
} ?.also(print)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onVisualGallery {
|
onVisualGallery {
|
||||||
sendVisualMediaGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
sendVisualMediaGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
||||||
|
@ -3,7 +3,7 @@ import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
|||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.filterContentMessages
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.filterContentMessages
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||||
import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType
|
import dev.inmo.tgbotapi.types.dice.SlotMachineDiceAnimationType
|
||||||
import dev.inmo.tgbotapi.types.message.content.DiceContent
|
import dev.inmo.tgbotapi.types.message.content.DiceContent
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@ -14,7 +14,7 @@ suspend fun main(args: Array<String>) {
|
|||||||
val bot = telegramBot(args.first())
|
val bot = telegramBot(args.first())
|
||||||
|
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
bot.longPolling(scope = scope) {
|
||||||
filterContentMessages<DiceContent>(scope).onEach {
|
filterContentMessages<DiceContent>(scope).onEach {
|
||||||
val content = it.content
|
val content = it.content
|
||||||
val dice = content.dice
|
val dice = content.dice
|
||||||
|
@ -2,5 +2,14 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
if (project.hasProperty("GITHUB_USER") && project.hasProperty("GITHUB_TOKEN")) {
|
||||||
|
maven {
|
||||||
|
url "https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"
|
||||||
|
credentials {
|
||||||
|
username = project.getProperty("GITHUB_USER")
|
||||||
|
password = project.getProperty("GITHUB_TOKEN")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,4 +2,4 @@ kotlin.code.style=official
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|
||||||
kotlin_version=1.4.31
|
kotlin_version=1.4.31
|
||||||
telegram_bot_api_version=0.32.8
|
telegram_bot_api_version=0.33.0
|
||||||
|
Loading…
Reference in New Issue
Block a user