diff --git a/buildSrc/src/main/kotlin/K2Config.kt b/buildSrc/src/main/kotlin/K2Config.kt deleted file mode 100644 index b8de1c2..0000000 --- a/buildSrc/src/main/kotlin/K2Config.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2024. ForteScarlet. - * - * This file is part of simbot-component-telegram. - * - * simbot-component-telegram is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Foundation, - * either version 3 of the License, or (at your option) any later version. - * - * simbot-component-telegram is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with simbot-component-telegram. - * If not, see . - */ - -import org.gradle.api.Project - - -fun Project.useK2(languageVersion: String = "2.0") { - logger.warn("暂时关闭 K2,等待 Kotlin 2.0 正式版发布。languageVersion = {}", languageVersion) - // tasks.withType { - // kotlinOptions { - // this.languageVersion = languageVersion - // } - // } -} diff --git a/simbot-component-telegram-api/build.gradle.kts b/simbot-component-telegram-api/build.gradle.kts index 840846a..428152c 100644 --- a/simbot-component-telegram-api/build.gradle.kts +++ b/simbot-component-telegram-api/build.gradle.kts @@ -34,7 +34,6 @@ plugins { setup(P.ComponentTelegram) -useK2() configJavaCompileWithModule("simbot.component.telegram.api") // configJsTestTasks() diff --git a/simbot-component-telegram-api/supports.md b/simbot-component-telegram-api/supports.md index bb5ea7f..d37cb47 100644 --- a/simbot-component-telegram-api/supports.md +++ b/simbot-component-telegram-api/supports.md @@ -1,43 +1,43 @@ # Supported API List -- [bot](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot) - - [x] [CloseApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/CloseApi.kt) - - [command](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command) - - [x] [DeleteMyCommandsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command/DeleteMyCommandsApi.kt) - - [x] [GetMyCommandsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command/GetMyCommandsApi.kt) - - [x] [SetMyCommandsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command/SetMyCommandsApi.kt) - - [x] [GetChatMenuButtonApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetChatMenuButtonApi.kt) - - [x] [GetMeApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMeApi.kt) - - [x] [GetMyDefaultAdministratorRightsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyDefaultAdministratorRightsApi.kt) - - [x] [GetMyDescriptionApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyDescriptionApi.kt) - - [x] [GetMyNameApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyNameApi.kt) - - [x] [GetMyShortDescriptionApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyShortDescriptionApi.kt) - - [x] [LogOutApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/LogOutApi.kt) +- [update](src/commonMain/kotlin/love/forte/simbot/telegram/api/update) + - [x] [GetWebhookInfoApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/GetWebhookInfoApi.kt) + - [x] [SetWebhookApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/SetWebhookApi.kt) + - [x] [DeleteWebhookApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/DeleteWebhookApi.kt) + - [x] [GetUpdatesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/GetUpdatesApi.kt) - [chat](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat) - - [x] [GetChatAdministratorsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatAdministratorsApi.kt) - - [x] [GetChatApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatApi.kt) - - [x] [GetChatMemberApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatMemberApi.kt) - - [x] [GetChatMemberCountApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatMemberCountApi.kt) - [x] [GetForumTopicIconStickersApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetForumTopicIconStickersApi.kt) + - [x] [GetChatMemberCountApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatMemberCountApi.kt) + - [x] [GetChatApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatApi.kt) + - [x] [GetChatAdministratorsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatAdministratorsApi.kt) - [x] [GetUserChatBoostsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetUserChatBoostsApi.kt) + - [x] [GetChatMemberApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/chat/GetChatMemberApi.kt) - [internal](src/commonMain/kotlin/love/forte/simbot/telegram/api/internal) - [message](src/commonMain/kotlin/love/forte/simbot/telegram/api/message) - [x] [CopyMessageApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/CopyMessageApi.kt) - - [x] [CopyMessagesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/CopyMessagesApi.kt) - - [x] [DeleteMessageApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/DeleteMessageApi.kt) - - [x] [DeleteMessagesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/DeleteMessagesApi.kt) + - [x] [SendPhotoApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/SendPhotoApi.kt) + - [x] [SendDocumentApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/SendDocumentApi.kt) - [x] [ForwardMessageApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/ForwardMessageApi.kt) - - [x] [ForwardMessagesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/ForwardMessagesApi.kt) - [x] [SendAudioApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/SendAudioApi.kt) - - [x] [SendDocumentApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/SendDocumentApi.kt) + - [x] [ForwardMessagesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/ForwardMessagesApi.kt) + - [x] [CopyMessagesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/CopyMessagesApi.kt) + - [x] [DeleteMessageApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/DeleteMessageApi.kt) - [x] [SendMessageApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/SendMessageApi.kt) - - [x] [SendPhotoApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/SendPhotoApi.kt) -- [x] [TelegramApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/TelegramApi.kt) -- [update](src/commonMain/kotlin/love/forte/simbot/telegram/api/update) - - [x] [DeleteWebhookApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/DeleteWebhookApi.kt) - - [x] [GetUpdatesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/GetUpdatesApi.kt) - - [x] [GetWebhookInfoApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/GetWebhookInfoApi.kt) - - [x] [SetWebhookApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/update/SetWebhookApi.kt) + - [x] [DeleteMessagesApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/message/DeleteMessagesApi.kt) - [user](src/commonMain/kotlin/love/forte/simbot/telegram/api/user) - [x] [GetUserProfilePhotosApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/user/GetUserProfilePhotosApi.kt) +- [x] [TelegramApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/TelegramApi.kt) +- [bot](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot) + - [x] [GetChatMenuButtonApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetChatMenuButtonApi.kt) + - [x] [GetMeApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMeApi.kt) + - [x] [GetMyNameApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyNameApi.kt) + - [x] [LogOutApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/LogOutApi.kt) + - [x] [GetMyShortDescriptionApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyShortDescriptionApi.kt) + - [x] [GetMyDefaultAdministratorRightsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyDefaultAdministratorRightsApi.kt) + - [x] [GetMyDescriptionApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/GetMyDescriptionApi.kt) + - [command](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command) + - [x] [DeleteMyCommandsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command/DeleteMyCommandsApi.kt) + - [x] [GetMyCommandsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command/GetMyCommandsApi.kt) + - [x] [SetMyCommandsApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/command/SetMyCommandsApi.kt) + - [x] [CloseApi](src/commonMain/kotlin/love/forte/simbot/telegram/api/bot/CloseApi.kt) - [ ] **Others not listed** diff --git a/simbot-component-telegram-core/build.gradle.kts b/simbot-component-telegram-core/build.gradle.kts index 3b3cfe2..44e6bea 100644 --- a/simbot-component-telegram-core/build.gradle.kts +++ b/simbot-component-telegram-core/build.gradle.kts @@ -32,7 +32,6 @@ plugins { setup(P.ComponentTelegram) -useK2() configJavaCompileWithModule("simbot.component.telegram.core") apply(plugin = "simbot-telegram-multiplatform-maven-publish") diff --git a/simbot-component-telegram-stdlib/README.md b/simbot-component-telegram-stdlib/README.md index 3f046ca..24df719 100644 --- a/simbot-component-telegram-stdlib/README.md +++ b/simbot-component-telegram-stdlib/README.md @@ -3,6 +3,9 @@ > [!caution] > WIP, and this module will remove +> [!caution] +> This module may be deprecated, refactored, hidden or reorganised. + ## Setup > [!note] diff --git a/simbot-component-telegram-stdlib/build.gradle.kts b/simbot-component-telegram-stdlib/build.gradle.kts index 07fe6f7..55ca091 100644 --- a/simbot-component-telegram-stdlib/build.gradle.kts +++ b/simbot-component-telegram-stdlib/build.gradle.kts @@ -32,7 +32,6 @@ plugins { setup(P.ComponentTelegram) -useK2() configJavaCompileWithModule("simbot.component.telegram.stdlib") apply(plugin = "simbot-telegram-multiplatform-maven-publish") diff --git a/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/Bot.kt b/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/Bot.kt index b895d3f..2161e27 100644 --- a/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/Bot.kt +++ b/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/Bot.kt @@ -235,7 +235,8 @@ public interface Bot : CoroutineScope { /** * Bot ticket. * - * @property token Bot full token. e.g.: `bot123456.aaabbbccc` + * @property token Bot full token. e.g.: `bot123456.aaabbbccc`, + * it should have a `"bot"` prefix. */ public data class Ticket(val token: String) } diff --git a/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/internal/BotImpl.kt b/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/internal/BotImpl.kt index cf8b2e1..b0a1d55 100644 --- a/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/internal/BotImpl.kt +++ b/simbot-component-telegram-stdlib/src/commonMain/kotlin/love/forte/simbot/telegram/stdlib/bot/internal/BotImpl.kt @@ -54,7 +54,7 @@ import kotlin.time.Duration.Companion.seconds */ @OptIn(ExperimentalSimbotCollectionApi::class) internal class BotImpl( - override val ticket: Bot.Ticket, + ticket: Bot.Ticket, private val configuration: BotConfiguration, ) : Bot { private val logger = LoggerFactory.getLogger("love.forte.simbot.telegram.stdlib.bot") @@ -76,6 +76,15 @@ internal class BotImpl( this.apiClient = apiClient } + override val ticket: Bot.Ticket = with(ticket) { + if (token.startsWith("bot")) { + this + } else { + logger.debug("Append prefix 'bot' for ticket.token.") + copy(token = "bot$token") + } + } + private inline fun resolveHttpClient(crossinline block: HttpClientConfig<*>.() -> Unit = {}): HttpClient { val apiClientConfigurer = configuration.apiClientConfigurer diff --git a/simbot-component-telegram-type/build.gradle.kts b/simbot-component-telegram-type/build.gradle.kts index d303b6c..05a6523 100644 --- a/simbot-component-telegram-type/build.gradle.kts +++ b/simbot-component-telegram-type/build.gradle.kts @@ -29,7 +29,6 @@ plugins { setup(P.ComponentTelegram) -useK2() configJavaCompileWithModule("simbot.component.telegram.type") apply(plugin = "simbot-telegram-multiplatform-maven-publish")