mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2025-12-16 19:25:36 +00:00
Compare commits
80 Commits
0.35.1
...
3ebca4a058
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ebca4a058 | ||
| 2b9af2f667 | |||
| 16410debff | |||
| a18f22fe8f | |||
| 0489f217b3 | |||
| e772cfda3b | |||
| 9d42385662 | |||
| b740203116 | |||
| 149717301d | |||
| 60e72be844 | |||
| 831b558724 | |||
| df778b4e93 | |||
| bf0c6497fe | |||
|
|
71a047f867 | ||
| 2ae3e1165d | |||
| 9a5d02512b | |||
| dd2c528006 | |||
| 1c16a9f868 | |||
| 00c3aba12b | |||
| a547bbce65 | |||
| 0b7d8c087f | |||
| 8ec282e3d5 | |||
|
|
e8433cd8ac | ||
| 222134836a | |||
| c18e02dcb3 | |||
| f9050061d1 | |||
| a3e3f6c22c | |||
| 516cc7bfcb | |||
| c707a11b66 | |||
| c6c418c393 | |||
| e0795c3c14 | |||
| dec55990dc | |||
|
|
169f3f5bd5 | ||
| e175bb6143 | |||
| 290d722ae6 | |||
| 9ee85df1ad | |||
|
|
2953c40963 | ||
| 512067b056 | |||
|
|
0cb209dc6e | ||
| 7cf6814d89 | |||
| 09e8492439 | |||
|
|
71222f42e5 | ||
| 426d649877 | |||
|
|
93faf9654a | ||
| 288386e25a | |||
| 99e83589a4 | |||
|
|
fbea95fc0a | ||
| 0edaa28151 | |||
| df874b0783 | |||
| 5f5722398d | |||
| cc29ec75ca | |||
|
|
a42173acf6 | ||
| d936bc4643 | |||
| 1b340d8db5 | |||
|
|
4cd1980778 | ||
| d89202aebb | |||
| be2de6e372 | |||
|
|
08796f18e8 | ||
| 8bd7e116e3 | |||
|
|
39d7a95c95 | ||
| 526ecac89a | |||
|
|
1e4e246fab | ||
| 6aa7fe151e | |||
| 16c27fa493 | |||
|
|
f6a811acca | ||
| 17c08fc906 | |||
| aee0943a5e | |||
| c07f4f2ed1 | |||
| 817acb8faf | |||
| 8b294a0cc0 | |||
|
|
0139cc5dcc | ||
| 6d16508277 | |||
| ce2051d32d | |||
| 1abbcc8789 | |||
| c5e05dfce1 | |||
| c1d7129af8 | |||
| 496fc45d2d | |||
| cdb634e91a | |||
| 9d17311918 | |||
| 12ef88c757 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -8,9 +8,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 1.8
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: 11
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,3 +8,5 @@ settings.xml
|
|||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
out/
|
out/
|
||||||
|
|
||||||
|
kotlin-js-store/
|
||||||
|
|||||||
11
.travis.yml
11
.travis.yml
@@ -1,11 +0,0 @@
|
|||||||
language: java
|
|
||||||
install: true
|
|
||||||
|
|
||||||
os: linux
|
|
||||||
dist: trusty
|
|
||||||
jdk: oraclejdk8
|
|
||||||
|
|
||||||
script:
|
|
||||||
- ./gradlew build -s
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -13,10 +14,13 @@ apply plugin: 'application'
|
|||||||
|
|
||||||
mainClassName="SimpleFSMBotKt"
|
mainClassName="SimpleFSMBotKt"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
implementation "dev.inmo:micro_utils.fsm.common:$micro_utils_version"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,90 +1,51 @@
|
|||||||
|
import dev.inmo.micro_utils.coroutines.AccumulatorFlow
|
||||||
import dev.inmo.micro_utils.fsm.common.State
|
import dev.inmo.micro_utils.fsm.common.State
|
||||||
import dev.inmo.micro_utils.fsm.common.dsl.buildFSM
|
|
||||||
import dev.inmo.micro_utils.fsm.common.dsl.strictlyOn
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.sendMessage
|
import dev.inmo.tgbotapi.extensions.api.send.sendMessage
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.command
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat
|
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
|
import kotlinx.coroutines.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
|
|
||||||
sealed interface State : State
|
sealed interface BotState : State
|
||||||
data class ExpectContentOrStopState(override val context: ChatId, val sourceMessage: CommonMessage<TextContent>) : State
|
data class ExpectContentOrStopState(override val context: ChatId, val sourceMessage: CommonMessage<TextContent>) : BotState
|
||||||
data class StopState(override val context: ChatId) : State
|
data class StopState(override val context: ChatId) : BotState
|
||||||
|
|
||||||
fun TextContent.containsStopCommand() = parseCommandsWithParams().keys.firstOrNull { it == "stop" } != null
|
|
||||||
|
|
||||||
suspend fun main(args: Array<String>) {
|
suspend fun main(args: Array<String>) {
|
||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
|
|
||||||
telegramBotWithBehaviour(botToken, CoroutineScope(Dispatchers.IO)) {
|
telegramBotWithBehaviourAndFSMAndStartLongPolling<BotState>(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||||
val fsm = buildFSM {
|
strictlyOn<ExpectContentOrStopState> {
|
||||||
strictlyOn<ExpectContentOrStopState> {
|
sendMessage(
|
||||||
sendMessage(
|
it.context,
|
||||||
it.context,
|
buildEntities {
|
||||||
buildEntities {
|
+"Send me some content or " + botCommand("stop") + " if you want to stop sending"
|
||||||
+"Send me some content or "
|
}
|
||||||
botCommand("stop")
|
)
|
||||||
+" if you want to stop sending"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
val content = oneOf(
|
val contentMessage = waitContentMessage().first()
|
||||||
parallel {
|
val content = contentMessage.content
|
||||||
waitContentMessage(includeMediaGroups = false) { if (chat.id == it.context) content else null }.also(::println)
|
|
||||||
},
|
|
||||||
parallel {
|
|
||||||
waitMediaGroup { chat ?.id == it.context }.also(::println)
|
|
||||||
},
|
|
||||||
parallel {
|
|
||||||
waitText { if (content.containsStopCommand()) content else null }.also(::println)
|
|
||||||
}
|
|
||||||
).first()
|
|
||||||
|
|
||||||
when {
|
when {
|
||||||
content is TextContent && content.containsStopCommand() -> StopState(it.context) // assume we got "stop" command
|
content is TextContent && content.parseCommandsWithParams().keys.contains("stop") -> StopState(it.context)
|
||||||
content is List<*> -> { // assume it is media group
|
else -> {
|
||||||
val casted = (content as List<MediaGroupContent>)
|
execute(content.createResend(it.context))
|
||||||
|
it
|
||||||
reply(it.sourceMessage, "Ok, I got this media group and now will resend it to you")
|
|
||||||
sendMediaGroup(it.context, casted.map { it.toMediaGroupMemberInputMedia() })
|
|
||||||
|
|
||||||
it
|
|
||||||
}
|
|
||||||
content is MessageContent -> {
|
|
||||||
|
|
||||||
reply(it.sourceMessage, "Ok, I got this content and now will resend it to you")
|
|
||||||
execute(content.createResend(it.context))
|
|
||||||
|
|
||||||
it
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
sendMessage(it.context, "Unknown internal error")
|
|
||||||
it
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strictlyOn<StopState> {
|
}
|
||||||
sendMessage(it.context, "You have stopped sending of content")
|
strictlyOn<StopState> {
|
||||||
|
sendMessage(it.context, "You have stopped sending of content")
|
||||||
|
|
||||||
null
|
null
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
command("start") {
|
command("start") {
|
||||||
fsm.startChain(ExpectContentOrStopState(it.chat.id, it))
|
startChain(ExpectContentOrStopState(it.chat.id, it))
|
||||||
}
|
}
|
||||||
|
|
||||||
fsm.start(this)
|
|
||||||
}.second.join()
|
}.second.join()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -14,7 +14,7 @@ apply plugin: 'application'
|
|||||||
mainClassName="FilesLoaderBotKt"
|
mainClassName="FilesLoaderBotKt"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import dev.inmo.tgbotapi.extensions.api.downloadFile
|
import dev.inmo.tgbotapi.extensions.api.files.downloadFile
|
||||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
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.onContentMessage
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onMedia
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onMedia
|
||||||
import dev.inmo.tgbotapi.utils.filenameFromUrl
|
import dev.inmo.tgbotapi.utils.filenameFromUrl
|
||||||
@@ -17,8 +17,8 @@ suspend fun main(args: Array<String>) {
|
|||||||
val directoryOrFile = args.getOrNull(1) ?.let { File(it) } ?: File("")
|
val directoryOrFile = args.getOrNull(1) ?.let { File(it) } ?: File("")
|
||||||
directoryOrFile.mkdirs()
|
directoryOrFile.mkdirs()
|
||||||
|
|
||||||
telegramBotWithBehaviour(botToken, CoroutineScope(Dispatchers.IO)) {
|
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||||
onMedia(includeMediaGroups = true) {
|
onMedia(initialFilter = null) {
|
||||||
val pathedFile = bot.getFileAdditionalInfo(it.content.media)
|
val pathedFile = bot.getFileAdditionalInfo(it.content.media)
|
||||||
val file = File(directoryOrFile, pathedFile.filePath.filenameFromUrl).apply {
|
val file = File(directoryOrFile, pathedFile.filePath.filenameFromUrl).apply {
|
||||||
createNewFile()
|
createNewFile()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,7 +15,7 @@ mainClassName="ForwardInfoSenderBotKt"
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
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.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.onContentMessage
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
import dev.inmo.tgbotapi.types.chat.CommonBot
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||||
import dev.inmo.tgbotapi.types.message.*
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ import kotlinx.coroutines.*
|
|||||||
suspend fun main(vararg args: String) {
|
suspend fun main(vararg args: String) {
|
||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
|
|
||||||
telegramBotWithBehaviour(botToken, CoroutineScope(Dispatchers.IO)) {
|
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||||
onContentMessage(includeMediaGroups = true) {
|
onContentMessage(subcontextUpdatesFilter = { _, _ -> true }) {
|
||||||
val toAnswer = buildEntities {
|
val toAnswer = buildEntities {
|
||||||
when (val forwardInfo = it.forwardInfo) {
|
when (val forwardInfo = it.forwardInfo) {
|
||||||
null -> +"There is no forward info"
|
null -> +"There is no forward info"
|
||||||
@@ -25,15 +25,17 @@ suspend fun main(vararg args: String) {
|
|||||||
}
|
}
|
||||||
is UserForwardInfo -> {
|
is UserForwardInfo -> {
|
||||||
val user = forwardInfo.from
|
val user = forwardInfo.from
|
||||||
regular("User ") + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})"
|
when (user) {
|
||||||
|
is CommonUser -> regular("User ")
|
||||||
|
is CommonBot,
|
||||||
|
is ExtendedBot -> regular("Bot ")
|
||||||
|
} + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})"
|
||||||
}
|
}
|
||||||
is ForwardFromChannelInfo -> regular("Channel (") + code((forwardInfo.channelChat).title) + ")"
|
is ForwardFromChannelInfo -> regular("Channel (") + code((forwardInfo.channelChat).title) + ")"
|
||||||
is ForwardFromSupergroupInfo -> regular("Supergroup (") + code((forwardInfo.group).title) + ")"
|
is ForwardFromSupergroupInfo -> regular("Supergroup (") + code((forwardInfo.group).title) + ")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reply(it, toAnswer)
|
reply(it, toAnswer)
|
||||||
coroutineContext.job.invokeOnCompletion { println("completance of onContentMessage") }
|
|
||||||
}
|
}
|
||||||
coroutineContext.job.invokeOnCompletion { println("Completed :)") }
|
|
||||||
}.second.join()
|
}.second.join()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,7 +15,7 @@ mainClassName="HelloBotKt"
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,4 +10,4 @@ suspend fun main(vararg args: String) {
|
|||||||
val bot = telegramBot(botToken)
|
val bot = telegramBot(botToken)
|
||||||
|
|
||||||
println(bot.getMe())
|
println(bot.getMe())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,7 +15,7 @@ mainClassName="HelloBotKt"
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,28 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.safely
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
|
import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
|
||||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviour
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage
|
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.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.longPolling
|
import dev.inmo.tgbotapi.types.chat.*
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
|
import dev.inmo.tgbotapi.types.chat.GroupChat
|
||||||
import dev.inmo.tgbotapi.types.User
|
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
||||||
import dev.inmo.tgbotapi.types.chat.abstracts.*
|
import dev.inmo.tgbotapi.types.chat.SupergroupChat
|
||||||
|
import dev.inmo.tgbotapi.types.message.MarkdownV2
|
||||||
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Common
|
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Common
|
||||||
import kotlinx.coroutines.*
|
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
|
* The main purpose of this bot is just to answer "Oh, hi, " and add user mention here
|
||||||
*/
|
*/
|
||||||
|
@OptIn(PreviewFeature::class)
|
||||||
suspend fun main(vararg args: String) {
|
suspend fun main(vararg args: String) {
|
||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
|
|
||||||
telegramBotWithBehaviour(botToken, CoroutineScope(Dispatchers.IO)) {
|
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||||
onContentMessage { message ->
|
onContentMessage { message ->
|
||||||
val chat = message.chat
|
val chat = message.chat
|
||||||
if (chat is ChannelChat) {
|
if (chat is ChannelChat) {
|
||||||
@@ -32,8 +31,8 @@ suspend fun main(vararg args: String) {
|
|||||||
return@onContentMessage
|
return@onContentMessage
|
||||||
}
|
}
|
||||||
val answerText = "Oh, hi, " + when (chat) {
|
val answerText = "Oh, hi, " + when (chat) {
|
||||||
is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
|
||||||
is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
||||||
|
is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
||||||
is SupergroupChat -> (chat.username ?.username ?: getChat(chat).inviteLink) ?.let {
|
is SupergroupChat -> (chat.username ?.username ?: getChat(chat).inviteLink) ?.let {
|
||||||
chat.title.linkMarkdownV2(it)
|
chat.title.linkMarkdownV2(it)
|
||||||
} ?: chat.title
|
} ?: chat.title
|
||||||
@@ -48,5 +47,6 @@ suspend fun main(vararg args: String) {
|
|||||||
MarkdownV2
|
MarkdownV2
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { println(it) }
|
||||||
}.second.join()
|
}.second.join()
|
||||||
}
|
}
|
||||||
|
|||||||
32
KeyboardsBot/KeyboardsBotLib/build.gradle
Normal file
32
KeyboardsBot/KeyboardsBotLib/build.gradle
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm()
|
||||||
|
js(IR) {
|
||||||
|
browser()
|
||||||
|
binaries.executable()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('stdlib')
|
||||||
|
|
||||||
|
api "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
|
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.text.editMessageText
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.botCommand
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.buildEntities
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||||
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
|
private const val nextPageData = "next"
|
||||||
|
private const val previousPageData = "previous"
|
||||||
|
|
||||||
|
fun String.parsePageAndCount(): Pair<Int, Int>? {
|
||||||
|
val (pageString, countString) = split(" ").takeIf { it.count() > 1 } ?: return null
|
||||||
|
return Pair(
|
||||||
|
pageString.toIntOrNull() ?: return null,
|
||||||
|
countString.toIntOrNull() ?: return null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun InlineKeyboardBuilder.includePageButtons(page: Int, count: Int) {
|
||||||
|
val numericButtons = listOfNotNull(
|
||||||
|
page - 1,
|
||||||
|
page,
|
||||||
|
page + 1,
|
||||||
|
)
|
||||||
|
row {
|
||||||
|
val numbersRange = 1 .. count
|
||||||
|
numericButtons.forEach {
|
||||||
|
if (it in numbersRange) {
|
||||||
|
dataButton(it.toString(), "$it $count")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
row {
|
||||||
|
if (page - 1 > 2) {
|
||||||
|
dataButton("<<", "1 $count")
|
||||||
|
}
|
||||||
|
if (page - 1 > 1) {
|
||||||
|
dataButton("<", "${page - 2} $count")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page + 1 < count) {
|
||||||
|
dataButton(">", "${page + 2} $count")
|
||||||
|
}
|
||||||
|
if (page + 2 < count) {
|
||||||
|
dataButton(">>", "$count $count")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun activateKeyboardsBot(
|
||||||
|
token: String,
|
||||||
|
print: (Any) -> Unit
|
||||||
|
) {
|
||||||
|
val bot = telegramBot(token)
|
||||||
|
|
||||||
|
print(bot.getMe())
|
||||||
|
|
||||||
|
bot.buildBehaviourWithLongPolling(CoroutineScope(currentCoroutineContext() + SupervisorJob())) {
|
||||||
|
onCommandWithArgs("inline") { message, args ->
|
||||||
|
val numberOfPages = args.firstOrNull() ?.toIntOrNull() ?: 10
|
||||||
|
reply(
|
||||||
|
message,
|
||||||
|
"Your inline keyboard with $numberOfPages pages",
|
||||||
|
replyMarkup = inlineKeyboard {
|
||||||
|
row {
|
||||||
|
includePageButtons(1, numberOfPages)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMessageDataCallbackQuery {
|
||||||
|
val (page, count) = it.data.parsePageAndCount() ?: it.let {
|
||||||
|
answer(it, "Unsupported data :(")
|
||||||
|
return@onMessageDataCallbackQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
val text = "This is $page of $count"
|
||||||
|
|
||||||
|
editMessageText(
|
||||||
|
it.message.withContent<TextContent>() ?: it.let {
|
||||||
|
answer(it, "Unsupported message type :(")
|
||||||
|
return@onMessageDataCallbackQuery
|
||||||
|
},
|
||||||
|
text,
|
||||||
|
replyMarkup = inlineKeyboard {
|
||||||
|
row {
|
||||||
|
includePageButtons(page, count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnhandledCommand {
|
||||||
|
reply(
|
||||||
|
it,
|
||||||
|
buildEntities {
|
||||||
|
+"Use " + botCommand("inline") + " to get pagination inline keyboard"
|
||||||
|
},
|
||||||
|
replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) {
|
||||||
|
row {
|
||||||
|
simpleButton("/inline")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard"))
|
||||||
|
|
||||||
|
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
||||||
|
println(it)
|
||||||
|
}
|
||||||
|
}.join()
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import kotlinx.browser.document
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import org.w3c.dom.*
|
||||||
|
|
||||||
|
private val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
document.addEventListener(
|
||||||
|
"DOMContentLoaded",
|
||||||
|
{
|
||||||
|
val botsContainer = document.getElementById("bots_container") ?: return@addEventListener
|
||||||
|
|
||||||
|
(document.getElementById("bot_token_form") as? HTMLFormElement) ?.onsubmit = {
|
||||||
|
(document.getElementById("bot_token") as? HTMLInputElement) ?.value ?.let { token ->
|
||||||
|
val botContainer = document.createElement("div") as HTMLDivElement
|
||||||
|
botsContainer.append(botContainer)
|
||||||
|
|
||||||
|
val infoDiv = document.createElement("div") as HTMLDivElement
|
||||||
|
botContainer.append(infoDiv)
|
||||||
|
|
||||||
|
scope.launch {
|
||||||
|
activateKeyboardsBot(token) {
|
||||||
|
infoDiv.innerHTML = it.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
16
KeyboardsBot/KeyboardsBotLib/src/jsMain/resources/index.html
Normal file
16
KeyboardsBot/KeyboardsBotLib/src/jsMain/resources/index.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Keyboards bot</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="bot_token_form">
|
||||||
|
<input type="text" id="bot_token">
|
||||||
|
<input type="submit" value="Start bot">
|
||||||
|
</form>
|
||||||
|
<div id="start_offer">Type your bot token to the input above to start its work</div>
|
||||||
|
<script type="text/javascript" src="KeyboardsBotLib.js"></script>
|
||||||
|
<div id="bots_container"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
21
KeyboardsBot/jvm_launcher/build.gradle
Normal file
21
KeyboardsBot/jvm_launcher/build.gradle
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'application'
|
||||||
|
|
||||||
|
mainClassName="KeyboardsBotJvmKt"
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
|
implementation project(":KeyboardsBot:KeyboardsBotLib")
|
||||||
|
}
|
||||||
10
KeyboardsBot/jvm_launcher/src/main/kotlin/KeyboardsBotJvm.kt
Normal file
10
KeyboardsBot/jvm_launcher/src/main/kotlin/KeyboardsBotJvm.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
suspend fun main(args: Array<String>) {
|
||||||
|
withContext(Dispatchers.IO) { // IO for inheriting of it in side of activateKeyboardsBot
|
||||||
|
activateKeyboardsBot(args.first()) {
|
||||||
|
println(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,7 +15,7 @@ mainClassName="RandomFileSenderBotKt"
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
import dev.inmo.tgbotapi.bot.Ktor.telegramBot
|
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.getMe
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.media.sendDocument
|
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.reply
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviour
|
import dev.inmo.tgbotapi.extensions.api.send.withUploadDocumentAction
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.toInputFile
|
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.BotCommand
|
||||||
import kotlinx.coroutines.*
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.media.TelegramMediaDocument
|
||||||
|
import dev.inmo.tgbotapi.types.mediaCountInMediaGroup
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
private const val command = "send_file"
|
private const val command = "send_file"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This bot will send files inside of working directory OR from directory in the second argument
|
* This bot will send files inside of working directory OR from directory in the second argument.
|
||||||
|
* You may send /send_file command to this bot to get random file from the directory OR
|
||||||
|
* `/send_file $number` when you want to receive required number of files. For example,
|
||||||
|
* /send_file and `/send_file 1` will have the same effect - bot will send one random file.
|
||||||
|
* But if you will send `/send_file 5` it will choose 5 random files and send them as group
|
||||||
*/
|
*/
|
||||||
suspend fun main(args: Array<String>) {
|
suspend fun main(args: Array<String>) {
|
||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
@@ -23,25 +32,63 @@ suspend fun main(args: Array<String>) {
|
|||||||
if (currentRoot.isFile) {
|
if (currentRoot.isFile) {
|
||||||
return currentRoot
|
return currentRoot
|
||||||
} else {
|
} else {
|
||||||
return pickFile(currentRoot.listFiles() ?.random() ?: return null)
|
return pickFile(currentRoot.listFiles() ?.takeIf { it.isNotEmpty() } ?.random() ?: return null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun TelegramBot.sendFiles(chat: Chat, files: List<File>) {
|
||||||
|
when (files.size) {
|
||||||
|
1 -> sendDocument(
|
||||||
|
chat.id,
|
||||||
|
files.first().asMultipartFile(),
|
||||||
|
protectContent = true
|
||||||
|
)
|
||||||
|
else -> sendDocumentsGroup(
|
||||||
|
chat,
|
||||||
|
files.map { TelegramMediaDocument(it.asMultipartFile()) },
|
||||||
|
protectContent = true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val bot = telegramBot(botToken)
|
val bot = telegramBot(botToken)
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
|
||||||
|
|
||||||
bot.buildBehaviour(scope) {
|
bot.buildBehaviourWithLongPolling (defaultExceptionsHandler = { it.printStackTrace() }) {
|
||||||
onCommand(command.toRegex()) { message ->
|
onCommandWithArgs(command) { message, args ->
|
||||||
pickFile() ?.let {
|
|
||||||
bot.sendDocument(
|
withUploadDocumentAction(message.chat) {
|
||||||
message.chat.id,
|
val count = args.firstOrNull() ?.toIntOrNull() ?: 1
|
||||||
it.toInputFile()
|
var sent = false
|
||||||
)
|
|
||||||
} ?: bot.reply(message, "Nothing selected :(")
|
var left = count
|
||||||
|
val chosen = mutableListOf<File>()
|
||||||
|
|
||||||
|
while (left > 0) {
|
||||||
|
left--
|
||||||
|
val picked = pickFile() ?: continue
|
||||||
|
chosen.add(picked)
|
||||||
|
if (chosen.size >= mediaCountInMediaGroup.last) {
|
||||||
|
sendFiles(message.chat, chosen)
|
||||||
|
chosen.clear()
|
||||||
|
sent = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chosen.isNotEmpty()) {
|
||||||
|
sendFiles(message.chat, chosen)
|
||||||
|
sent = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sent) {
|
||||||
|
bot.reply(message, "Nothing selected :(")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setMyCommands(
|
setMyCommands(
|
||||||
BotCommand(command, "Send some random file in picker directory")
|
BotCommand(command, "Send some random file in picker directory")
|
||||||
)
|
)
|
||||||
|
|
||||||
println(getMe())
|
println(getMe())
|
||||||
}.join()
|
}.join()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
|
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.bot.Ktor.telegramBot
|
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
import dev.inmo.tgbotapi.extensions.api.send.media.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
|
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.triggers_handling.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlin.coroutines.coroutineContext
|
|
||||||
|
|
||||||
suspend fun activateResenderBot(
|
suspend fun activateResenderBot(
|
||||||
token: String,
|
token: String,
|
||||||
@@ -16,20 +18,37 @@ suspend fun activateResenderBot(
|
|||||||
|
|
||||||
print(bot.getMe())
|
print(bot.getMe())
|
||||||
|
|
||||||
bot.buildBehaviour(CoroutineScope(coroutineContext + SupervisorJob())) {
|
bot.buildBehaviourWithLongPolling(CoroutineScope(currentCoroutineContext() + SupervisorJob())) {
|
||||||
onContentMessage(
|
onContentMessage(
|
||||||
additionalFilter = { it !is MediaGroupMessage<*> }
|
initialFilter = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter = MessageFilterByChat
|
||||||
) {
|
) {
|
||||||
executeUnsafe(it.content.createResend(it.chat.id, replyToMessageId = it.messageId))
|
val chat = it.chat
|
||||||
|
withTypingAction(chat) {
|
||||||
|
executeUnsafe(it.content.createResend(chat.id, replyToMessageId = it.messageId))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onVisualGallery {
|
onVisualGallery {
|
||||||
sendVisualMediaGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
val chat = it.chat ?: return@onVisualGallery
|
||||||
|
withUploadPhotoAction(chat) {
|
||||||
|
sendVisualMediaGroup(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onPlaylist {
|
onPlaylist {
|
||||||
sendPlaylist(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
val chat = it.chat ?: return@onPlaylist
|
||||||
|
withUploadDocumentAction(chat) {
|
||||||
|
sendPlaylist(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onDocumentsGroup {
|
onDocumentsGroup {
|
||||||
sendDocumentsGroup(it.chat!!, it.map { it.content.toMediaGroupMemberInputMedia() })
|
val chat = it.chat ?: return@onDocumentsGroup
|
||||||
|
withUploadDocumentAction(chat) {
|
||||||
|
sendDocumentsGroup(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
||||||
|
println(it)
|
||||||
}
|
}
|
||||||
}.join()
|
}.join()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,7 +15,7 @@ mainClassName="ResenderBotJvmKt"
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation project(":ResenderBot:ResenderBotLib")
|
implementation project(":ResenderBot:ResenderBotLib")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,7 +15,7 @@ mainClassName="SlotMachineDetectorBotKt"
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,26 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.safely
|
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||||
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.behaviour_builder.buildBehaviourWithLongPolling
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onDice
|
||||||
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.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 kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
|
|
||||||
suspend fun main(args: Array<String>) {
|
suspend fun main(args: Array<String>) {
|
||||||
val bot = telegramBot(args.first())
|
val bot = telegramBot(args.first())
|
||||||
|
|
||||||
val scope = CoroutineScope(Dispatchers.Default)
|
bot.buildBehaviourWithLongPolling(scope = CoroutineScope(Dispatchers.IO)) {
|
||||||
bot.longPolling(scope = scope) {
|
onDice {
|
||||||
filterContentMessages<DiceContent>(scope).onEach {
|
|
||||||
val content = it.content
|
val content = it.content
|
||||||
val dice = content.dice
|
val dice = content.dice
|
||||||
val diceType = dice.animationType
|
val diceType = dice.animationType
|
||||||
|
|
||||||
safely ({ it.printStackTrace() }) {
|
if (diceType == SlotMachineDiceAnimationType) {
|
||||||
if (diceType == SlotMachineDiceAnimationType) {
|
val result = dice.calculateSlotMachineResult() ?: return@onDice
|
||||||
val result = dice.calculateSlotMachineResult() ?: return@safely
|
bot.reply(it, "${result.leftReel}|${result.centerReel}|${result.rightReel}")
|
||||||
bot.reply(it, "${result.leftReel}|${result.centerReel}|${result.rightReel}")
|
} else {
|
||||||
} else {
|
bot.reply(it, "There is no slot machine dice in message")
|
||||||
bot.reply(it, "There is no slot machine dice in message")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.launchIn(scope)
|
}
|
||||||
}
|
}.join()
|
||||||
|
}
|
||||||
scope.coroutineContext[Job]!!.join()
|
|
||||||
}
|
|
||||||
|
|||||||
17
WebApp/README.md
Normal file
17
WebApp/README.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# WebApp
|
||||||
|
|
||||||
|
Here you may find simple example of `WebApp`. For work of this example you will need one of two things:
|
||||||
|
|
||||||
|
* Your own domain with SSL (letsencrypt is okay)
|
||||||
|
* Test account in telegram
|
||||||
|
|
||||||
|
What is there in this module:
|
||||||
|
|
||||||
|
* JVM part of this example is a server with simple static webapp sharing and bot which just gives the webapp button to open webapp
|
||||||
|
* JS part is the WebApp with one button and reacting to chaged user theme and app viewport
|
||||||
|
|
||||||
|
## How to run
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
./gradlew run --args="TOKEN WEB_APP_ADDRESS"
|
||||||
|
```
|
||||||
55
WebApp/build.gradle
Normal file
55
WebApp/build.gradle
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'application'
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm()
|
||||||
|
js(IR) {
|
||||||
|
browser()
|
||||||
|
binaries.executable()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('stdlib')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jsMain {
|
||||||
|
dependencies {
|
||||||
|
implementation "dev.inmo:tgbotapi.webapps:$telegram_bot_api_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jvmMain {
|
||||||
|
dependencies {
|
||||||
|
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
||||||
|
implementation "dev.inmo:micro_utils.ktor.server:$micro_utils_version"
|
||||||
|
implementation "io.ktor:ktor-server-cio:$ktor_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClassName = "WebAppServerKt"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName("compileKotlinJvm")
|
||||||
|
.dependsOn(jsBrowserDistribution)
|
||||||
|
tasks.getByName("compileKotlinJvm").configure {
|
||||||
|
mustRunAfter jsBrowserDistribution
|
||||||
|
}
|
||||||
55
WebApp/src/jsMain/kotlin/main.kt
Normal file
55
WebApp/src/jsMain/kotlin/main.kt
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
|
import dev.inmo.tgbotapi.types.webAppQueryIdField
|
||||||
|
import dev.inmo.tgbotapi.webapps.*
|
||||||
|
import io.ktor.client.HttpClient
|
||||||
|
import io.ktor.client.call.receive
|
||||||
|
import io.ktor.client.request.*
|
||||||
|
import io.ktor.client.statement.HttpResponse
|
||||||
|
import io.ktor.client.statement.readText
|
||||||
|
import io.ktor.http.*
|
||||||
|
import io.ktor.http.content.TextContent
|
||||||
|
import kotlinx.browser.document
|
||||||
|
import kotlinx.browser.window
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import kotlinx.dom.appendElement
|
||||||
|
import kotlinx.dom.appendText
|
||||||
|
import org.w3c.dom.HTMLElement
|
||||||
|
|
||||||
|
fun HTMLElement.log(text: String) {
|
||||||
|
appendElement("p", {})
|
||||||
|
appendText(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
console.log("Web app started")
|
||||||
|
window.onload = {
|
||||||
|
val scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
runCatching {
|
||||||
|
document.body ?.appendElement("button") {
|
||||||
|
addEventListener("click", {
|
||||||
|
scope.launchSafelyWithoutExceptions {
|
||||||
|
handleResult({ "Clicked" }) {
|
||||||
|
HttpClient().post("${window.location.origin.removeSuffix("/")}/inline") {
|
||||||
|
parameter(webAppQueryIdField, it)
|
||||||
|
setBody(TextContent("Clicked", ContentType.Text.Plain))
|
||||||
|
document.body ?.log(url.build().toString())
|
||||||
|
}.coroutineContext.job.join()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
appendText("Example button")
|
||||||
|
} ?: window.alert("Unable to load body")
|
||||||
|
webApp.apply {
|
||||||
|
onThemeChanged {
|
||||||
|
document.body ?.log("Theme changed: ${webApp.themeParams}")
|
||||||
|
}
|
||||||
|
onViewportChanged {
|
||||||
|
document.body ?.log("Viewport changed: ${it.isStateStable}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
webApp.ready()
|
||||||
|
}.onFailure {
|
||||||
|
window.alert(it.stackTraceToString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
WebApp/src/jsMain/resources/index.html
Normal file
11
WebApp/src/jsMain/resources/index.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Web App Example</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="application/javascript" src="https://telegram.org/js/telegram-web-app.js"></script>
|
||||||
|
<script type="application/javascript" src="WebApp.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
107
WebApp/src/jvmMain/kotlin/WebAppServer.kt
Normal file
107
WebApp/src/jvmMain/kotlin/WebAppServer.kt
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
|
import dev.inmo.micro_utils.ktor.server.createKtorServer
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
||||||
|
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.telegramBot
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.botCommand
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.formatting.buildEntities
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
||||||
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
||||||
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
||||||
|
import dev.inmo.tgbotapi.types.webAppQueryIdField
|
||||||
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
|
import io.ktor.server.application.call
|
||||||
|
import io.ktor.server.http.content.*
|
||||||
|
import io.ktor.server.request.receiveText
|
||||||
|
import io.ktor.server.response.respond
|
||||||
|
import io.ktor.server.routing.post
|
||||||
|
import io.ktor.server.routing.routing
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts two parameters:
|
||||||
|
*
|
||||||
|
* * Telegram Token
|
||||||
|
* * URL where will be placed
|
||||||
|
*
|
||||||
|
* Will start the server to share the static (index.html and WebApp.js) on 0.0.0.0:8080
|
||||||
|
*/
|
||||||
|
@OptIn(PreviewFeature::class)
|
||||||
|
suspend fun main(vararg args: String) {
|
||||||
|
val bot = telegramBot(args.first(), testServer = args.any { it == "testServer" })
|
||||||
|
createKtorServer(
|
||||||
|
"0.0.0.0",
|
||||||
|
8080,
|
||||||
|
additionalEngineEnvironmentConfigurator = {
|
||||||
|
parentCoroutineContext += Dispatchers.IO
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
routing {
|
||||||
|
static {
|
||||||
|
files(File("WebApp/build/distributions"))
|
||||||
|
default("WebApp/build/distributions/index.html")
|
||||||
|
}
|
||||||
|
post("inline") {
|
||||||
|
val requestBody = call.receiveText()
|
||||||
|
val queryId = call.parameters[webAppQueryIdField] ?: error("$webAppQueryIdField should be presented")
|
||||||
|
|
||||||
|
bot.answer(queryId, InlineQueryResultArticle(queryId, "Result", InputTextMessageContent(requestBody)))
|
||||||
|
call.respond(HttpStatusCode.OK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.start(false)
|
||||||
|
|
||||||
|
bot.buildBehaviourWithLongPolling(
|
||||||
|
defaultExceptionsHandler = { it.printStackTrace() }
|
||||||
|
) {
|
||||||
|
onCommand("reply_markup") {
|
||||||
|
reply(
|
||||||
|
it,
|
||||||
|
"Button",
|
||||||
|
replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) {
|
||||||
|
row {
|
||||||
|
webAppButton("Open WebApp", WebAppInfo(args[1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onCommand("inline") {
|
||||||
|
reply(
|
||||||
|
it,
|
||||||
|
"Button",
|
||||||
|
replyMarkup = inlineKeyboard {
|
||||||
|
row {
|
||||||
|
webAppButton("Open WebApp", WebAppInfo(args[1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onUnhandledCommand {
|
||||||
|
reply(
|
||||||
|
it,
|
||||||
|
buildEntities {
|
||||||
|
+"Use " + botCommand("inline") + " to get inline web app button\n"
|
||||||
|
+"Use " + botCommand("reply_markup") + " to get reply markup web app button\n"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
setMyCommands(
|
||||||
|
BotCommand("reply_markup", "Use to get reply markup keyboard with web app trigger"),
|
||||||
|
BotCommand("inline", "Use to get inline keyboard with web app trigger"),
|
||||||
|
)
|
||||||
|
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
||||||
|
println(it)
|
||||||
|
}
|
||||||
|
println(getMe())
|
||||||
|
}.join()
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
mavenCentral()
|
||||||
if (project.hasProperty("GITHUB_USER") && project.hasProperty("GITHUB_TOKEN")) {
|
if (project.hasProperty("GITHUB_USER") && project.hasProperty("GITHUB_TOKEN")) {
|
||||||
maven {
|
maven {
|
||||||
url "https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"
|
url "https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"
|
||||||
@@ -12,4 +12,4 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
# Due to parallel compilation project require next amount of memory on full build
|
||||||
|
org.gradle.jvmargs=-Xmx768m
|
||||||
|
|
||||||
|
|
||||||
kotlin_version=1.5.20
|
kotlin_version=1.6.21
|
||||||
telegram_bot_api_version=0.35.1
|
telegram_bot_api_version=1.0.0
|
||||||
micro_utils_version=0.5.15
|
micro_utils_version=0.10.4
|
||||||
|
ktor_version=2.0.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
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
include ":ForwardInfoSenderBot"
|
include ":ForwardInfoSenderBot"
|
||||||
|
|
||||||
include ":RandomFileSenderBot"
|
include ":RandomFileSenderBot"
|
||||||
|
|
||||||
include ":HelloBot"
|
include ":HelloBot"
|
||||||
|
|
||||||
include ":GetMeBot"
|
include ":GetMeBot"
|
||||||
|
|
||||||
include ":FilesLoaderBot"
|
include ":FilesLoaderBot"
|
||||||
|
|
||||||
include ":ResenderBot:ResenderBotLib"
|
include ":ResenderBot:ResenderBotLib"
|
||||||
include ":ResenderBot:jvm_launcher"
|
include ":ResenderBot:jvm_launcher"
|
||||||
|
|
||||||
|
include ":KeyboardsBot:KeyboardsBotLib"
|
||||||
|
include ":KeyboardsBot:jvm_launcher"
|
||||||
|
|
||||||
include ":SlotMachineDetectorBot"
|
include ":SlotMachineDetectorBot"
|
||||||
|
|
||||||
|
include ":WebApp"
|
||||||
|
|
||||||
include ":FSMBot"
|
include ":FSMBot"
|
||||||
|
|||||||
Reference in New Issue
Block a user