Skip to content

Commit 80c47ff

Browse files
committed
请求相关内容增加JVM平台的额外实现
1 parent f87baa7 commit 80c47ff

File tree

8 files changed

+853
-6
lines changed

8 files changed

+853
-6
lines changed

.github/workflows/publish-release.yml

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: Publish Release
2+
on:
3+
push:
4+
tags:
5+
- v**
6+
7+
env:
8+
IS_CI: true
9+
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
10+
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
11+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
12+
OSSRH_USER: ${{ secrets.SONATYPE_USERNAME }}
13+
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
14+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
15+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
16+
GRADLE_OPTS: "-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
17+
18+
19+
jobs:
20+
run-test-and-publish:
21+
name: Run test and publish
22+
strategy:
23+
matrix:
24+
os: [ macos-latest, ubuntu-latest, windows-latest ]
25+
runs-on: ${{ matrix.os }}
26+
steps:
27+
# 检出仓库代码
28+
- uses: actions/checkout@v4
29+
30+
# setup Java
31+
- name: Setup Java
32+
uses: actions/setup-java@v4
33+
with:
34+
distribution: 'zulu'
35+
java-version: 21
36+
cache: 'gradle'
37+
38+
# setup Gradle
39+
- name: Gradle Run Test
40+
uses: gradle/actions/setup-gradle@v3
41+
with:
42+
gradle-version: 8.5
43+
arguments: assemble test -Porg.gradle.daemon=false
44+
45+
# setup Gradle
46+
- name: Publish Release
47+
uses: gradle/actions/setup-gradle@v3
48+
with:
49+
gradle-version: 8.5
50+
arguments: |
51+
publishToSonatype
52+
closeAndReleaseStagingRepository
53+
--info
54+
--warning-mode all
55+
-x test
56+
--build-cache
57+
-Porg.gradle.jvmargs="-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
58+
59+
env:
60+
SIMBOT_IS_SNAPSHOT: false
61+
SIMBOT_RELEASES_ONLY: true
62+
63+
create-release:
64+
name: Create release
65+
runs-on: ubuntu-latest
66+
needs: run-test-and-publish
67+
permissions:
68+
contents: write
69+
steps:
70+
# 检出仓库代码
71+
- name: Check Out Repo
72+
uses: actions/checkout@v4
73+
74+
# Create gitHub release
75+
- name: Create Github Release
76+
uses: softprops/action-gh-release@v2
77+
with:
78+
token: ${{ secrets.PUSH_TOKEN }}
79+
body: '${{ github.ref_name }}'
80+
body_path: .changelog/${{ github.ref_name }}.md
81+
generate_release_notes: true
82+
prerelease: ${{ contains(github.ref_name, 'preview') || contains(github.ref_name, 'alpha') }}
83+
84+
# || contains(github.ref_name, 'beta')
85+
86+
publish-snapshot:
87+
name: Publish snapshot
88+
strategy:
89+
matrix:
90+
os: [ macos-latest, windows-latest, ubuntu-latest ]
91+
runs-on: ${{ matrix.os }}
92+
needs: run-test-and-publish
93+
steps:
94+
# 检出仓库代码
95+
- name: Check out repo
96+
uses: actions/checkout@v4
97+
98+
# setup Java
99+
- name: Setup java
100+
uses: actions/setup-java@v4
101+
with:
102+
distribution: 'zulu'
103+
java-version: 21
104+
105+
# setup Gradle
106+
- name: Gradle publish snapshot
107+
uses: gradle/actions/setup-gradle@v3
108+
with:
109+
gradle-version: 8.5
110+
arguments: |
111+
publishToSonatype
112+
closeAndReleaseStagingRepository
113+
--info
114+
--warning-mode all
115+
-x test
116+
--build-cache
117+
-Porg.gradle.jvmargs="-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
118+
-Porg.gradle.daemon=false
119+
env:
120+
SIMBOT_IS_SNAPSHOT: true
121+
SIMBOT_SNAPSHOT_ONLY: true
122+
123+
deploy-doc:
124+
name: Deploy-doc
125+
runs-on: ubuntu-latest
126+
needs: run-test-and-publish
127+
steps:
128+
# 检出仓库代码
129+
- name: Check out repo
130+
uses: actions/checkout@v4
131+
with:
132+
persist-credentials: false
133+
fetch-depth: 0
134+
# setup Java
135+
- name: Setup java
136+
uses: actions/setup-java@v4
137+
with:
138+
distribution: 'zulu'
139+
java-version: 21
140+
141+
# setup Gradle
142+
- name: Gradle generate documentation
143+
uses: gradle/actions/setup-gradle@v3
144+
with:
145+
gradle-version: 8.5
146+
arguments: |
147+
dokkaHtmlMultiModule
148+
--info
149+
--warning-mode all
150+
-x test
151+
--build-cache
152+
-Porg.gradle.jvmargs="-Xmx8g -Xms2g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8"
153+
-Porg.gradle.daemon=false
154+
155+
- name: Push to doc repository
156+
uses: peaceiris/actions-gh-pages@v3
157+
with:
158+
personal_token: ${{ secrets.PUSH_TOKEN }}
159+
external_repository: simple-robot-library/simbot3-api-docs
160+
publish_branch: kdoc-deploy/component-onebot
161+
publish_dir: ./build/dokka/html
162+
# deploy to sub dir
163+
destination_dir: components/onebot

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,42 @@ Simple Robot OneBot 组件是一个将
5353
[协助](https://github.com/simple-robot/simbot-component-onebot/pulls)
5454
感谢您的贡献与支持!
5555

56+
## 配置文件
57+
58+
使用spring的时候用的。需要注意实际上是不允许使用注释的,这里只是方便展示。
59+
60+
```json5
61+
{
62+
// 固定值
63+
"component": "simbot.onebot11",
64+
"authorization": {
65+
// 唯一ID,作为组件内 Bot 的 id,用于组件内去重。可以随便编,但建议是bot的qq号
66+
"botUniqueId": "123456",
67+
// api地址,是个http/https服务器的路径,默认localhost:3000
68+
"apiServerHost": "http://localhost:3000",
69+
// 订阅事件的服务器地址,是个ws/wss路径,默认localhost:3001
70+
"eventServerHost":"ws://localhost:3001",
71+
// 配置的 token,可以是null
72+
"accessToken": null
73+
},
74+
// 额外的可选配置
75+
// config本身以及其内的各项属性绝大多数都可省略或null
76+
config: {
77+
// API请求中的超时请求配置。整数数字,单位毫秒,默认为 `null`。
78+
"apiHttpRequestTimeoutMillis": null,
79+
// API请求中的超时请求配置。整数数字,单位毫秒,默认为 `null`。
80+
"apiHttpConnectTimeoutMillis": null,
81+
// API请求中的超时请求配置。整数数字,单位毫秒,默认为 `null`。
82+
"apiHttpSocketTimeoutMillis": null,
83+
// 每次尝试连接到 ws 服务时的最大重试次数,大于等于0的整数,默认为 2147483647
84+
"wsConnectMaxRetryTimes": null,
85+
// 每次尝试连接到 ws 服务时,如果需要重新尝试,则每次尝试之间的等待时长
86+
// 整数数字,单位毫秒,默认为 3500
87+
"wsConnectRetryDelayMillis": null,
88+
}
89+
}
90+
```
91+
5692
## License
5793

5894
```

buildSrc/src/main/kotlin/simbot-onebot-multiplatform-maven-publish.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ multiplatformConfigPublishing {
8282
logger.info("Is 'SIMBOT_LOCAL', mainHost set as null")
8383
mainHost = null
8484
}
85-
86-
publicationsFromMainHost += listOf("wasm", "wasm32", "wasm_js")
87-
mainHostSupportedTargets += listOf("wasm", "wasm32", "wasm_js")
8885
}
8986

9087
// TODO see https://github.com/gradle-nexus/publish-plugin/issues/208#issuecomment-1465029831

simbot-component-onebot11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/OneBot11.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package love.forte.simbot.component.onebot.v11.core
1919

20+
import kotlinx.serialization.ExperimentalSerializationApi
2021
import kotlinx.serialization.json.Json
2122
import kotlinx.serialization.modules.SerializersModule
2223
import kotlinx.serialization.modules.polymorphic
@@ -63,12 +64,14 @@ public object OneBot11 {
6364
* 一个默认的 [Json] 序列化器。
6465
* 会在部分内部API中使用。
6566
*/
67+
@OptIn(ExperimentalSerializationApi::class)
6668
@JvmField
6769
public val DefaultJson: Json = Json {
6870
isLenient = true
6971
ignoreUnknownKeys = true
7072
allowSpecialFloatingPointValues = true
7173
prettyPrint = false
7274
serializersModule = OneBot11.serializersModule
75+
allowTrailingComma = true
7376
}
7477
}

simbot-component-onebot11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
@file:JvmName("OneBotApiRequests")
19+
@file:JvmMultifileClass
1920

2021
package love.forte.simbot.component.onebot.v11.core.api
2122

@@ -32,12 +33,11 @@ import love.forte.simbot.common.serialization.guessSerializer
3233
import love.forte.simbot.component.onebot.v11.core.OneBot11
3334
import love.forte.simbot.logger.Logger
3435
import love.forte.simbot.logger.LoggerFactory
36+
import kotlin.jvm.JvmMultifileClass
3537
import kotlin.jvm.JvmName
3638
import kotlin.jvm.JvmOverloads
3739
import kotlin.jvm.JvmSynthetic
3840

39-
// TODO JVM async, blocking
40-
4141
/**
4242
* 用于在对 [OneBotApi] 发起请求时输出相关的 `debug` 日志。
4343
*/

simbot-component-onebot11-core/src/jvmMain/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
requires io.ktor.client.core;
2424
requires io.ktor.client.websockets;
2525
requires io.ktor.http;
26+
requires io.ktor.io;
2627

2728
exports love.forte.simbot.component.onebot.v11.core;
2829
exports love.forte.simbot.component.onebot.v11.core.actor;

0 commit comments

Comments
 (0)