fixes and README filling

This commit is contained in:
InsanusMokrassar 2020-02-25 13:41:18 +06:00
parent b2f22296ce
commit ea784c8070
3 changed files with 15 additions and 5 deletions

9
ForwarderBot/README.md Normal file
View File

@ -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"
```

View File

@ -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()

View File

@ -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<String>) {
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"