mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-26 03:58:49 +00:00
update hello example
This commit is contained in:
parent
dfae8b7f29
commit
358bfdaa05
@ -1,5 +1,6 @@
|
|||||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
|
||||||
import dev.inmo.tgbotapi.extensions.api.chat.get.getChatAdministrators
|
import dev.inmo.tgbotapi.extensions.api.chat.get.getChatAdministrators
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
|
import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
|
||||||
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
import dev.inmo.tgbotapi.extensions.api.telegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
|
import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
|
||||||
@ -32,8 +33,9 @@ suspend fun main(vararg args: String) {
|
|||||||
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
|
||||||
messageFlow.onEach {
|
messageFlow.onEach {
|
||||||
safely {
|
safely {
|
||||||
val chat = it.data.chat
|
val message = it.data
|
||||||
val message = "Oh, hi, " + when (chat) {
|
val chat = message.chat
|
||||||
|
val answerText = "Oh, hi, " + when (chat) {
|
||||||
is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
||||||
is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
|
||||||
is SupergroupChat -> (chat.username ?.username ?: bot.getChat(chat).inviteLink) ?.let {
|
is SupergroupChat -> (chat.username ?.username ?: bot.getChat(chat).inviteLink) ?.let {
|
||||||
@ -44,7 +46,11 @@ suspend fun main(vararg args: String) {
|
|||||||
} ?: chat.title
|
} ?: chat.title
|
||||||
else -> "Unknown :(".escapeMarkdownV2Common()
|
else -> "Unknown :(".escapeMarkdownV2Common()
|
||||||
}
|
}
|
||||||
bot.sendTextMessage(chat, message, MarkdownV2)
|
bot.reply(
|
||||||
|
message,
|
||||||
|
answerText,
|
||||||
|
MarkdownV2
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}.launchIn(scope)
|
}.launchIn(scope)
|
||||||
channelPostFlow.onEach {
|
channelPostFlow.onEach {
|
||||||
|
Loading…
Reference in New Issue
Block a user