mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-11-25 19:48:49 +00:00
update version and example of hello bot
This commit is contained in:
parent
d9b42efc4a
commit
df33e3ac38
@ -36,14 +36,18 @@ suspend fun main(vararg args: String) {
|
|||||||
is GroupChat -> bot.getChat(chat).inviteLink ?.let {
|
is GroupChat -> bot.getChat(chat).inviteLink ?.let {
|
||||||
chat.title.linkMarkdownV2(it)
|
chat.title.linkMarkdownV2(it)
|
||||||
} ?: chat.title
|
} ?: chat.title
|
||||||
is ChannelChat -> (chat.username ?.username ?: bot.getChat(chat).inviteLink) ?.let {
|
|
||||||
chat.title.linkMarkdownV2(it)
|
|
||||||
} ?: chat.title
|
|
||||||
else -> "Unknown :(".escapeMarkdownV2Common()
|
else -> "Unknown :(".escapeMarkdownV2Common()
|
||||||
}
|
}
|
||||||
bot.sendTextMessage(chat, message, MarkdownV2)
|
bot.sendTextMessage(chat, message, MarkdownV2)
|
||||||
}
|
}
|
||||||
}.launchIn(scope)
|
}.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()
|
scope.coroutineContext[Job]!!.join()
|
||||||
|
5
build.gradle
Normal file
5
build.gradle
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,3 @@
|
|||||||
kotlin_version=1.3.72
|
kotlin_version=1.3.72
|
||||||
|
|
||||||
telegram_bot_api_version=0.27.6
|
telegram_bot_api_version=0.27.8
|
||||||
|
Loading…
Reference in New Issue
Block a user