Skip to content

Commit

Permalink
Merge pull request #6 from simple-robot/dev/main
Browse files Browse the repository at this point in the history
Release: v0.0.1-dev2
  • Loading branch information
ForteScarlet authored Apr 15, 2024
2 parents d6ac695 + 5833ba8 commit f351022
Show file tree
Hide file tree
Showing 66 changed files with 4,079 additions and 382 deletions.
19 changes: 18 additions & 1 deletion .changelog/v0.0.1-dev1.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,25 @@ bot.join()
> [!note]
> 如果不配置 `longPolling`,也就是只使用 Telegram 的 webhook 的形式接收事件,
> 那么你需要自行启动一个 HTTP 服务,并将接收到的请求体的 JSON 字符串(或解析后的 `Update` 实体)提供给 bot。
> ```Kotlin
```Kotlin
val bot = ...
bot.start()

// 假设你使用 Kror Server
embeddedServer(Netty, port = 80) {
routing {
get ("/YOUR_ROUTE") {
// The `Update` JSON string.
val raw = call.receiveText()

// Push `Update` to bot. Maybe in try-catch? Myabe in launch { ... } ?
bot.pushUpdate(Update.decodeFromRawJson(raw), raw)

// respond a result to Telegram
call.respondText("""{"ok":true}""")
}
}
}.start(wait = true)
```


Expand Down
11 changes: 11 additions & 0 deletions .changelog/v0.0.1-dev2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
> 对应核心版本: [**v4.0.0-beta3**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-beta3)

> [!warning]
> **目前版本处于 `dev` 阶段,代表此版本是一个开发预览版,可能不稳定、可能随时发生更改、且不保证可用性。**

我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-telegram/issues)[协助](https://github.com/simple-robot/simbot-component-telegram/pulls)
感谢您的贡献与支持!

也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可!
36 changes: 13 additions & 23 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ jobs:
java-version: 21

# setup Gradle
- uses: gradle/actions/setup-gradle@v3

- name: Gradle test and publish snapshot
uses: gradle/actions/setup-gradle@v3
run: gradle allTests publishToSonatype closeAndReleaseStagingRepository --info --warning-mode all "-Porg.gradle.daemon=false" "-Porg.gradle.jvmargs='-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8'"

- name: Upload test reports
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
gradle-version: 8.5
arguments: |
allTests
publishToSonatype
closeAndReleaseStagingRepository
--info
--warning-mode all
-Porg.gradle.jvmargs="-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
-Porg.gradle.daemon=false
name: test-reports-${{ runner.os }}
path: '**/build/reports/tests'
retention-days: 7

deploy-doc:
name: Deploy-doc
Expand All @@ -86,19 +86,9 @@ jobs:
java-version: 21

# setup Gradle
- name: Gradle generate documentation
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.5
arguments: |
-Porg.gradle.jvmargs="-Xmx4g -Xms4g -XX:MaxMetaspaceSize=2g -Dfile.encoding=UTF-8"
-Porg.gradle.daemon=false
-DisSnapshot=false
--info
--warning-mode all
-x test
--build-cache
dokkaHtmlMultiModule
- uses: gradle/actions/setup-gradle@v3

- run: gradle dokkaHtmlMultiModule "-Porg.gradle.jvmargs='-Xmx4g -Xms4g -XX:MaxMetaspaceSize=2g -Dfile.encoding=UTF-8'" "-Porg.gradle.daemon=false" "-DisSnapshot=false" --info --warning-mode all -x test --build-cache

- name: Push to doc repository
uses: peaceiris/actions-gh-pages@v3
Expand Down
25 changes: 11 additions & 14 deletions .github/workflows/test-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,13 @@ jobs:
java-version: 21
cache: 'gradle'

- name: Run All Tests
- name: Set up gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.5
arguments: |
assemble
build
allTests
--info
--warning-mode all
# --build-cache
# -Porg.gradle.daemon=false
# -Porg.gradle.jvmargs="-Xmx4g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
add-job-summary-as-pr-comment: on-failure # Valid values are 'never' (default), 'always', and 'on-failure'

- name: Run All Tests
run: gradle assemble allTests "-Porg.gradle.jvmargs='-Xmx4g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8'" --info --warning-mode all --build-cache

- name: Upload test reports
uses: actions/upload-artifact@v4
Expand All @@ -68,11 +62,14 @@ jobs:
java-version: 21
cache: 'gradle'

- name: Run All Tests
- name: Set up gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.5
arguments: detekt
add-job-summary-as-pr-comment: on-failure # Valid values are 'never' (default), 'always', and 'on-failure'

- name: Run detekt
run: gradle detekt

- name: Upload detekt reports
uses: actions/upload-artifact@v4
if: ${{ always() }}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
> [Feel free to share](https://github.com/simple-robot/simbot-component-telegram/issues)
> or join the [communities](https://simbot.forte.love/communities.html).
> [!warning]
> This content is machine-translated.
This is a [**Telegram Bot**][telegram bot doc] API/SDK Kotlin multi-platform library based on
Expand Down Expand Up @@ -78,6 +79,8 @@ The goal is to preserve the feel of the original API as much as possible without
Based on [API module](simbot-component-telegram-api),
for the implementation of authentication, subscription events and other related functions in bot.

The `stdlib` module can be thought of as a lightweight SDK implementation library.

This module provides an implementation of event-related functionality based on the API module,
including the ability to subscribe to events.

Expand Down
2 changes: 2 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Kotlin 多平台库,异步高效、Java友好。

基于 [API模块](simbot-component-telegram-api) 针对 bot 的鉴权、事件订阅等功能的实现。

stdlib模块可以被看作是一个轻量级的 SDK 实现库。

同样的,其目标为在提供封装的情况下尽可能地保留原始API的使用手感,不做过多的封装。

👉 [前往模块](simbot-component-telegram-stdlib) 了解更多。
Expand Down
7 changes: 5 additions & 2 deletions buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ object P {

object ComponentTelegram : ProjectDetail() {
const val GROUP = "love.forte.simbot.component"
const val DESCRIPTION = "Kotlin coroutines based Telegram bot API/SDK Kotlin multiplatform library, is also a Simple Robot Component library"
const val DESCRIPTION =
"Kotlin coroutines based Telegram bot API/SDK Kotlin multiplatform library, " +
"is also a Simple Robot Component library"

const val HOMEPAGE = "https://github.com/simple-robot/simbot-component-telegram"

override val group: String get() = GROUP
override val description: String get() = DESCRIPTION
override val homepage: String get() = HOMEPAGE


private val baseVersion = v(0, 0, 1) - v("dev1")
private val baseVersion = v(0, 0, 1) - v("dev2")

val snapshotVersion = baseVersion - Version.SNAPSHOT
override val version = if (isSnapshot()) snapshotVersion else baseVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repositories {
}

fun org.jetbrains.dokka.gradle.AbstractDokkaTask.configOutput(format: String) {
moduleName.set("Simple Robot 组件 | Discord")
moduleName.set("Simple Robot 组件 | Telegram")
outputDirectory.set(rootProject.file("build/dokka/$format"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ plugins {
tasks.withType<DokkaTaskPartial>().configureEach {
dokkaSourceSets.configureEach {
version = P.ComponentTelegram.version.toString()
documentedVisibilities.set(listOf(DokkaConfiguration.Visibility.PUBLIC, DokkaConfiguration.Visibility.PROTECTED))
documentedVisibilities.set(
listOf(DokkaConfiguration.Visibility.PUBLIC, DokkaConfiguration.Visibility.PROTECTED)
)
fun checkModule(projectFileName: String): Boolean {
val moduleMdFile = project.file(projectFileName)
if (moduleMdFile.exists()) {
Expand Down Expand Up @@ -57,7 +59,7 @@ tasks.withType<DokkaTaskPartial>().configureEach {
sourceLink {
localDirectory.set(projectDir.resolve("src"))
val relativeTo = projectDir.relativeTo(rootProject.projectDir)
remoteUrl.set(URI.create("${P.ComponentTelegram.HOMEPAGE}/tree/main/$relativeTo/src/").toURL())
remoteUrl.set(URI.create("${P.ComponentTelegram.HOMEPAGE}/tree/dev/main/$relativeTo/src/").toURL())
remoteLineSuffix.set("#L")
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
kotlin.code.style=official
kotlin.js.generate.executable.default=false
kotlin.native.ignoreDisabledTargets=true
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ private class ComponentEventProcessor(private val environment: SymbolProcessorEn
****************************
""".trimIndent()
)
addAnnotation(
AnnotationSpec.builder(Suppress::class)
.addMember("%S, %S", "ALL", "unused")
.build()
)
indent(" ")
}.build()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Component Events processor

用于在核心组件模块中生成所有基础的事件类型定义的接口。

会根据 `Update` 中的所有类型,定义所有如下类型的接口:

```kotlin

interface TelegramXxxEvent : TelegramEvent {
override val sourceContent: Xxx // 实际上的事件类型
}

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("jvm")
}

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(11)
compilerOptions {
javaParameters = true
jvmTarget.set(JvmTarget.JVM_11)
}
}

configJavaCompileWithModule()

dependencies {
// implementation(project(":annotations"))
api(libs.ksp)
api(libs.kotlinPoet.ksp)
testImplementation(kotlin("test-junit5"))
}

tasks.getByName<Test>("test") {
useJUnitPlatform()
}

Loading

0 comments on commit f351022

Please sign in to comment.