From 2a444ba84eebc8bae79171e5037540cb6dcc3e3d Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Thu, 18 Jul 2024 16:25:57 +0800 Subject: [PATCH 1/7] doc: core README --- simbot-component-telegram-core/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/simbot-component-telegram-core/README.md b/simbot-component-telegram-core/README.md index 17e67c1..21284ce 100644 --- a/simbot-component-telegram-core/README.md +++ b/simbot-component-telegram-core/README.md @@ -197,3 +197,22 @@ The configuration file `*.bot.json` } ``` + +```json5 +{ + "component": "simbot.telegram", + "ticket": { + "token": "Your Bot Token" + }, + // config and its properties are optional and default to `null`. + "config": { + "server": null, + "proxy": null, + // config the `longPolling` to subscribe evnets + "longPolling": { + "limit": 100 + } + } +} +``` + From cfa3474d002dac33a34a57c83ea37255ec79a303 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Thu, 18 Jul 2024 17:18:58 +0800 Subject: [PATCH 2/7] Update core README --- simbot-component-telegram-core/README.md | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/simbot-component-telegram-core/README.md b/simbot-component-telegram-core/README.md index 21284ce..452b2a5 100644 --- a/simbot-component-telegram-core/README.md +++ b/simbot-component-telegram-core/README.md @@ -86,6 +86,40 @@ dependencies { ``` +### Ktor client engine + +The Telegram component uses Ktor as the HTTP client implementation, +but does not rely on any specific engine by default. + +Therefore, you need to choose and use a Ktor Client engine implementation. + +You can go to the [Ktor documentation](https://ktor.io/docs/client-engines.html) +to select a suitable Client Engine for your platform. + +Take the JVM platform as an example: + +
Gradle + +```kotlin +runtimeOnly("io.ktor:ktor-client-java:$ktor_version") +``` + +
+ +
Maven + +```xml + + io.ktor + ktor-client-java-jvm + ${ktor_version} + runtime + +``` + +
+ + ## Examples **simbot core** From 3ea062842af362b32ccc8bde1772433c94a8ec30 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Fri, 19 Jul 2024 03:36:52 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E7=AE=80=E5=8D=95=E8=B0=83=E6=95=B4README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 263 ++++++++++++++++++--- simbot-component-telegram-core/README.md | 5 +- simbot-component-telegram-stdlib/README.md | 5 +- 3 files changed, 237 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 22520d7..a481ff1 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,7 @@ It is also a component library of [Simple Robot v4][simbot4 gh] (simbot), which With the capabilities provided by the simbot core library, it can support more advanced encapsulation, as well as component collaboration, Spring support, and more. -It can be used as aid as a low-level API/SDK dependency or as a lightweight framework -that can be developed quickly with the help of the simbot core library! - -Serialization and network requests are based on [Kotlin serialization](https://github.com/Kotlin/kotlinx.serialization) and [Ktor](https://ktor.io/). +> Serialization and network requests are based on [Kotlin serialization](https://github.com/Kotlin/kotlinx.serialization) and [Ktor](https://ktor.io/). ## Documentation @@ -54,55 +51,259 @@ Serialization and network requests are based on [Kotlin serialization](https://g - **API Documentation**: [**The KDoc of Telegram Component**](https://docs.simbot.forte.love/components/telegram) in the [**document guide site**](https://docs.simbot.forte.love). - [**Communities**](https://simbot.forte.love/communities.html): Have fun interacting with us and other developers! -## Modules -### ⭐ Type module +## Setup + +To use the simbot component library, you first need to add the core implementation of simbot +(such as the core library (`simbot-core`) or Spring Boot starter (`simbot-core-spring-boot-starter`)), +and then add the component library dependencies of the Telegram (`simbot-component-telegram-core`). + +> [!note] +> The version of the simbot core implementation library (`SIMBOT_VERSION` below) +> goes [here](https://github.com/simple-robot/simpler-robot/releases) for reference; +> +> Telegram Component library versions (`VERSION` below) go to the [release](https://github.com/simple-robot/simbot-component-telegram/releases) reference. + +**With simbot core** + +### Gradle + +`build.gradle.kts` -Provides definitions for most types in Telegram and supports serialization based on -[Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization). +```kotlin +plugins { + kotlin("...") version "..." +} -👉 [Go to the module](simbot-component-telegram-type) to learn more. +dependencies { + implementation("love.forte.simbot:simbot-core:${SIMBOT_VERSION}") + implementation("love.forte.simbot.component:simbot-component-telegram-core:$VERSION") +} +``` + +### Maven + +`pom.xml` + +```xml + + + love.forte.simbot + simbot-core-jvm + ${SIMBOT_VERSION} + + + love.forte.simbot.component + simbot-component-telegram-core-jvm + ${VERSION} + + +``` -### ⭐ API module +**With simbot spring boot starter** -Based on [Type module](simbot-component-telegram-type) -and [Ktor](https://ktor.io/)'s -[KMP][KMP] implementation for [Telegram Bot API][telegram bot doc], -is a simple, efficient and lightweight API implementation module. +### Gradle -This module provides very little extra implementation. -The goal is to preserve the feel of the original API as much as possible without overwrapping it. +`build.gradle.kts` -👉 [Go to the module](simbot-component-telegram-api) to learn more. +```kotlin +plugins { + kotlin("jvm") version "..." +} -### ⭐ Stdlib module +dependencies { + implementation("love.forte.simbot:simbot-core-spring-boot-starter:${SIMBOT_VERSION}") + implementation("love.forte.simbot.component:simbot-component-telegram-core:$VERSION") +} +``` -Based on [API module](simbot-component-telegram-api), -for the implementation of authentication, subscription events and other related functions in bot. +### Maven + +`pom.xml` + +```xml + + + love.forte.simbot + simbot-core-spring-boot-starter + ${SIMBOT_VERSION} + + + love.forte.simbot.component + simbot-component-telegram-core-jvm + ${VERSION} + + +``` -The `stdlib` module can be thought of as a lightweight SDK implementation library. +### Ktor client engine -This module provides an implementation of event-related functionality based on the API module, -including the ability to subscribe to events. +The Telegram component uses Ktor as the HTTP client implementation, +but does not rely on any specific engine by default. -Again, the goal is to provide as much of the feel of the original API as possible without overwrapping it. +Therefore, you need to choose and use a Ktor Client engine implementation. -👉 [Go to the module](simbot-component-telegram-stdlib) to learn more. +You can go to the [Ktor documentation](https://ktor.io/docs/client-engines.html) +to select a suitable Client Engine for your platform. -### ⭐ Core Component module +Take the JVM platform as an example: -A component implementation of the [simbot4 core library][simbot4 gh] based on [standard library module](simbot-component-telegram-stdlib). +
Gradle -Is a relatively highly encapsulated module that provides most of the capabilities of simbot4, -including event listeners, multi-component coordination, Spring Boot starter, and more. +```kotlin +runtimeOnly("io.ktor:ktor-client-java:$ktor_version") +``` -👉 [Go to Modules](simbot-component-telegram-core) to learn more. +
+ +
Maven + +```xml + + io.ktor + ktor-client-java-jvm + ${ktor_version} + runtime + +``` + +
+ +## Examples + +**simbot core** + +```Kotlin +suspend fun main() { + val app = launchSimpleApplication { + useTelegram() // install Telegram Component + } + + // subscribe to events + app.listeners { + // subscribe to ChatGroupMessageEvent + listen { event -> + // process event... + event.reply("Hello!") + event.reply(At(event.authorId) + "Where are you?".toText()) + + // Required an result + EventResult.empty() + } + + // subscribe to ChatGroupMessageEvent + process { event -> + // process event... + event.content().send("Welcome, " + At(event.member().id)) + + // Without result in `process` + } + } + + // register bots + app.telegramBots { + // register a bot via token + val bot = register(token = "botaaabbb.123123444") { + // Config... + // The source stdlib bot config + botConfiguration { + apiClientConfigurer { + engine { + // A proxy? + proxy = ProxyBuilder.http("http://127.0.0.1:7790") + } + } + + // Enable longPolling? + longPolling = LongPolling( + limit = 100, + timeout = 10.minutes.inWholeSeconds.toInt(), + allowedUpdates = setOf(UpdateValues.MESSAGE_NAME), + // Enable retry? + retry = LongPolling.Retry() + ) + } + } + + // start the bot + bot.start() + } + + + app.join() +} +``` + +**simbot Spring Boot starter** + +```Kotlin +@SpringBootApplication +@EnableSimbot // enable +class App + +fun main(args: Array) { + runApplication(*args) +} + +@Component +class MyHandles { + + @Listener // subscribe to ChatGroupMemberIncreaseEvent + suspend fun handleMemberIncrease(event: ChatGroupMemberIncreaseEvent) { + // ... + } + + @Filter("Hello.*") + @Listener // subscribe to ChatGroupMessageEvent + suspend fun handleGroupMessage(event: ChatGroupMessageEvent) { + event.reply("Hello!") + } +} +``` +The configuration file `*.bot.json` + +> Comments are not supported. +> Remember to clean them up when you use them. + +```json5 +{ + "component": "simbot.telegram", + "ticket": { + "token": "Your FULL Bot Token, e.g. Bot123456789:aaaabbbbcccc" + }, + // config and its properties are optional and default to `null`. + "config": { + "server": null, + "proxy": null, + "longPolling": null + } +} +``` + + +```json5 +{ + "component": "simbot.telegram", + "ticket": { + "token": "Your FULL Bot Token, e.g. Bot123456789:aaaabbbbcccc" + }, + // config and its properties are optional and default to `null`. + "config": { + "server": null, + "proxy": null, + // config the `longPolling` to subscribe evnets + "longPolling": { + "limit": 100 + } + } +} +``` ## CONTRIBUTING See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for more information! We welcome you and look forward to it -[feed back](https://github.com/simple-robot/simbot-component-telegram/issues) +[feedback](https://github.com/simple-robot/simbot-component-telegram/issues) or [pull request](https://github.com/simple-robot/simbot-component-telegram/pulls), Thank you for your contribution and support! diff --git a/simbot-component-telegram-core/README.md b/simbot-component-telegram-core/README.md index 452b2a5..9a8ed36 100644 --- a/simbot-component-telegram-core/README.md +++ b/simbot-component-telegram-core/README.md @@ -119,7 +119,6 @@ runtimeOnly("io.ktor:ktor-client-java:$ktor_version") - ## Examples **simbot core** @@ -220,7 +219,7 @@ The configuration file `*.bot.json` { "component": "simbot.telegram", "ticket": { - "token": "Your Bot Token" + "token": "Your FULL Bot Token, e.g. Bot123456789:aaaabbbbcccc" }, // config and its properties are optional and default to `null`. "config": { @@ -236,7 +235,7 @@ The configuration file `*.bot.json` { "component": "simbot.telegram", "ticket": { - "token": "Your Bot Token" + "token": "Your FULL Bot Token, e.g. Bot123456789:aaaabbbbcccc" }, // config and its properties are optional and default to `null`. "config": { diff --git a/simbot-component-telegram-stdlib/README.md b/simbot-component-telegram-stdlib/README.md index 089cc63..3f046ca 100644 --- a/simbot-component-telegram-stdlib/README.md +++ b/simbot-component-telegram-stdlib/README.md @@ -1,12 +1,13 @@ # Stdlib module > [!caution] -> WIP +> WIP, and this module will remove ## Setup > [!note] -> Version (`VERSION` below) goes to the [releases](https://github.com/simple-robot/simbot-component-telegram/releases) reference. +> Version (`VERSION` below) goes to the [release](https://github.com/simple-robot/simbot-component-telegram/releases) +> reference. ### Gradle From 416820ebbfb372059c7356052038107b13f3ce0d Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Fri, 19 Jul 2024 03:42:45 +0800 Subject: [PATCH 4/7] README --- README_CN.md | 257 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 233 insertions(+), 24 deletions(-) diff --git a/README_CN.md b/README_CN.md index 5fc57b1..f721688 100644 --- a/README_CN.md +++ b/README_CN.md @@ -54,44 +54,253 @@ Kotlin 多平台库,异步高效、Java友好。 - **API文档**: [**文档引导站点**](https://docs.simbot.forte.love) 中 Telegram 的 [**KDoc站点**](https://docs.simbot.forte.love/components/telegram) - [**社群**](https://simbot.forte.love/communities.html): 与我们和其他开发者愉快地交流! -## 模块引导 -### ⭐ Type模块 -提供 Telegram 中的绝大多数类型定义,并基于 -[Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization) -实现可序列化。 +## 安装 -👉 [前往模块](simbot-component-telegram-type/README_CN.md) 了解更多。 +To use the simbot component library, you first need to add the core implementation of simbot +(such as the core library (`simbot-core`) or Spring Boot starter (`simbot-core-spring-boot-starter`)), +and then add the component library dependencies of the Telegram (`simbot-component-telegram-core`). -### ⭐ API模块 +> [!note] +> The version of the simbot core implementation library (`SIMBOT_VERSION` below) +> goes [here](https://github.com/simple-robot/simpler-robot/releases) for reference; +> +> Telegram Component library versions (`VERSION` below) go to the [release](https://github.com/simple-robot/simbot-component-telegram/releases) reference. -基于 `Ktor` 针对 [Telegram API](https://telegram.com/developers/docs/intro) -的基本完整的[KMP](https://kotlinlang.org/docs/multiplatform.html)多平台封装实现, -是一个简单高效轻量级的API实现模块。 +**With simbot core** -此模块基本不会提供什么多余的实现,其目标为在提供封装的情况下尽可能地保留原始API的使用手感,不做过多的封装。 +### Gradle -👉 [前往模块](simbot-component-telegram-api/README_CN.md) 了解更多。 +`build.gradle.kts` -### ⭐ 标准库模块 +```kotlin +plugins { + kotlin("...") version "..." +} -基于 [API模块](simbot-component-telegram-api) 针对 bot 的鉴权、事件订阅等功能的实现。 +dependencies { + implementation("love.forte.simbot:simbot-core:${SIMBOT_VERSION}") + implementation("love.forte.simbot.component:simbot-component-telegram-core:$VERSION") +} +``` + +### Maven + +`pom.xml` + +```xml + + + love.forte.simbot + simbot-core-jvm + ${SIMBOT_VERSION} + + + love.forte.simbot.component + simbot-component-telegram-core-jvm + ${VERSION} + + +``` + +**With simbot spring boot starter** -stdlib模块可以被看作是一个轻量级的 SDK 实现库。 +### Gradle -同样的,其目标为在提供封装的情况下尽可能地保留原始API的使用手感,不做过多的封装。 +`build.gradle.kts` -👉 [前往模块](simbot-component-telegram-stdlib) 了解更多。 +```kotlin +plugins { + kotlin("jvm") version "..." +} -### ⭐ 核心组件模块 +dependencies { + implementation("love.forte.simbot:simbot-core-spring-boot-starter:${SIMBOT_VERSION}") + implementation("love.forte.simbot.component:simbot-component-telegram-core:$VERSION") +} +``` + +### Maven + +`pom.xml` + +```xml + + + love.forte.simbot + simbot-core-spring-boot-starter + ${SIMBOT_VERSION} + + + love.forte.simbot.component + simbot-component-telegram-core-jvm + ${VERSION} + + +``` -基于 -[标准库模块](simbot-component-telegram-stdlib) -对 [simbot4核心库](https://github.com/simple-robot/simpler-robot) -的组件实现, -是一个相对高度封装的模块,并提供simbot4大部分能力,包括事件监听、多组件协同、Spring Boot starter 等。 +### Ktor client engine -👉 [前往模块](simbot-component-telegram-core) 了解更多。 +The Telegram component uses Ktor as the HTTP client implementation, +but does not rely on any specific engine by default. + +Therefore, you need to choose and use a Ktor Client engine implementation. + +You can go to the [Ktor documentation](https://ktor.io/docs/client-engines.html) +to select a suitable Client Engine for your platform. + +Take the JVM platform as an example: + +
Gradle + +```kotlin +runtimeOnly("io.ktor:ktor-client-java:$ktor_version") +``` + +
+ +
Maven + +```xml + + io.ktor + ktor-client-java-jvm + ${ktor_version} + runtime + +``` + +
+ +## Examples + +**simbot core** + +```Kotlin +suspend fun main() { + val app = launchSimpleApplication { + useTelegram() // install Telegram Component + } + + // subscribe to events + app.listeners { + // subscribe to ChatGroupMessageEvent + listen { event -> + // process event... + event.reply("Hello!") + event.reply(At(event.authorId) + "Where are you?".toText()) + + // Required an result + EventResult.empty() + } + + // subscribe to ChatGroupMessageEvent + process { event -> + // process event... + event.content().send("Welcome, " + At(event.member().id)) + + // Without result in `process` + } + } + + // register bots + app.telegramBots { + // register a bot via token + val bot = register(token = "botaaabbb.123123444") { + // Config... + // The source stdlib bot config + botConfiguration { + apiClientConfigurer { + engine { + // A proxy? + proxy = ProxyBuilder.http("http://127.0.0.1:7790") + } + } + + // Enable longPolling? + longPolling = LongPolling( + limit = 100, + timeout = 10.minutes.inWholeSeconds.toInt(), + allowedUpdates = setOf(UpdateValues.MESSAGE_NAME), + // Enable retry? + retry = LongPolling.Retry() + ) + } + } + + // start the bot + bot.start() + } + + + app.join() +} +``` + +**simbot Spring Boot starter** + +```Kotlin +@SpringBootApplication +@EnableSimbot // enable +class App + +fun main(args: Array) { + runApplication(*args) +} + +@Component +class MyHandles { + + @Listener // subscribe to ChatGroupMemberIncreaseEvent + suspend fun handleMemberIncrease(event: ChatGroupMemberIncreaseEvent) { + // ... + } + + @Filter("Hello.*") + @Listener // subscribe to ChatGroupMessageEvent + suspend fun handleGroupMessage(event: ChatGroupMessageEvent) { + event.reply("Hello!") + } +} +``` +The configuration file `*.bot.json` + +> Comments are not supported. +> Remember to clean them up when you use them. + +```json5 +{ + "component": "simbot.telegram", + "ticket": { + "token": "Your FULL Bot Token, e.g. Bot123456789:aaaabbbbcccc" + }, + // config and its properties are optional and default to `null`. + "config": { + "server": null, + "proxy": null, + "longPolling": null + } +} +``` + + +```json5 +{ + "component": "simbot.telegram", + "ticket": { + "token": "Your FULL Bot Token, e.g. Bot123456789:aaaabbbbcccc" + }, + // config and its properties are optional and default to `null`. + "config": { + "server": null, + "proxy": null, + // config the `longPolling` to subscribe evnets + "longPolling": { + "limit": 100 + } + } +} +``` ## 贡献 From 260675d13723fe28016d85b7e173607c750fa51f Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Fri, 19 Jul 2024 03:46:43 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../telegram/core/bot/SerializableTelegramBotConfiguration.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/SerializableTelegramBotConfiguration.kt b/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/SerializableTelegramBotConfiguration.kt index 45528c2..0760404 100644 --- a/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/SerializableTelegramBotConfiguration.kt +++ b/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/SerializableTelegramBotConfiguration.kt @@ -31,6 +31,10 @@ import love.forte.simbot.telegram.stdlib.bot.LongPolling /** + * A configuration type for a serializable bot config file. + * + * Only for deserialization use, it is not recommended to directly construct or use it, + * and the compatibility and stability of direct use are not guaranteed. * * @author ForteScarlet */ From 12cf60bcdb617e6144e7538888bbac085c6ff517 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sat, 20 Jul 2024 14:41:54 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix(core):=20bot=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E6=9C=AA=E5=88=9D=E5=A7=8B=E5=8C=96=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/telegram/core/bot/TelegramBot.kt | 15 +++++++++++---- .../telegram/core/bot/internal/TelegramBotImpl.kt | 14 ++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/TelegramBot.kt b/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/TelegramBot.kt index 6468200..ab5fcb8 100644 --- a/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/TelegramBot.kt +++ b/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/TelegramBot.kt @@ -64,14 +64,21 @@ public interface TelegramBot : Bot { get() = userInfo.username ?: userInfo.firstName /** - * The id of current bot. + * The id of [userInfo]. * - * @throws IllegalStateException The bot has not been started, or has never been used [queryUserInfo]. - * @see userInfo + * @throws IllegalStateException The bot has not be started, + * or has never been used [queryUserInfo] + */ + public val userId: ID + get() = userInfo.id.ID + + /** + * The bot token configured. * + * If you want to get the `user.id` of this bot, + * use [userId]. */ override val id: ID - get() = userInfo.id.ID /** * Query user info of the current bot. diff --git a/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/internal/TelegramBotImpl.kt b/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/internal/TelegramBotImpl.kt index 80f44a2..2285037 100644 --- a/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/internal/TelegramBotImpl.kt +++ b/simbot-component-telegram-core/src/commonMain/kotlin/love/forte/simbot/component/telegram/core/bot/internal/TelegramBotImpl.kt @@ -26,7 +26,8 @@ import kotlinx.coroutines.sync.withLock import love.forte.simbot.annotations.FragileSimbotAPI import love.forte.simbot.bot.JobBasedBot import love.forte.simbot.common.id.ID -import love.forte.simbot.common.id.literal +import love.forte.simbot.common.id.StringID.Companion.ID +import love.forte.simbot.common.id.toLongOrNull import love.forte.simbot.component.telegram.core.bot.StdlibBot import love.forte.simbot.component.telegram.core.bot.TelegramBot import love.forte.simbot.component.telegram.core.bot.TelegramBotConfiguration @@ -71,6 +72,8 @@ internal class TelegramBotImpl( internal val logger = LoggerFactory.getLogger("love.forte.simbot.component.telegram.core.bot") internal val eventLogger = LoggerFactory.getLogger("love.forte.simbot.component.telegram.stdlib.bot.event") + override val id: ID = source.ticket.token.ID + private var _userInfo: User? = null override val userInfo: User @@ -83,10 +86,10 @@ internal class TelegramBotImpl( } override fun isMe(id: ID): Boolean { - // TODO - return source.ticket.token == id.literal - } + val ui = _userInfo ?: return this.id == id + return this.id == id || ui.id == id.toLongOrNull() + } private val startLock = Mutex() @@ -99,6 +102,9 @@ internal class TelegramBotImpl( } source.start() + // init bot user info + queryUserInfo() + subscribeInternalProcessor(this, source, eventDispatcher) // mark started From 57eb2f09e5cd2da212533a5a5b93c9a4c8940ed2 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Sat, 20 Jul 2024 15:27:54 +0800 Subject: [PATCH 7/7] release: v0.0.7 --- .changelog/v0.0.7.md | 7 +++++++ buildSrc/src/main/kotlin/P.kt | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changelog/v0.0.7.md diff --git a/.changelog/v0.0.7.md b/.changelog/v0.0.7.md new file mode 100644 index 0000000..163b1a0 --- /dev/null +++ b/.changelog/v0.0.7.md @@ -0,0 +1,7 @@ +> 对应核心版本: [**v4.1.0**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.1.0) + + +我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-telegram/issues)或[协助](https://github.com/simple-robot/simbot-component-telegram/pulls), +感谢您的贡献与支持! + +也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可! diff --git a/buildSrc/src/main/kotlin/P.kt b/buildSrc/src/main/kotlin/P.kt index a75363a..72b4481 100644 --- a/buildSrc/src/main/kotlin/P.kt +++ b/buildSrc/src/main/kotlin/P.kt @@ -40,8 +40,8 @@ object P { override val description: String get() = DESCRIPTION override val homepage: String get() = HOMEPAGE - const val VERSION = "0.0.6" - const val NEXT_VERSION = "0.0.7" + const val VERSION = "0.0.7" + const val NEXT_VERSION = "0.0.8" override val snapshotVersion = "$NEXT_VERSION-SNAPSHOT" override val version = if (isSnapshot()) snapshotVersion else VERSION