mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-22 08:13:53 +00:00
fixes and README filling
This commit is contained in:
parent
b2f22296ce
commit
ea784c8070
9
ForwarderBot/README.md
Normal file
9
ForwarderBot/README.md
Normal 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"
|
||||||
|
```
|
@ -21,7 +21,7 @@ apply plugin: 'application'
|
|||||||
project.version = "0.1.0"
|
project.version = "0.1.0"
|
||||||
project.group = "com.insanusmokrassar"
|
project.group = "com.insanusmokrassar"
|
||||||
|
|
||||||
mainClassName="com.insanusmokrassar.examples.ForwarderBotKt.main"
|
mainClassName="com.insanusmokrassar.examples.ForwarderBotKt"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
@ -3,10 +3,11 @@ package com.insanusmokrassar.examples
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.sendTextMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.sendTextMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2
|
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.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblyForwardedMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblyForwardedMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
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.UpdateReceiver
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.startGettingOfUpdates
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.startGettingOfUpdates
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@ -28,11 +29,11 @@ suspend fun main(args: Array<String>) {
|
|||||||
val forwardInfo = message.forwardInfo
|
val forwardInfo = message.forwardInfo
|
||||||
when (forwardInfo) {
|
when (forwardInfo) {
|
||||||
null -> "There is no forward info"
|
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 ->
|
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 {
|
} else {
|
||||||
"There is no forward info"
|
"There is no forward info"
|
||||||
|
Loading…
Reference in New Issue
Block a user