2020-10-04 11:32:50 +00:00
|
|
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
2020-11-18 06:35:45 +00:00
|
|
|
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
2021-02-01 06:57:39 +00:00
|
|
|
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
|
|
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
|
|
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
2020-10-04 11:32:50 +00:00
|
|
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
2021-02-01 06:57:39 +00:00
|
|
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
2020-08-20 17:14:22 +00:00
|
|
|
import kotlinx.coroutines.*
|
2021-02-01 06:57:39 +00:00
|
|
|
import kotlin.coroutines.coroutineContext
|
2020-08-20 17:14:22 +00:00
|
|
|
|
|
|
|
suspend fun activateResenderBot(
|
|
|
|
token: String,
|
|
|
|
print: (Any) -> Unit
|
|
|
|
) {
|
|
|
|
val bot = telegramBot(token)
|
|
|
|
|
|
|
|
print(bot.getMe())
|
|
|
|
|
2021-02-01 06:57:39 +00:00
|
|
|
bot.buildBehaviour(CoroutineScope(coroutineContext + SupervisorJob())) {
|
|
|
|
onContentMessage(
|
|
|
|
additionalFilter = { it !is MediaGroupMessage<*> }
|
|
|
|
) {
|
2021-03-12 09:48:31 +00:00
|
|
|
executeUnsafe(it.content.createResend(it.chat.id, replyToMessageId = it.messageId))
|
2020-08-20 17:14:22 +00:00
|
|
|
}
|
2021-02-01 06:57:39 +00:00
|
|
|
onVisualGallery {
|
|
|
|
sendVisualMediaGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
|
|
|
}
|
|
|
|
onPlaylist {
|
|
|
|
sendPlaylist(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
|
|
|
}
|
|
|
|
onDocumentsGroup {
|
|
|
|
sendDocumentsGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
|
|
|
}
|
|
|
|
}.join()
|
2020-08-20 17:14:22 +00:00
|
|
|
}
|