From ea784c80702ce596e95d97c048277ec00e332e44 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Feb 2020 13:41:18 +0600 Subject: [PATCH] fixes and README filling --- ForwarderBot/README.md | 9 +++++++++ ForwarderBot/build.gradle | 2 +- .../kotlin/com/insanusmokrassar/examples/ForwarderBot.kt | 9 +++++---- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 ForwarderBot/README.md diff --git a/ForwarderBot/README.md b/ForwarderBot/README.md new file mode 100644 index 0000000..d0a12d7 --- /dev/null +++ b/ForwarderBot/README.md @@ -0,0 +1,9 @@ +# ForwarderBot + +The main purpose of this bot is just to send info about forwarder when bot receive any update + +## Launch + +```bash +../gradlew run --args="BOT_TOKEN" +``` diff --git a/ForwarderBot/build.gradle b/ForwarderBot/build.gradle index 2238256..a254060 100644 --- a/ForwarderBot/build.gradle +++ b/ForwarderBot/build.gradle @@ -21,7 +21,7 @@ apply plugin: 'application' project.version = "0.1.0" project.group = "com.insanusmokrassar" -mainClassName="com.insanusmokrassar.examples.ForwarderBotKt.main" +mainClassName="com.insanusmokrassar.examples.ForwarderBotKt" repositories { mavenLocal() diff --git a/ForwarderBot/src/main/kotlin/com/insanusmokrassar/examples/ForwarderBot.kt b/ForwarderBot/src/main/kotlin/com/insanusmokrassar/examples/ForwarderBot.kt index de31d05..27dc02e 100644 --- a/ForwarderBot/src/main/kotlin/com/insanusmokrassar/examples/ForwarderBot.kt +++ b/ForwarderBot/src/main/kotlin/com/insanusmokrassar/examples/ForwarderBot.kt @@ -3,10 +3,11 @@ package com.insanusmokrassar.examples import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.sendTextMessage import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2 +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.ChannelChat import com.github.insanusmokrassar.TelegramBotAPI.types.message.* import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblyForwardedMessage import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate -import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper +import com.github.insanusmokrassar.TelegramBotAPI.utils.* import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.startGettingOfUpdates import kotlinx.coroutines.* @@ -28,11 +29,11 @@ suspend fun main(args: Array) { val forwardInfo = message.forwardInfo when (forwardInfo) { null -> "There is no forward info" - is AnonymousForwardInfo -> "Anonymous user which signed as \"${forwardInfo.senderName}\"" + is AnonymousForwardInfo -> "Anonymous user which signed as \"${forwardInfo.senderName.codeMarkdownV2()}\"" is UserForwardInfo -> forwardInfo.from.let { user -> - "User `${user.id.chatId}` (`${user.firstName} ${user.lastName}`: ${user.username ?.username ?: "Without username"})" + "User ${user.id.chatId.toString().codeMarkdownV2()} " + "(${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})".regularMarkdownV2() } - is ForwardFromChannelInfo -> "Channel (${forwardInfo.channelChat})" + is ForwardFromChannelInfo -> "Channel (".regularMarkdownV2() + (forwardInfo.channelChat as ChannelChat).title.codeMarkdownV2() + ")".regularMarkdownV2() } } else { "There is no forward info"