update version and example of hello bot

This commit is contained in:
2020-07-02 16:37:12 +06:00
parent d9b42efc4a
commit df33e3ac38
3 changed files with 13 additions and 4 deletions

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