Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve: When the ticket.token without a bot prefix, append one. #66

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions buildSrc/src/main/kotlin/K2Config.kt

This file was deleted.

1 change: 0 additions & 1 deletion simbot-component-telegram-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ plugins {

setup(P.ComponentTelegram)

useK2()
configJavaCompileWithModule("simbot.component.telegram.api")

// configJsTestTasks()
Expand Down
58 changes: 29 additions & 29 deletions simbot-component-telegram-api/supports.md
Original file line number Diff line number Diff line change
@@ -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**
1 change: 0 additions & 1 deletion simbot-component-telegram-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ plugins {

setup(P.ComponentTelegram)

useK2()
configJavaCompileWithModule("simbot.component.telegram.core")
apply(plugin = "simbot-telegram-multiplatform-maven-publish")

Expand Down
3 changes: 3 additions & 0 deletions simbot-component-telegram-stdlib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
> [!caution]
> WIP, and this module will remove

> [!caution]
> This module may be deprecated, refactored, hidden or reorganised.

## Setup

> [!note]
Expand Down
1 change: 0 additions & 1 deletion simbot-component-telegram-stdlib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ plugins {

setup(P.ComponentTelegram)

useK2()
configJavaCompileWithModule("simbot.component.telegram.stdlib")
apply(plugin = "simbot-telegram-multiplatform-maven-publish")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion simbot-component-telegram-type/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ plugins {

setup(P.ComponentTelegram)

useK2()
configJavaCompileWithModule("simbot.component.telegram.type")
apply(plugin = "simbot-telegram-multiplatform-maven-publish")

Expand Down
Loading