diff --git a/HelloBot/src/main/kotlin/HelloBot.kt b/HelloBot/src/main/kotlin/HelloBot.kt index 968ee1c..9651fb0 100644 --- a/HelloBot/src/main/kotlin/HelloBot.kt +++ b/HelloBot/src/main/kotlin/HelloBot.kt @@ -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() diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..20f4210 --- /dev/null +++ b/build.gradle @@ -0,0 +1,5 @@ +allprojects { + repositories { + mavenLocal() + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3de8887..7aaae27 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ kotlin_version=1.3.72 -telegram_bot_api_version=0.27.6 +telegram_bot_api_version=0.27.8