mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-19 14:53:54 +00:00
commit
ad57e4142c
@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.possiblyWithEffectMessageOrNull
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
|
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
|
||||||
import dev.inmo.tgbotapi.types.ReplyParameters
|
import dev.inmo.tgbotapi.types.ReplyParameters
|
||||||
@ -39,7 +40,8 @@ suspend fun activateResenderBot(
|
|||||||
entities = quote ?.textSources ?: emptyList(),
|
entities = quote ?.textSources ?: emptyList(),
|
||||||
quotePosition = quote ?.position
|
quotePosition = quote ?.position
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
|
effectId = it.possiblyWithEffectMessageOrNull() ?.effectId
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
it.forEach(print)
|
it.forEach(print)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
import dev.inmo.tgbotapi.extensions.api.files.downloadFile
|
import dev.inmo.tgbotapi.extensions.api.files.downloadFile
|
||||||
import dev.inmo.tgbotapi.extensions.api.files.downloadFileToTemp
|
import dev.inmo.tgbotapi.extensions.api.files.downloadFileToTemp
|
||||||
@ -77,10 +78,18 @@ suspend fun main(args: Array<String>) {
|
|||||||
runCatchingSafely {
|
runCatchingSafely {
|
||||||
getStickerSet(stickerSetName)
|
getStickerSet(stickerSetName)
|
||||||
}.onSuccess { stickerSet ->
|
}.onSuccess { stickerSet ->
|
||||||
addStickerToSet(it.chat.id.toChatId(), stickerSet.name, newSticker).also { _ ->
|
runCatching {
|
||||||
|
addStickerToSet(it.chat.id.toChatId(), stickerSet.name, newSticker).also { _ ->
|
||||||
|
reply(
|
||||||
|
it,
|
||||||
|
getStickerSet(stickerSetName).stickers.last()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}.onFailure { exception ->
|
||||||
|
exception.printStackTrace()
|
||||||
reply(
|
reply(
|
||||||
it,
|
it,
|
||||||
getStickerSet(stickerSetName).stickers.last()
|
"Unable to add sticker in stickerset"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}.onFailure { exception ->
|
}.onFailure { exception ->
|
||||||
@ -100,5 +109,9 @@ suspend fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
||||||
|
println(it)
|
||||||
|
}
|
||||||
}.second.join()
|
}.second.join()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import dev.inmo.kslog.common.KSLog
|
import dev.inmo.kslog.common.*
|
||||||
import dev.inmo.kslog.common.LogLevel
|
|
||||||
import dev.inmo.kslog.common.defaultMessageFormatter
|
|
||||||
import dev.inmo.kslog.common.setDefaultKSLog
|
|
||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
import dev.inmo.micro_utils.ktor.server.createKtorServer
|
import dev.inmo.micro_utils.ktor.server.createKtorServer
|
||||||
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
||||||
@ -40,6 +37,7 @@ import java.nio.charset.Charset
|
|||||||
*
|
*
|
||||||
* * Telegram Token
|
* * Telegram Token
|
||||||
* * URL where will be placed
|
* * URL where will be placed
|
||||||
|
* * Port (default 8080)
|
||||||
*
|
*
|
||||||
* Will start the server to share the static (index.html and WebApp.js) on 0.0.0.0:8080
|
* Will start the server to share the static (index.html and WebApp.js) on 0.0.0.0:8080
|
||||||
*/
|
*/
|
||||||
@ -58,6 +56,7 @@ suspend fun main(vararg args: String) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
val initiationLogger = KSLog("Initialization")
|
||||||
|
|
||||||
val bot = telegramBot(telegramBotAPIUrlsKeeper)
|
val bot = telegramBot(telegramBotAPIUrlsKeeper)
|
||||||
createKtorServer(
|
createKtorServer(
|
||||||
@ -69,12 +68,28 @@ suspend fun main(vararg args: String) {
|
|||||||
) {
|
) {
|
||||||
routing {
|
routing {
|
||||||
val baseJsFolder = File("WebApp/build/dist/js/")
|
val baseJsFolder = File("WebApp/build/dist/js/")
|
||||||
baseJsFolder.list() ?.forEach {
|
val prodSubFolder = File(baseJsFolder, "productionExecutable")
|
||||||
if (it == "productionExecutable" || it == "developmentExecutable") {
|
val devSubFolder = File(baseJsFolder, "developmentExecutable")
|
||||||
staticFiles("", File(baseJsFolder, it)) {
|
|
||||||
default("WebApp/build/dist/js/$it/index.html")
|
val staticFolder = when {
|
||||||
}
|
prodSubFolder.exists() -> {
|
||||||
|
initiationLogger.i("Folder for static is ${prodSubFolder.absolutePath}")
|
||||||
|
prodSubFolder
|
||||||
}
|
}
|
||||||
|
devSubFolder.exists() -> {
|
||||||
|
initiationLogger.i("Folder for static is ${devSubFolder.absolutePath}")
|
||||||
|
devSubFolder
|
||||||
|
}
|
||||||
|
else -> error("""
|
||||||
|
Unable to detect any folder with static. Current working directory: ${File("").absolutePath}.
|
||||||
|
Searched paths:
|
||||||
|
* ${prodSubFolder.absolutePath}
|
||||||
|
* ${devSubFolder.absolutePath}
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
|
|
||||||
|
staticFiles("", staticFolder) {
|
||||||
|
default("${staticFolder.absolutePath}${File.separator}index.html")
|
||||||
}
|
}
|
||||||
post("inline") {
|
post("inline") {
|
||||||
val requestBody = call.receiveText()
|
val requestBody = call.receiveText()
|
||||||
|
@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx2344m
|
|||||||
|
|
||||||
|
|
||||||
kotlin_version=1.9.23
|
kotlin_version=1.9.23
|
||||||
telegram_bot_api_version=13.0.0
|
telegram_bot_api_version=14.0.0
|
||||||
micro_utils_version=0.20.45
|
micro_utils_version=0.20.45
|
||||||
serialization_version=1.6.3
|
serialization_version=1.6.3
|
||||||
ktor_version=2.3.10
|
ktor_version=2.3.10
|
||||||
|
Loading…
Reference in New Issue
Block a user