mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2025-07-05 18:11:26 +00:00
update version and example of hello bot
This commit is contained in:
@ -36,14 +36,18 @@ suspend fun main(vararg args: String) {
|
||||
is GroupChat -> bot.getChat(chat).inviteLink ?.let {
|
||||
chat.title.linkMarkdownV2(it)
|
||||
} ?: chat.title
|
||||
is ChannelChat -> (chat.username ?.username ?: bot.getChat(chat).inviteLink) ?.let {
|
||||
chat.title.linkMarkdownV2(it)
|
||||
} ?: chat.title
|
||||
else -> "Unknown :(".escapeMarkdownV2Common()
|
||||
}
|
||||
bot.sendTextMessage(chat, message, MarkdownV2)
|
||||
}
|
||||
}.launchIn(scope)
|
||||
channelPostFlow.onEach {
|
||||
safely {
|
||||
val chat = it.data.chat
|
||||
val message = "Hi everybody in this channel \"${(chat as ChannelChat).title}\""
|
||||
bot.sendTextMessage(chat, message, MarkdownV2)
|
||||
}
|
||||
}.launchIn(scope)
|
||||
}
|
||||
|
||||
scope.coroutineContext[Job]!!.join()
|
||||
|
Reference in New Issue
Block a user