mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2025-12-27 16:39:12 +00:00
Compare commits
1 Commits
6.0.0
...
8c36733c7a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c36733c7a |
@@ -1,9 +0,0 @@
|
|||||||
# ChatAvatarSetter
|
|
||||||
|
|
||||||
This bot will set the chat avatar based on the image sent to bot
|
|
||||||
|
|
||||||
## Launch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
../gradlew run --args="BOT_TOKEN"
|
|
||||||
```
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'application'
|
|
||||||
|
|
||||||
mainClassName="ChatAvatarSetterKt"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.modify.setChatPhoto
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.files.downloadFile
|
|
||||||
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.onPhoto
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.asMultipartFile
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
|
|
||||||
suspend fun main(args: Array<String>) {
|
|
||||||
val bot = telegramBot(args.first())
|
|
||||||
|
|
||||||
bot.buildBehaviourWithLongPolling(scope = CoroutineScope(Dispatchers.IO)) {
|
|
||||||
onPhoto {
|
|
||||||
val bytes = downloadFile(it.content)
|
|
||||||
runCatchingSafely {
|
|
||||||
setChatPhoto(
|
|
||||||
it.chat.id,
|
|
||||||
bytes.asMultipartFile("sample.jpg")
|
|
||||||
)
|
|
||||||
}.onSuccess { b ->
|
|
||||||
if (b) {
|
|
||||||
reply(it, "Done")
|
|
||||||
} else {
|
|
||||||
reply(it, "Something went wrong")
|
|
||||||
}
|
|
||||||
}.onFailure { e ->
|
|
||||||
e.printStackTrace()
|
|
||||||
|
|
||||||
reply(it, "Something went wrong (see logs)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.join()
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# DeepLinksBot
|
|
||||||
|
|
||||||
This bot will send you deeplink to this bot when you send some text message and react on the `start` button
|
|
||||||
|
|
||||||
## Launch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
../gradlew run --args="BOT_TOKEN"
|
|
||||||
```
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'application'
|
|
||||||
|
|
||||||
mainClassName="DeepLinksBotKt"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelySkippingExceptions
|
|
||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitDeepLinks
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.makeTelegramDeepLink
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This bot will send you deeplink to this bot when you send some text message and react on the `start` button
|
|
||||||
*/
|
|
||||||
suspend fun main(vararg args: String) {
|
|
||||||
val botToken = args.first()
|
|
||||||
|
|
||||||
telegramBotWithBehaviourAndLongPolling(botToken) {
|
|
||||||
val me = bot.getMe()
|
|
||||||
println(me)
|
|
||||||
|
|
||||||
onText(
|
|
||||||
initialFilter = { it.content.textSources.none { it is BotCommandTextSource } } // excluding messages with commands
|
|
||||||
) {
|
|
||||||
reply(it, makeTelegramDeepLink(me.username, it.content.text))
|
|
||||||
}
|
|
||||||
|
|
||||||
onCommand("start", requireOnlyCommandInMessage = true) { // handling of `start` without args
|
|
||||||
reply(it, "Hi :) Send me any text and I will try hard to create deeplink for you")
|
|
||||||
}
|
|
||||||
onDeepLink { (it, deepLink) ->
|
|
||||||
reply(it, "Ok, I got deep link \"${deepLink}\" in trigger")
|
|
||||||
}
|
|
||||||
waitDeepLinks().subscribeSafelyWithoutExceptions(this) { (it, deepLink) ->
|
|
||||||
reply(it, "Ok, I got deep link \"${deepLink}\" in waiter")
|
|
||||||
println(triggersHolder.handleableCommandsHolder.handleable)
|
|
||||||
}
|
|
||||||
}.second.join()
|
|
||||||
}
|
|
||||||
@@ -6,21 +6,16 @@ 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.*
|
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.extensions.sameThread
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
||||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
|
||||||
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.utils.botCommand
|
|
||||||
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.filter
|
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
|
||||||
sealed interface BotState : State
|
sealed interface BotState : State
|
||||||
data class ExpectContentOrStopState(override val context: IdChatIdentifier, val sourceMessage: CommonMessage<TextContent>) : BotState
|
data class ExpectContentOrStopState(override val context: ChatId, val sourceMessage: CommonMessage<TextContent>) : BotState
|
||||||
data class StopState(override val context: IdChatIdentifier) : BotState
|
data class StopState(override val context: ChatId) : BotState
|
||||||
|
|
||||||
suspend fun main(args: Array<String>) {
|
suspend fun main(args: Array<String>) {
|
||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
@@ -42,15 +37,14 @@ suspend fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
strictlyOn<ExpectContentOrStopState> {
|
strictlyOn<ExpectContentOrStopState> {
|
||||||
send(
|
sendMessage(
|
||||||
it.context,
|
it.context,
|
||||||
) {
|
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 contentMessage = waitAnyContentMessage().filter { message ->
|
val contentMessage = waitContentMessage().first()
|
||||||
message.sameThread(it.sourceMessage)
|
|
||||||
}.first()
|
|
||||||
val content = contentMessage.content
|
val content = contentMessage.content
|
||||||
|
|
||||||
when {
|
when {
|
||||||
@@ -62,14 +56,12 @@ suspend fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
strictlyOn<StopState> {
|
strictlyOn<StopState> {
|
||||||
send(it.context) { +"You have stopped sending of content" }
|
send(it.context, "You have stopped sending of content")
|
||||||
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
command(
|
command("start") {
|
||||||
"start"
|
|
||||||
) {
|
|
||||||
startChain(ExpectContentOrStopState(it.chat.id, it))
|
startChain(ExpectContentOrStopState(it.chat.id, it))
|
||||||
}
|
}
|
||||||
}.second.join()
|
}.second.join()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ 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.telegramBotWithBehaviourAndLongPolling
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
|
||||||
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
|
||||||
@@ -15,21 +14,14 @@ import java.io.File
|
|||||||
*/
|
*/
|
||||||
suspend fun main(args: Array<String>) {
|
suspend fun main(args: Array<String>) {
|
||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
val directoryOrFile = args.getOrNull(1) ?.let { File(it) } ?: File("/tmp/")
|
val directoryOrFile = args.getOrNull(1) ?.let { File(it) } ?: File("")
|
||||||
directoryOrFile.mkdirs()
|
directoryOrFile.mkdirs()
|
||||||
|
|
||||||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||||
onCommand("start") {
|
|
||||||
reply(it, "Send me any media (like photo or video) to download it")
|
|
||||||
}
|
|
||||||
onMedia(initialFilter = null) {
|
onMedia(initialFilter = null) {
|
||||||
val pathedFile = bot.getFileAdditionalInfo(it.content.media)
|
val pathedFile = bot.getFileAdditionalInfo(it.content.media)
|
||||||
val outFile = File(directoryOrFile, pathedFile.filePath.filenameFromUrl)
|
val outFile = File(directoryOrFile, pathedFile.filePath.filenameFromUrl)
|
||||||
runCatching {
|
|
||||||
bot.downloadFile(it.content.media, outFile)
|
bot.downloadFile(it.content.media, outFile)
|
||||||
}.onFailure {
|
|
||||||
it.printStackTrace()
|
|
||||||
}
|
|
||||||
reply(it, "Saved to ${outFile.absolutePath}")
|
reply(it, "Saved to ${outFile.absolutePath}")
|
||||||
}
|
}
|
||||||
onContentMessage { println(it) }
|
onContentMessage { println(it) }
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
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.makeLink
|
import dev.inmo.tgbotapi.extensions.utils.formatting.*
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonBot
|
import dev.inmo.tgbotapi.types.chat.CommonBot
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||||
import dev.inmo.tgbotapi.types.message.*
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
import dev.inmo.tgbotapi.utils.buildEntities
|
|
||||||
import dev.inmo.tgbotapi.utils.code
|
|
||||||
import dev.inmo.tgbotapi.utils.link
|
|
||||||
import dev.inmo.tgbotapi.utils.regular
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,14 +16,14 @@ suspend fun main(vararg args: String) {
|
|||||||
val botToken = args.first()
|
val botToken = args.first()
|
||||||
|
|
||||||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
||||||
onContentMessage {
|
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"
|
||||||
is ForwardInfo.ByAnonymous -> {
|
is AnonymousForwardInfo -> {
|
||||||
regular("Anonymous user which signed as \"") + code(forwardInfo.senderName) + "\""
|
regular("Anonymous user which signed as \"") + code(forwardInfo.senderName) + "\""
|
||||||
}
|
}
|
||||||
is ForwardInfo.ByUser -> {
|
is UserForwardInfo -> {
|
||||||
val user = forwardInfo.from
|
val user = forwardInfo.from
|
||||||
when (user) {
|
when (user) {
|
||||||
is CommonUser -> {
|
is CommonUser -> {
|
||||||
@@ -37,21 +33,12 @@ suspend fun main(vararg args: String) {
|
|||||||
regular("User ")
|
regular("User ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is CommonBot,
|
is CommonBot,
|
||||||
is ExtendedBot -> regular("Bot ")
|
is ExtendedBot -> regular("Bot ")
|
||||||
} + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})"
|
} + code(user.id.chatId.toString()) + " (${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})"
|
||||||
}
|
}
|
||||||
is ForwardInfo.PublicChat.FromChannel -> {
|
is ForwardFromChannelInfo -> regular("Channel (") + code((forwardInfo.channelChat).title) + ")"
|
||||||
regular("Channel (") + (forwardInfo.channelChat.username ?.let {
|
is ForwardFromSupergroupInfo -> regular("Supergroup (") + code((forwardInfo.group).title) + ")"
|
||||||
link(
|
|
||||||
forwardInfo.channelChat.title,
|
|
||||||
makeLink(it)
|
|
||||||
)
|
|
||||||
} ?: code(forwardInfo.channelChat.title)) + ")"
|
|
||||||
}
|
|
||||||
is ForwardInfo.PublicChat.FromSupergroup -> regular("Supergroup (") + code(forwardInfo.group.title) + ")"
|
|
||||||
is ForwardInfo.PublicChat.SentByChannel -> regular("Sent by channel (") + code(forwardInfo.channelChat.title) + ")"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reply(it, toAnswer)
|
reply(it, toAnswer)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ buildscript {
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
|
|
||||||
mainClassName="GetMeBotKt"
|
mainClassName="HelloBotKt"
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -1,16 +1,5 @@
|
|||||||
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
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.closeForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.createForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.deleteForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.reopenForumTopic
|
|
||||||
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.onForumTopicClosed
|
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
|
||||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
|
||||||
import dev.inmo.tgbotapi.types.ForumTopic
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is one of the most easiest bot - it will just print information about itself
|
* This is one of the most easiest bot - it will just print information about itself
|
||||||
|
|||||||
@@ -3,11 +3,8 @@ import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
|||||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
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.extensions.raw.sender_chat
|
|
||||||
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.ifChannelChat
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.ifFromChannelGroupContentMessage
|
|
||||||
import dev.inmo.tgbotapi.types.chat.*
|
import dev.inmo.tgbotapi.types.chat.*
|
||||||
import dev.inmo.tgbotapi.types.chat.GroupChat
|
import dev.inmo.tgbotapi.types.chat.GroupChat
|
||||||
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
||||||
@@ -27,35 +24,21 @@ suspend fun main(vararg args: String) {
|
|||||||
telegramBotWithBehaviourAndLongPolling(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) {
|
||||||
val answerText = when (val chat = message.chat) {
|
|
||||||
is ChannelChat -> {
|
|
||||||
val answer = "Hi everybody in this channel \"${chat.title}\""
|
val answer = "Hi everybody in this channel \"${chat.title}\""
|
||||||
reply(message, answer, MarkdownV2)
|
send(chat, answer, MarkdownV2)
|
||||||
return@onContentMessage
|
return@onContentMessage
|
||||||
}
|
}
|
||||||
is PrivateChat -> {
|
val answerText = "Oh, hi, " + when (chat) {
|
||||||
reply(message, "Hi, " + "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id), MarkdownV2)
|
is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
||||||
return@onContentMessage
|
is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
||||||
}
|
|
||||||
is GroupChat -> {
|
|
||||||
message.ifFromChannelGroupContentMessage {
|
|
||||||
val answer = "Hi, ${it.senderChat.title}"
|
|
||||||
reply(message, answer, MarkdownV2)
|
|
||||||
return@onContentMessage
|
|
||||||
}
|
|
||||||
"Oh, hi, " + when (chat) {
|
|
||||||
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
|
||||||
else -> bot.getChat(chat).inviteLink ?.let {
|
is GroupChat -> bot.getChat(chat).inviteLink ?.let {
|
||||||
chat.title.linkMarkdownV2(it)
|
chat.title.linkMarkdownV2(it)
|
||||||
} ?: chat.title
|
} ?: chat.title
|
||||||
}
|
else -> "Unknown :(".escapeMarkdownV2Common()
|
||||||
}
|
|
||||||
is UnknownExtendedChat,
|
|
||||||
is UnknownChatType -> "Unknown :(".escapeMarkdownV2Common()
|
|
||||||
else -> error("Something went wrong: unknown type of chat $chat")
|
|
||||||
}
|
}
|
||||||
reply(
|
reply(
|
||||||
message,
|
message,
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ import dev.inmo.tgbotapi.extensions.api.edit.edit
|
|||||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
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.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.withContent
|
import dev.inmo.tgbotapi.extensions.utils.withContent
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.utils.*
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
private const val nextPageData = "next"
|
private const val nextPageData = "next"
|
||||||
@@ -70,14 +71,13 @@ suspend fun activateKeyboardsBot(
|
|||||||
val numberOfPages = args.firstOrNull() ?.toIntOrNull() ?: 10
|
val numberOfPages = args.firstOrNull() ?.toIntOrNull() ?: 10
|
||||||
reply(
|
reply(
|
||||||
message,
|
message,
|
||||||
|
"Your inline keyboard with $numberOfPages pages",
|
||||||
replyMarkup = inlineKeyboard {
|
replyMarkup = inlineKeyboard {
|
||||||
row {
|
row {
|
||||||
includePageButtons(1, numberOfPages)
|
includePageButtons(1, numberOfPages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
)
|
||||||
regular("Your inline keyboard with $numberOfPages pages")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessageDataCallbackQuery {
|
onMessageDataCallbackQuery {
|
||||||
@@ -86,33 +86,34 @@ suspend fun activateKeyboardsBot(
|
|||||||
return@onMessageDataCallbackQuery
|
return@onMessageDataCallbackQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val text = "This is $page of $count"
|
||||||
|
|
||||||
edit(
|
edit(
|
||||||
it.message.withContent<TextContent>() ?: it.let {
|
it.message.withContent<TextContent>() ?: it.let {
|
||||||
answer(it, "Unsupported message type :(")
|
answer(it, "Unsupported message type :(")
|
||||||
return@onMessageDataCallbackQuery
|
return@onMessageDataCallbackQuery
|
||||||
},
|
},
|
||||||
|
text,
|
||||||
replyMarkup = inlineKeyboard {
|
replyMarkup = inlineKeyboard {
|
||||||
row {
|
row {
|
||||||
includePageButtons(page, count)
|
includePageButtons(page, count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
)
|
||||||
regular("This is $page of $count")
|
|
||||||
}
|
|
||||||
answer(it)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onUnhandledCommand {
|
onUnhandledCommand {
|
||||||
reply(
|
reply(
|
||||||
it,
|
it,
|
||||||
|
buildEntities {
|
||||||
|
+"Use " + botCommand("inline") + " to get pagination inline keyboard"
|
||||||
|
},
|
||||||
replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) {
|
replyMarkup = replyKeyboard(resizeKeyboard = true, oneTimeKeyboard = true) {
|
||||||
row {
|
row {
|
||||||
simpleButton("/inline")
|
simpleButton("/inline")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
)
|
||||||
+"Use " + botCommand("inline") + " to get pagination inline keyboard"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard"))
|
setMyCommands(BotCommand("inline", "Creates message with pagination inline keyboard"))
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
# LiveLocationsBot
|
|
||||||
|
|
||||||
This bot will send you live location and update it from time to time
|
|
||||||
|
|
||||||
## Launch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
../gradlew run --args="BOT_TOKEN"
|
|
||||||
```
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'application'
|
|
||||||
|
|
||||||
mainClassName="LiveLocationsBotKt"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.EditLiveLocationInfo
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.edit
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.handleLiveLocation
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitMessageDataCallbackQuery
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.oneOf
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.parallel
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onContentMessage
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extensions.sameMessage
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.textMentionMarkdownV2
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.ifFromChannelGroupContentMessage
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.dataButton
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.flatInlineKeyboard
|
|
||||||
import dev.inmo.tgbotapi.types.chat.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.GroupChat
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
|
||||||
import dev.inmo.tgbotapi.types.chat.SupergroupChat
|
|
||||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
|
||||||
import dev.inmo.tgbotapi.types.message.MarkdownV2
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.LiveLocationContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
|
||||||
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Common
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.coroutines.flow.FlowCollector
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
|
||||||
import kotlinx.coroutines.flow.filter
|
|
||||||
import kotlinx.coroutines.flow.first
|
|
||||||
import kotlinx.coroutines.flow.flow
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This bot will send you live location and update it from time to time
|
|
||||||
*/
|
|
||||||
suspend fun main(vararg args: String) {
|
|
||||||
val botToken = args.first()
|
|
||||||
|
|
||||||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) {
|
|
||||||
val locationsFlow = flow {
|
|
||||||
var i = 0
|
|
||||||
while (isActive) {
|
|
||||||
val newInfo = EditLiveLocationInfo(
|
|
||||||
latitude = i.toDouble(),
|
|
||||||
longitude = i.toDouble(),
|
|
||||||
replyMarkup = flatInlineKeyboard {
|
|
||||||
dataButton("Cancel", "cancel")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
emit(newInfo)
|
|
||||||
i++
|
|
||||||
delay(3000L) // 3 seconds
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onCommand("start") {
|
|
||||||
// in this flow will be actual message with live location
|
|
||||||
val currentMessageState = MutableStateFlow<ContentMessage<LocationContent>?>(null)
|
|
||||||
val sendingJob = launch {
|
|
||||||
handleLiveLocation(
|
|
||||||
it.chat.id,
|
|
||||||
locationsFlow,
|
|
||||||
sentMessageFlow = FlowCollector { currentMessageState.emit(it) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
waitMessageDataCallbackQuery().filter {
|
|
||||||
it.message.sameMessage(
|
|
||||||
currentMessageState.value ?: return@filter false
|
|
||||||
) && it.data == "cancel"
|
|
||||||
}.first()
|
|
||||||
|
|
||||||
sendingJob.cancel() // ends live location
|
|
||||||
currentMessageState.value ?.let {
|
|
||||||
edit(it, replyMarkup = null) // removing reply keyboard
|
|
||||||
}
|
|
||||||
}
|
|
||||||
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { println(it) }
|
|
||||||
}.second.join()
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilte
|
|||||||
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.shortcuts.*
|
import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
|
||||||
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
suspend fun activateResenderBot(
|
suspend fun activateResenderBot(
|
||||||
@@ -21,23 +20,31 @@ suspend fun activateResenderBot(
|
|||||||
|
|
||||||
bot.buildBehaviourWithLongPolling(CoroutineScope(currentCoroutineContext() + SupervisorJob())) {
|
bot.buildBehaviourWithLongPolling(CoroutineScope(currentCoroutineContext() + SupervisorJob())) {
|
||||||
onContentMessage(
|
onContentMessage(
|
||||||
subcontextUpdatesFilter = MessageFilterByChat,
|
initialFilter = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter = MessageFilterByChat
|
||||||
) {
|
) {
|
||||||
val chat = it.chat
|
val chat = it.chat
|
||||||
|
withTypingAction(chat) {
|
||||||
val answer = withTypingAction(chat) {
|
executeUnsafe(it.content.createResend(chat.id, replyToMessageId = it.messageId))
|
||||||
executeUnsafe(
|
|
||||||
it.content.createResend(
|
|
||||||
chat.id,
|
|
||||||
messageThreadId = it.threadIdOrNull,
|
|
||||||
replyToMessageId = it.messageId
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
it.forEach(print)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onVisualGallery {
|
||||||
println("Answer info: $answer")
|
val chat = it.chat ?: return@onVisualGallery
|
||||||
|
withUploadPhotoAction(chat) {
|
||||||
|
send(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onPlaylist {
|
||||||
|
val chat = it.chat ?: return@onPlaylist
|
||||||
|
withUploadDocumentAction(chat) {
|
||||||
|
send(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onDocumentsGroup {
|
||||||
|
val chat = it.chat ?: return@onDocumentsGroup
|
||||||
|
withUploadDocumentAction(chat) {
|
||||||
|
send(chat, it.map { it.content.toMediaGroupMemberTelegramMedia() })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# RightsChanger
|
|
||||||
|
|
||||||
All the commands should be called with reply to some common user.
|
|
||||||
|
|
||||||
* Use `/simple` with bot to get request buttons for non-independent permissions change
|
|
||||||
* Use `/granular` with bot to get request buttons for independent permissions change
|
|
||||||
|
|
||||||
## Launch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
../gradlew run --args="BOT_TOKEN allowed_user_id_long"
|
|
||||||
```
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'application'
|
|
||||||
|
|
||||||
mainClassName="RightsChangerKt"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
|
||||||
}
|
|
||||||
@@ -1,255 +0,0 @@
|
|||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.members.getChatMember
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.members.restrictChatMember
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.edit
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|
||||||
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.onMessageDataCallbackQuery
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asContentMessage
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPossiblyReplyMessage
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.contentMessageOrNull
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.extendedGroupChatOrNull
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.fromUserMessageOrNull
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.restrictedChatMemberOrNull
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.dataButton
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.whenMemberChatMember
|
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|
||||||
import dev.inmo.tgbotapi.types.chat.ChatPermissions
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PublicChat
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import dev.inmo.tgbotapi.types.toChatId
|
|
||||||
import dev.inmo.tgbotapi.utils.row
|
|
||||||
|
|
||||||
suspend fun main(args: Array<String>) {
|
|
||||||
val botToken = args.first()
|
|
||||||
|
|
||||||
val bot = telegramBot(botToken)
|
|
||||||
|
|
||||||
val allowedAdmin = ChatId(args[1].toLong())
|
|
||||||
|
|
||||||
fun Boolean?.allowedSymbol() = when (this) {
|
|
||||||
true -> "✅"
|
|
||||||
false -> "❌"
|
|
||||||
null -> ""
|
|
||||||
}
|
|
||||||
|
|
||||||
val granularDataPrefix = "granular"
|
|
||||||
val messagesToggleGranularData = "$granularDataPrefix messages"
|
|
||||||
val otherMessagesToggleGranularData = "$granularDataPrefix other messages"
|
|
||||||
val audiosToggleGranularData = "$granularDataPrefix audios"
|
|
||||||
val voicesToggleGranularData = "$granularDataPrefix voices"
|
|
||||||
val videosToggleGranularData = "$granularDataPrefix videos"
|
|
||||||
val videoNotesToggleGranularData = "$granularDataPrefix video notes"
|
|
||||||
val photosToggleGranularData = "$granularDataPrefix photos"
|
|
||||||
val webPagePreviewToggleGranularData = "$granularDataPrefix web page preview"
|
|
||||||
val pollsToggleGranularData = "$granularDataPrefix polls"
|
|
||||||
val documentsToggleGranularData = "$granularDataPrefix documents"
|
|
||||||
|
|
||||||
val commonDataPrefix = "common"
|
|
||||||
val pollsToggleCommonData = "$commonDataPrefix polls"
|
|
||||||
val otherMessagesToggleCommonData = "$commonDataPrefix other messages"
|
|
||||||
val webPagePreviewToggleCommonData = "$commonDataPrefix web page preview"
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.getUserChatPermissions(chatId: ChatId, userId: UserId): ChatPermissions? {
|
|
||||||
val chatMember = getChatMember(chatId, userId)
|
|
||||||
return chatMember.restrictedChatMemberOrNull() ?: chatMember.whenMemberChatMember {
|
|
||||||
getChat(chatId).extendedGroupChatOrNull() ?.permissions
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.buildGranularKeyboard(chatId: ChatId, userId: UserId): InlineKeyboardMarkup? {
|
|
||||||
val permissions = getUserChatPermissions(chatId, userId) ?: return null
|
|
||||||
|
|
||||||
return inlineKeyboard {
|
|
||||||
row {
|
|
||||||
dataButton("Send messages${permissions.canSendMessages.allowedSymbol()}", messagesToggleGranularData)
|
|
||||||
dataButton("Send other messages${permissions.canSendOtherMessages.allowedSymbol()}", otherMessagesToggleGranularData)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
dataButton("Send audios${permissions.canSendAudios.allowedSymbol()}", audiosToggleGranularData)
|
|
||||||
dataButton("Send voices${permissions.canSendVoiceNotes.allowedSymbol()}", voicesToggleGranularData)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
dataButton("Send videos${permissions.canSendVideos.allowedSymbol()}", videosToggleGranularData)
|
|
||||||
dataButton("Send video notes${permissions.canSendVideoNotes.allowedSymbol()}", videoNotesToggleGranularData)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
dataButton("Send photos${permissions.canSendPhotos.allowedSymbol()}", photosToggleGranularData)
|
|
||||||
dataButton("Add web preview${permissions.canAddWebPagePreviews.allowedSymbol()}", webPagePreviewToggleGranularData)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
dataButton("Send polls${permissions.canSendPolls.allowedSymbol()}", pollsToggleGranularData)
|
|
||||||
dataButton("Send documents${permissions.canSendDocuments.allowedSymbol()}", documentsToggleGranularData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun BehaviourContext.buildCommonKeyboard(chatId: ChatId, userId: UserId): InlineKeyboardMarkup? {
|
|
||||||
val permissions = getUserChatPermissions(chatId, userId) ?: return null
|
|
||||||
|
|
||||||
return inlineKeyboard {
|
|
||||||
row {
|
|
||||||
dataButton("Send polls${permissions.canSendPolls.allowedSymbol()}", pollsToggleCommonData)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
dataButton("Send other messages${permissions.canSendOtherMessages.allowedSymbol()}", otherMessagesToggleCommonData)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
dataButton("Add web preview${permissions.canAddWebPagePreviews.allowedSymbol()}", webPagePreviewToggleCommonData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bot.buildBehaviourWithLongPolling(
|
|
||||||
defaultExceptionsHandler = {
|
|
||||||
println(it)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
onCommand("simple", initialFilter = { it.chat is PublicChat && it.fromUserMessageOrNull() ?.user ?.id == allowedAdmin }) {
|
|
||||||
val replyMessage = it.replyTo
|
|
||||||
val userInReply = replyMessage ?.fromUserMessageOrNull() ?.user ?.id ?: return@onCommand
|
|
||||||
reply(
|
|
||||||
replyMessage,
|
|
||||||
"Manage keyboard:",
|
|
||||||
replyMarkup = buildCommonKeyboard(it.chat.id.toChatId(), userInReply) ?: return@onCommand
|
|
||||||
)
|
|
||||||
}
|
|
||||||
onCommand("granular", initialFilter = { it.chat is PublicChat && it.fromUserMessageOrNull() ?.user ?.id == allowedAdmin }) {
|
|
||||||
val replyMessage = it.replyTo
|
|
||||||
val userInReply = replyMessage ?.fromUserMessageOrNull() ?.user ?.id ?: return@onCommand
|
|
||||||
reply(
|
|
||||||
replyMessage,
|
|
||||||
"Manage keyboard:",
|
|
||||||
replyMarkup = buildGranularKeyboard(it.chat.id.toChatId(), userInReply) ?: return@onCommand
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMessageDataCallbackQuery(
|
|
||||||
Regex("^${granularDataPrefix}.*"),
|
|
||||||
initialFilter = { it.user.id == allowedAdmin }
|
|
||||||
) {
|
|
||||||
val messageReply = it.message.commonMessageOrNull() ?.replyTo ?.fromUserMessageOrNull() ?: return@onMessageDataCallbackQuery
|
|
||||||
val userId = messageReply.user.id
|
|
||||||
val permissions = getUserChatPermissions(it.message.chat.id.toChatId(), userId) ?: return@onMessageDataCallbackQuery
|
|
||||||
val newPermission = when (it.data) {
|
|
||||||
messagesToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendMessages = permissions.canSendMessages ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
otherMessagesToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendOtherMessages = permissions.canSendOtherMessages ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
audiosToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendAudios = permissions.canSendAudios ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
voicesToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendVoiceNotes = permissions.canSendVoiceNotes ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
videosToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendVideos = permissions.canSendVideos ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
videoNotesToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendVideoNotes = permissions.canSendVideoNotes ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
photosToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendPhotos = permissions.canSendPhotos ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
webPagePreviewToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canAddWebPagePreviews = permissions.canAddWebPagePreviews ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
pollsToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendPolls = permissions.canSendPolls ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
documentsToggleGranularData -> {
|
|
||||||
permissions.copyGranular(
|
|
||||||
canSendDocuments = permissions.canSendDocuments ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else -> permissions.copyGranular()
|
|
||||||
}
|
|
||||||
|
|
||||||
restrictChatMember(
|
|
||||||
it.message.chat.id,
|
|
||||||
userId,
|
|
||||||
permissions = newPermission,
|
|
||||||
useIndependentChatPermissions = true
|
|
||||||
)
|
|
||||||
|
|
||||||
edit(
|
|
||||||
it.message,
|
|
||||||
replyMarkup = buildGranularKeyboard(it.message.chat.id.toChatId(), userId) ?: return@onMessageDataCallbackQuery
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMessageDataCallbackQuery(
|
|
||||||
Regex("^${commonDataPrefix}.*"),
|
|
||||||
initialFilter = { it.user.id == allowedAdmin }
|
|
||||||
) {
|
|
||||||
val messageReply = it.message.commonMessageOrNull() ?.replyTo ?.fromUserMessageOrNull() ?: return@onMessageDataCallbackQuery
|
|
||||||
val userId = messageReply.user.id
|
|
||||||
val permissions = getUserChatPermissions(it.message.chat.id.toChatId(), userId) ?: return@onMessageDataCallbackQuery
|
|
||||||
val newPermission = when (it.data) {
|
|
||||||
pollsToggleCommonData -> {
|
|
||||||
permissions.copyCommon(
|
|
||||||
canSendPolls = permissions.canSendPolls ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
otherMessagesToggleCommonData -> {
|
|
||||||
permissions.copyCommon(
|
|
||||||
canSendOtherMessages = permissions.canSendOtherMessages ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
webPagePreviewToggleCommonData -> {
|
|
||||||
permissions.copyCommon(
|
|
||||||
canAddWebPagePreviews = permissions.canAddWebPagePreviews ?.let { !it } ?: false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else -> permissions.copyCommon()
|
|
||||||
}
|
|
||||||
|
|
||||||
restrictChatMember(
|
|
||||||
it.message.chat.id,
|
|
||||||
userId,
|
|
||||||
permissions = newPermission,
|
|
||||||
useIndependentChatPermissions = false
|
|
||||||
)
|
|
||||||
|
|
||||||
edit(
|
|
||||||
it.message,
|
|
||||||
replyMarkup = buildCommonKeyboard(it.message.chat.id.toChatId(), userId) ?: return@onMessageDataCallbackQuery
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
setMyCommands(
|
|
||||||
BotCommand("simple", "Trigger simple keyboard. Use with reply to user"),
|
|
||||||
BotCommand("granular", "Trigger granular keyboard. Use with reply to user"),
|
|
||||||
scope = BotCommandScope.AllGroupChats
|
|
||||||
)
|
|
||||||
}.join()
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id "org.jetbrains.kotlin.multiplatform"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
jvm()
|
|
||||||
// js(LEGACY) {
|
|
||||||
js(IR) {
|
|
||||||
browser()
|
|
||||||
binaries.executable()
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
commonMain {
|
|
||||||
dependencies {
|
|
||||||
implementation kotlin('stdlib')
|
|
||||||
|
|
||||||
api "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.defaultSafelyWithoutExceptionHandler
|
|
||||||
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.get.*
|
|
||||||
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.types.StickerType
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
import dev.inmo.tgbotapi.utils.bold
|
|
||||||
import dev.inmo.tgbotapi.utils.buildEntities
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
|
|
||||||
fun StickerSet?.buildInfo() = buildEntities {
|
|
||||||
if (this@buildInfo == null) {
|
|
||||||
bold("Looks like this stickerset has been removed")
|
|
||||||
} else {
|
|
||||||
bold("StickerSet name: ") + "${name}\n"
|
|
||||||
bold("StickerSet title: ") + "${title}\n"
|
|
||||||
bold(
|
|
||||||
when (stickerType) {
|
|
||||||
StickerType.CustomEmoji -> "Custom emoji"
|
|
||||||
StickerType.Mask -> "Mask"
|
|
||||||
StickerType.Regular -> "Regular"
|
|
||||||
is StickerType.Unknown -> "Unknown type \"${stickerType.type}\""
|
|
||||||
}
|
|
||||||
) + " sticker set with title " + bold(title) + " and name " + bold(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun activateStickerInfoBot(
|
|
||||||
token: String,
|
|
||||||
print: (Any) -> Unit
|
|
||||||
) {
|
|
||||||
val bot = telegramBot(token)
|
|
||||||
|
|
||||||
print(bot.getMe())
|
|
||||||
|
|
||||||
defaultSafelyWithoutExceptionHandler = {
|
|
||||||
it.printStackTrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
bot.buildBehaviourWithLongPolling(CoroutineScope(currentCoroutineContext() + SupervisorJob())) {
|
|
||||||
onText {
|
|
||||||
withTypingAction(it.chat) {
|
|
||||||
it.content.textSources.mapNotNull {
|
|
||||||
if (it is CustomEmojiTextSource) {
|
|
||||||
getCustomEmojiStickerOrNull(it.customEmojiId) ?.stickerSetName
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}.distinct().map {
|
|
||||||
getStickerSet(it)
|
|
||||||
}.distinct().flatMap {
|
|
||||||
it.buildInfo() + regular("\n")
|
|
||||||
}.separateForText().map { entities ->
|
|
||||||
reply(it, entities)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onSticker {
|
|
||||||
val stickerSetInfo = getStickerSetOrNull(it.content.media)
|
|
||||||
reply(
|
|
||||||
it,
|
|
||||||
stickerSetInfo.buildInfo()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
|
||||||
println(it)
|
|
||||||
}
|
|
||||||
}.join()
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
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 {
|
|
||||||
activateStickerInfoBot(token) {
|
|
||||||
infoDiv.innerHTML = it.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Resender 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="StickerInfoBotLib.js"></script>
|
|
||||||
<div id="bots_container"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'application'
|
|
||||||
|
|
||||||
mainClassName="StickerInfoBotJvmKt"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
|
|
||||||
implementation project(":StickerInfoBot:StickerInfoBotLib")
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
suspend fun main(args: Array<String>) {
|
|
||||||
activateStickerInfoBot(args.first()) {
|
|
||||||
println(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# HelloBot
|
|
||||||
|
|
||||||
The main purpose of this bot is just to answer "Oh, hi, " and add user mention here
|
|
||||||
|
|
||||||
## Launch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
../gradlew run --args="BOT_TOKEN"
|
|
||||||
```
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'application'
|
|
||||||
|
|
||||||
mainClassName="TopicsHandlingKt"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
|
||||||
}
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
import com.benasher44.uuid.uuid4
|
|
||||||
import dev.inmo.micro_utils.common.repeatOnFailure
|
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
|
||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.closeForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.closeGeneralForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.createForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.deleteForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.editForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.editGeneralForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.hideGeneralForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.reopenForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.reopenGeneralForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.forum.unhideGeneralForumTopic
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.flushAccumulatedUpdates
|
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
|
||||||
import dev.inmo.tgbotapi.types.ForumTopic
|
|
||||||
import dev.inmo.tgbotapi.types.commands.BotCommandScope
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
|
|
||||||
suspend fun main(vararg args: String) {
|
|
||||||
telegramBotWithBehaviourAndLongPolling(
|
|
||||||
args.first(),
|
|
||||||
CoroutineScope(Dispatchers.Default),
|
|
||||||
defaultExceptionsHandler = {
|
|
||||||
it.printStackTrace()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
flushAccumulatedUpdates()
|
|
||||||
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) {
|
|
||||||
println(it)
|
|
||||||
}
|
|
||||||
onCommand("start_test_topics") {
|
|
||||||
val forumTopic = createForumTopic(
|
|
||||||
it.chat,
|
|
||||||
"Test",
|
|
||||||
ForumTopic.GREEN
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "Test topic has been created")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
editForumTopic(
|
|
||||||
it.chat.id,
|
|
||||||
forumTopic.messageThreadId,
|
|
||||||
"Test 01"
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "Test topic has changed its name to Test 01")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
closeForumTopic(
|
|
||||||
it.chat.id,
|
|
||||||
forumTopic.messageThreadId,
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "Test topic has been closed")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
reopenForumTopic(
|
|
||||||
it.chat.id,
|
|
||||||
forumTopic.messageThreadId,
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "Test topic has been reopened")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
deleteForumTopic(
|
|
||||||
it.chat.id,
|
|
||||||
forumTopic.messageThreadId,
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "Test topic has been deleted")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
hideGeneralForumTopic(
|
|
||||||
it.chat.id,
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "General topic has been hidden")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
unhideGeneralForumTopic(
|
|
||||||
it.chat.id
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "General topic has been shown")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
runCatchingSafely(
|
|
||||||
{ _ ->
|
|
||||||
reopenGeneralForumTopic(
|
|
||||||
it.chat.id
|
|
||||||
)
|
|
||||||
|
|
||||||
closeGeneralForumTopic(
|
|
||||||
it.chat.id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
closeGeneralForumTopic(
|
|
||||||
it.chat.id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
reply(it, "General topic has been closed")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
reopenGeneralForumTopic(
|
|
||||||
it.chat.id
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "General topic has been opened")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
editGeneralForumTopic(
|
|
||||||
it.chat.id,
|
|
||||||
uuid4().toString().take(10)
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "General topic has been renamed")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
editGeneralForumTopic(
|
|
||||||
it.chat.id,
|
|
||||||
"Main topic"
|
|
||||||
)
|
|
||||||
|
|
||||||
reply(it, "General topic has been renamed")
|
|
||||||
|
|
||||||
delay(1000L)
|
|
||||||
}
|
|
||||||
|
|
||||||
setMyCommands(
|
|
||||||
BotCommand("start_test_topics", "start test topics"),
|
|
||||||
scope = BotCommandScope.AllGroupChats
|
|
||||||
)
|
|
||||||
}.second.join()
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# UserChatShared
|
|
||||||
|
|
||||||
Use `/start` with bot to get request buttons. Bot will ask you to choose user/chat from your list and send it to him.
|
|
||||||
|
|
||||||
## Launch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
../gradlew run --args="BOT_TOKEN"
|
|
||||||
```
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
apply plugin: 'application'
|
|
||||||
|
|
||||||
mainClassName="UserChatSharedKt"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
|
|
||||||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
|
|
||||||
}
|
|
||||||
@@ -1,218 +0,0 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
|
||||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.buildBehaviourWithLongPolling
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatShared
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestBotButton
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestChatButton
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestGroupButton
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestUserButton
|
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.requestUserOrBotButton
|
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
|
||||||
import dev.inmo.tgbotapi.types.chat.PrivateChat
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.mention
|
|
||||||
import dev.inmo.tgbotapi.types.request.RequestId
|
|
||||||
import dev.inmo.tgbotapi.utils.row
|
|
||||||
|
|
||||||
suspend fun main(args: Array<String>) {
|
|
||||||
val botToken = args.first()
|
|
||||||
|
|
||||||
val bot = telegramBot(botToken)
|
|
||||||
|
|
||||||
val requestIdUserOrBot = RequestId(0)
|
|
||||||
val requestIdUserNonPremium = RequestId(1)
|
|
||||||
val requestIdUserAny = RequestId(2)
|
|
||||||
val requestIdUserPremium = RequestId(3)
|
|
||||||
val requestIdBot = RequestId(4)
|
|
||||||
|
|
||||||
val requestIdAnyChat = RequestId(5)
|
|
||||||
val requestIdChannel = RequestId(6)
|
|
||||||
val requestIdPublicChannel = RequestId(7)
|
|
||||||
val requestIdPrivateChannel = RequestId(8)
|
|
||||||
val requestIdChannelUserOwner = RequestId(9)
|
|
||||||
|
|
||||||
val requestIdGroup = RequestId(10)
|
|
||||||
val requestIdPublicGroup = RequestId(11)
|
|
||||||
val requestIdPrivateGroup = RequestId(12)
|
|
||||||
val requestIdGroupUserOwner = RequestId(13)
|
|
||||||
|
|
||||||
val requestIdForum = RequestId(14)
|
|
||||||
val requestIdPublicForum = RequestId(15)
|
|
||||||
val requestIdPrivateForum = RequestId(16)
|
|
||||||
val requestIdForumUserOwner = RequestId(17)
|
|
||||||
|
|
||||||
val keyboard = replyKeyboard(
|
|
||||||
resizeKeyboard = true,
|
|
||||||
) {
|
|
||||||
row {
|
|
||||||
requestUserOrBotButton(
|
|
||||||
"\uD83D\uDC64/\uD83E\uDD16",
|
|
||||||
requestIdUserOrBot
|
|
||||||
)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
requestUserButton(
|
|
||||||
"\uD83D\uDC64☆",
|
|
||||||
requestIdUserNonPremium,
|
|
||||||
premiumUser = false
|
|
||||||
)
|
|
||||||
requestUserButton(
|
|
||||||
"\uD83D\uDC64",
|
|
||||||
requestIdUserAny,
|
|
||||||
premiumUser = null
|
|
||||||
)
|
|
||||||
requestUserButton(
|
|
||||||
"\uD83D\uDC64★",
|
|
||||||
requestIdUserPremium,
|
|
||||||
premiumUser = true
|
|
||||||
)
|
|
||||||
requestBotButton(
|
|
||||||
"\uD83E\uDD16",
|
|
||||||
requestIdBot
|
|
||||||
)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
requestChatButton(
|
|
||||||
"\uD83D\uDDE3/\uD83D\uDC65",
|
|
||||||
requestIdAnyChat
|
|
||||||
)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
requestChatButton(
|
|
||||||
"\uD83D\uDDE3",
|
|
||||||
requestIdChannel,
|
|
||||||
isChannel = true
|
|
||||||
)
|
|
||||||
requestChatButton(
|
|
||||||
"\uD83D\uDDE3\uD83D\uDD17",
|
|
||||||
requestIdPublicChannel,
|
|
||||||
isChannel = true,
|
|
||||||
isPublic = true
|
|
||||||
)
|
|
||||||
requestChatButton(
|
|
||||||
"\uD83D\uDDE3❌\uD83D\uDD17",
|
|
||||||
requestIdPrivateChannel,
|
|
||||||
isChannel = true,
|
|
||||||
isPublic = false
|
|
||||||
)
|
|
||||||
requestChatButton(
|
|
||||||
"\uD83D\uDDE3\uD83D\uDC6E",
|
|
||||||
requestIdChannelUserOwner,
|
|
||||||
isChannel = true,
|
|
||||||
isOwnedBy = true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
requestGroupButton(
|
|
||||||
"👥",
|
|
||||||
requestIdGroup
|
|
||||||
)
|
|
||||||
requestGroupButton(
|
|
||||||
"👥\uD83D\uDD17",
|
|
||||||
requestIdPublicGroup,
|
|
||||||
isPublic = true
|
|
||||||
)
|
|
||||||
requestGroupButton(
|
|
||||||
"👥❌\uD83D\uDD17",
|
|
||||||
requestIdPrivateGroup,
|
|
||||||
isPublic = false
|
|
||||||
)
|
|
||||||
requestGroupButton(
|
|
||||||
"👥\uD83D\uDC6E",
|
|
||||||
requestIdGroupUserOwner,
|
|
||||||
isOwnedBy = true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
requestGroupButton(
|
|
||||||
"🏛",
|
|
||||||
requestIdForum,
|
|
||||||
isForum = true
|
|
||||||
)
|
|
||||||
requestGroupButton(
|
|
||||||
"🏛\uD83D\uDD17",
|
|
||||||
requestIdPublicForum,
|
|
||||||
isPublic = true,
|
|
||||||
isForum = true
|
|
||||||
)
|
|
||||||
requestGroupButton(
|
|
||||||
"🏛❌\uD83D\uDD17",
|
|
||||||
requestIdPrivateForum,
|
|
||||||
isPublic = false,
|
|
||||||
isForum = true
|
|
||||||
)
|
|
||||||
requestGroupButton(
|
|
||||||
"🏛\uD83D\uDC6E",
|
|
||||||
requestIdForumUserOwner,
|
|
||||||
isOwnedBy = true,
|
|
||||||
isForum = true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bot.buildBehaviourWithLongPolling (defaultExceptionsHandler = { it.printStackTrace() }) {
|
|
||||||
onCommand("start", initialFilter = { it.chat is PrivateChat }) {
|
|
||||||
reply(
|
|
||||||
it,
|
|
||||||
"Here possible requests buttons:",
|
|
||||||
replyMarkup = keyboard
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
onUserShared {
|
|
||||||
val userId = it.chatEvent.userId
|
|
||||||
val userInfo = runCatchingSafely { getChat(userId) }.getOrNull()
|
|
||||||
reply(
|
|
||||||
it,
|
|
||||||
) {
|
|
||||||
+"You have shared "
|
|
||||||
+mention(
|
|
||||||
when (it.chatEvent.requestId) {
|
|
||||||
requestIdUserOrBot -> "user or bot"
|
|
||||||
requestIdUserNonPremium -> "non premium user"
|
|
||||||
requestIdUserAny -> "any user"
|
|
||||||
requestIdUserPremium -> "premium user"
|
|
||||||
requestIdBot -> "bot"
|
|
||||||
else -> "somebody O.o"
|
|
||||||
},
|
|
||||||
userId
|
|
||||||
)
|
|
||||||
+" (user info: $userInfo; user id: $userId)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onChatShared {
|
|
||||||
val chatId = it.chatEvent.chatId
|
|
||||||
val chatInfo = runCatchingSafely { getChat(chatId) }.getOrNull()
|
|
||||||
reply(
|
|
||||||
it,
|
|
||||||
) {
|
|
||||||
+"You have shared "
|
|
||||||
+when (it.chatEvent.requestId) {
|
|
||||||
requestIdAnyChat -> "some chat"
|
|
||||||
requestIdChannel -> "any channel"
|
|
||||||
requestIdPublicChannel -> "public channel"
|
|
||||||
requestIdPrivateChannel -> "private channel"
|
|
||||||
requestIdChannelUserOwner -> "channel owned by you"
|
|
||||||
requestIdGroup -> "any group"
|
|
||||||
requestIdPublicGroup -> "public group"
|
|
||||||
requestIdPrivateGroup -> "private group"
|
|
||||||
requestIdGroupUserOwner -> "group owned by you"
|
|
||||||
requestIdForum -> "any forum"
|
|
||||||
requestIdPublicForum -> "public forum"
|
|
||||||
requestIdPrivateForum -> "private forum"
|
|
||||||
requestIdForumUserOwner -> "forum owned by you"
|
|
||||||
else -> "some chat O.o"
|
|
||||||
}
|
|
||||||
+" (chat info: $chatInfo; chat id: $chatId)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setMyCommands(BotCommand("start", "Trigger buttons"))
|
|
||||||
}.join()
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@ import dev.inmo.tgbotapi.types.webAppQueryIdField
|
|||||||
import dev.inmo.tgbotapi.webapps.*
|
import dev.inmo.tgbotapi.webapps.*
|
||||||
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackStyle
|
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackStyle
|
||||||
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackType
|
import dev.inmo.tgbotapi.webapps.haptic.HapticFeedbackType
|
||||||
import dev.inmo.tgbotapi.webapps.popup.*
|
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.bodyAsText
|
import io.ktor.client.statement.bodyAsText
|
||||||
@@ -69,79 +68,6 @@ fun main() {
|
|||||||
})
|
})
|
||||||
appendText("Example button")
|
appendText("Example button")
|
||||||
} ?: window.alert("Unable to load body")
|
} ?: window.alert("Unable to load body")
|
||||||
|
|
||||||
document.body ?.appendElement("p", {})
|
|
||||||
document.body ?.appendText("Alerts:")
|
|
||||||
|
|
||||||
document.body ?.appendElement("button") {
|
|
||||||
addEventListener("click", {
|
|
||||||
webApp.showPopup(
|
|
||||||
PopupParams(
|
|
||||||
"It is sample title of default button",
|
|
||||||
"It is sample message of default button",
|
|
||||||
DefaultPopupButton("default", "Default button"),
|
|
||||||
OkPopupButton("ok"),
|
|
||||||
DestructivePopupButton("destructive", "Destructive button")
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
document.body ?.log(
|
|
||||||
when (it) {
|
|
||||||
"default" -> "You have clicked default button in popup"
|
|
||||||
"ok" -> "You have clicked ok button in popup"
|
|
||||||
"destructive" -> "You have clicked destructive button in popup"
|
|
||||||
else -> "I can't imagine where you take button with id $it"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
appendText("Popup")
|
|
||||||
} ?: window.alert("Unable to load body")
|
|
||||||
|
|
||||||
document.body ?.appendElement("button") {
|
|
||||||
addEventListener("click", {
|
|
||||||
webApp.showAlert(
|
|
||||||
"This is alert message"
|
|
||||||
) {
|
|
||||||
document.body ?.log(
|
|
||||||
"You have closed alert"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
appendText("Alert")
|
|
||||||
} ?: window.alert("Unable to load body")
|
|
||||||
|
|
||||||
document.body ?.appendElement("button") {
|
|
||||||
addEventListener("click", {
|
|
||||||
webApp.showConfirm(
|
|
||||||
"This is confirm message"
|
|
||||||
) {
|
|
||||||
document.body ?.log(
|
|
||||||
"You have pressed \"${if (it) "Ok" else "Cancel"}\" in confirm"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
appendText("Confirm")
|
|
||||||
} ?: window.alert("Unable to load body")
|
|
||||||
|
|
||||||
document.body ?.appendElement("p", {})
|
|
||||||
|
|
||||||
document.body ?.appendElement("button") {
|
|
||||||
fun updateText() {
|
|
||||||
textContent = if (webApp.isClosingConfirmationEnabled) {
|
|
||||||
"Disable closing confirmation"
|
|
||||||
} else {
|
|
||||||
"Enable closing confirmation"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addEventListener("click", {
|
|
||||||
webApp.toggleClosingConfirmation()
|
|
||||||
updateText()
|
|
||||||
})
|
|
||||||
updateText()
|
|
||||||
} ?: window.alert("Unable to load body")
|
|
||||||
|
|
||||||
document.body ?.appendElement("p", {})
|
|
||||||
|
|
||||||
webApp.apply {
|
webApp.apply {
|
||||||
onThemeChanged {
|
onThemeChanged {
|
||||||
document.body ?.log("Theme changed: ${webApp.themeParams}")
|
document.body ?.log("Theme changed: ${webApp.themeParams}")
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
|
import dev.inmo.micro_utils.crypto.hmacSha256
|
||||||
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
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
@@ -7,13 +8,16 @@ import dev.inmo.tgbotapi.extensions.api.send.*
|
|||||||
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
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.types.buttons.*
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
||||||
import dev.inmo.tgbotapi.types.webAppQueryIdField
|
import dev.inmo.tgbotapi.types.webAppQueryIdField
|
||||||
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
|
||||||
import dev.inmo.tgbotapi.utils.*
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.application.call
|
import io.ktor.server.application.call
|
||||||
import io.ktor.server.http.content.*
|
import io.ktor.server.http.content.*
|
||||||
|
|||||||
@@ -22,7 +22,5 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
maven { url "https://git.inmo.dev/api/packages/InsanusMokrassar/maven" }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
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
|
# Due to parallel compilation project require next amount of memory on full build
|
||||||
org.gradle.jvmargs=-Xmx1g
|
org.gradle.jvmargs=-Xmx768m
|
||||||
|
|
||||||
|
|
||||||
kotlin_version=1.8.10
|
kotlin_version=1.6.21
|
||||||
telegram_bot_api_version=6.0.0
|
telegram_bot_api_version=2.2.0
|
||||||
micro_utils_version=0.17.0
|
micro_utils_version=0.11.12
|
||||||
serialization_version=1.5.0
|
serialization_version=1.3.3
|
||||||
ktor_version=2.2.3
|
ktor_version=2.0.3
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
|
||||||
|
|||||||
292
gradlew
vendored
292
gradlew
vendored
@@ -1,78 +1,129 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS=""
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -89,84 +140,101 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
warn "Could not query maximum file descriptor limit"
|
||||||
fi
|
esac
|
||||||
ulimit -n $MAX_FD
|
case $MAX_FD in #(
|
||||||
if [ $? -ne 0 ] ; then
|
'' | soft) :;; #(
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
*)
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
else
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
|
||||||
if $cygwin ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
(0) set -- ;;
|
|
||||||
(1) set -- "$args0" ;;
|
|
||||||
(2) set -- "$args0" "$args1" ;;
|
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=$(save "$@")
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
51
gradlew.bat
vendored
51
gradlew.bat
vendored
@@ -1,3 +1,19 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
|||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS=
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -35,7 +54,7 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -45,38 +64,26 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ include ":HelloBot"
|
|||||||
|
|
||||||
include ":GetMeBot"
|
include ":GetMeBot"
|
||||||
|
|
||||||
include ":DeepLinksBot"
|
|
||||||
|
|
||||||
include ":FilesLoaderBot"
|
include ":FilesLoaderBot"
|
||||||
|
|
||||||
include ":ResenderBot:ResenderBotLib"
|
include ":ResenderBot:ResenderBotLib"
|
||||||
@@ -16,21 +14,8 @@ include ":ResenderBot:jvm_launcher"
|
|||||||
include ":KeyboardsBot:KeyboardsBotLib"
|
include ":KeyboardsBot:KeyboardsBotLib"
|
||||||
include ":KeyboardsBot:jvm_launcher"
|
include ":KeyboardsBot:jvm_launcher"
|
||||||
|
|
||||||
include ":StickerInfoBot:StickerInfoBotLib"
|
|
||||||
include ":StickerInfoBot:jvm_launcher"
|
|
||||||
|
|
||||||
include ":SlotMachineDetectorBot"
|
include ":SlotMachineDetectorBot"
|
||||||
|
|
||||||
include ":ChatAvatarSetter"
|
|
||||||
|
|
||||||
include ":WebApp"
|
include ":WebApp"
|
||||||
|
|
||||||
include ":FSMBot"
|
include ":FSMBot"
|
||||||
|
|
||||||
include ":TopicsHandling"
|
|
||||||
|
|
||||||
include ":UserChatShared"
|
|
||||||
|
|
||||||
include ":RightsChangerBot"
|
|
||||||
|
|
||||||
include ":LiveLocationsBot"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user