25 Commits

Author SHA1 Message Date
cc7ef37539 build(action): 移除 gradle/actions/wrapper-validation 并将 gradle/actions/setup-gradle 升级至 v4 版本. 2024-08-30 08:52:40 +08:00
4cf670a4d0 build(action): 将 gradle/gradle-build-action@v3.1.0 迁移至 gradle/actions/setup-gradle@v3 2024-08-30 08:45:35 +08:00
63f68acccd build(action): 将 gradle/wrapper-validation-action@v2 迁移至 gradle/actions/wrapper-validation@v3 2024-05-15 08:50:32 +08:00
506f073bf6 release: 发布 0.7.0 版本. 2024-05-15 08:32:34 +08:00
9dc4bfa28f feat: 为 BotExtensionFactory 提供一些可用的信息. (#125)
为 BotExtensionFactory 的 createExtensionInstance 方法添加 BotExtensionCreateOptions 参数,
通过 BotExtensionCreateOptions 为扩展包 Factory 提供更多信息, 以避免扩展重复声明配置文件.

Issue #4
2024-03-25 23:22:26 +08:00
92a1deac50 build(deps): bump org.telegram:telegrambots-abilities from 6.8.0 to 6.9.7.1 2024-03-25 23:04:24 +08:00
0e2ce68a9c feat(container): 将容器镜像的 Java 镜像由 OpenJDK:18 更改至 eclipse-temurin:21-jdk-alpine
这将有利于支持通过更高版本 Java 构建的扩展包, 且减少镜像体积.
2024-03-25 22:54:36 +08:00
d57e63f8de build: 更新 Kotlin 版本由 1.9.22 到 1.9.23
更新 Kotlin 版本以更好的支持新特性.
2024-03-25 22:52:15 +08:00
73653cabc6 build(deps): bump commons-codec:commons-codec from 1.16.0 to 1.16.1 (#144)
Bumps [commons-codec:commons-codec](https://github.com/apache/commons-codec) from 1.16.0 to 1.16.1.
- [Changelog](https://github.com/apache/commons-codec/blob/master/RELEASE-NOTES.txt)
- [Commits](https://github.com/apache/commons-codec/compare/rel/commons-codec-1.16.0...rel/commons-codec-1.16.1)

---
updated-dependencies:
- dependency-name: commons-codec:commons-codec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-25 22:11:04 +08:00
9e87591671 build(deps): bump org.mockito:mockito-core from 5.9.0 to 5.11.0 (#141)
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.9.0 to 5.11.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v5.9.0...v5.11.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-15 18:10:17 +08:00
126092487d build(deps): bump softprops/action-gh-release from 1 to 2 (#142)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-15 17:16:18 +08:00
44bc52050c build(deps): bump gradle/wrapper-validation-action from 1 to 2 (#135)
Bumps [gradle/wrapper-validation-action](https://github.com/gradle/wrapper-validation-action) from 1 to 2.
- [Release notes](https://github.com/gradle/wrapper-validation-action/releases)
- [Commits](https://github.com/gradle/wrapper-validation-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: gradle/wrapper-validation-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-15 16:26:35 +08:00
f809076df0 build(deps): bump org.jetbrains.kotlinx.binary-compatibility-validator (#134)
Bumps [org.jetbrains.kotlinx.binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) from 0.13.2 to 0.14.0.
- [Release notes](https://github.com/Kotlin/binary-compatibility-validator/releases)
- [Commits](https://github.com/Kotlin/binary-compatibility-validator/compare/0.13.2...0.14.0)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlinx.binary-compatibility-validator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-15 16:21:33 +08:00
b34f05a90b build(deps): bump gradle/gradle-build-action from 2.11.1 to 3.1.0 (#140)
Bumps [gradle/gradle-build-action](https://github.com/gradle/gradle-build-action) from 2.11.1 to 3.1.0.
- [Release notes](https://github.com/gradle/gradle-build-action/releases)
- [Commits](https://github.com/gradle/gradle-build-action/compare/v2.11.1...v3.1.0)

---
updated-dependencies:
- dependency-name: gradle/gradle-build-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-15 16:12:29 +08:00
ddc4de1340 build(deps): bump io.mockk:mockk from 1.13.8 to 1.13.9 (#123)
Bumps [io.mockk:mockk](https://github.com/mockk/mockk) from 1.13.8 to 1.13.9.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/commits)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-21 23:28:07 +08:00
a9134f378e build(deps): bump org.slf4j:slf4j-api from 2.0.9 to 2.0.11 (#124)
Bumps org.slf4j:slf4j-api from 2.0.9 to 2.0.11.

---
updated-dependencies:
- dependency-name: org.slf4j:slf4j-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-21 23:23:37 +08:00
dbb2fcdee1 build(deps): bump org.mockito:mockito-core from 5.8.0 to 5.9.0 (#128)
Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.8.0 to 5.9.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v5.8.0...v5.9.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-21 23:17:55 +08:00
ce00369a22 build(deps): bump org.jetbrains.kotlin:kotlin-reflect (#120)
Bumps [org.jetbrains.kotlin:kotlin-reflect](https://github.com/JetBrains/kotlin) from 1.9.21 to 1.9.22.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.21...v1.9.22)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-reflect
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-07 19:31:51 +08:00
65bac28303 build(deps): bump jvm from 1.9.10 to 1.9.22 (#119)
Bumps [jvm](https://github.com/JetBrains/kotlin) from 1.9.10 to 1.9.22.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.10...v1.9.22)

---
updated-dependencies:
- dependency-name: jvm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-07 18:47:23 +08:00
8bd6d5ffe5 build(deps): bump ch.qos.logback:logback-classic from 1.4.11 to 1.4.14 (#118)
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.4.11 to 1.4.14.
- [Commits](https://github.com/qos-ch/logback/compare/v_1.4.11...v_1.4.14)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-07 17:42:06 +08:00
1c4cc122c9 build(deps): bump org.jetbrains.kotlinx.kover from 0.7.4 to 0.7.5 (#117)
Bumps [org.jetbrains.kotlinx.kover](https://github.com/Kotlin/kotlinx-kover) from 0.7.4 to 0.7.5.
- [Release notes](https://github.com/Kotlin/kotlinx-kover/releases)
- [Changelog](https://github.com/Kotlin/kotlinx-kover/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Kotlin/kotlinx-kover/compare/0.7.4...v0.7.5)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlinx.kover
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-07 17:41:57 +08:00
6083f4fc68 build(deps): bump org.junit.jupiter:junit-jupiter-api (#115)
Bumps [org.junit.jupiter:junit-jupiter-api](https://github.com/junit-team/junit5) from 5.10.0 to 5.10.1.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.10.0...r5.10.1)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-07 17:41:41 +08:00
b33de4d63a build(deps): bump gradle/gradle-build-action from 2.11.0 to 2.11.1 (#121)
Bumps [gradle/gradle-build-action](https://github.com/gradle/gradle-build-action) from 2.11.0 to 2.11.1.
- [Release notes](https://github.com/gradle/gradle-build-action/releases)
- [Commits](https://github.com/gradle/gradle-build-action/compare/v2.11.0...v2.11.1)

---
updated-dependencies:
- dependency-name: gradle/gradle-build-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-07 17:41:27 +08:00
fd67eb99eb feat: 在启动机器人时调用 GetMe 接口, 以检查 Token 有效性.
通过这种方式, 可以帮助用户在启动阶段发现 Bot Token 无效的问题.
2023-12-18 22:21:58 +08:00
ba306e679f build(deps): bump all telegrambots deps from 6.7.0 to 6.8.0 (#114)
Bumps [org.telegram:telegrambots](https://github.com/rubenlagus/TelegramBots) from 6.7.0 to 6.8.0.
- [Release notes](https://github.com/rubenlagus/TelegramBots/releases)
- [Commits](rubenlagus/TelegramBots@v6.7.0...v6.8.0)

---
updated-dependencies:
- dependency-name: org.telegram:telegrambots-abilities
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.telegram:telegrambots
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.telegram:telegrambots-meta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...
2023-12-17 23:10:52 +08:00
17 changed files with 112 additions and 59 deletions

View File

@ -25,12 +25,9 @@ jobs:
with:
java-version: '11'
distribution: 'adopt-hotspot'
cache: 'gradle'
- uses: gradle/wrapper-validation-action@v1
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and run binary compatibility verification
uses: gradle/gradle-build-action@v2.11.0
with:
gradle-version: 'wrapper'
arguments: apiCheck
run: ./gradlew apiCheck

View File

@ -24,12 +24,9 @@ jobs:
with:
java-version: '11'
distribution: 'adopt-hotspot'
cache: 'gradle'
- uses: gradle/wrapper-validation-action@v1
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and test
uses: gradle/gradle-build-action@v2.11.0
with:
gradle-version: 'wrapper'
arguments: test
run: ./gradlew clean test

View File

@ -44,22 +44,20 @@ jobs:
with:
java-version: '11'
distribution: 'adopt-hotspot'
cache: 'gradle'
- uses: gradle/wrapper-validation-action@v1
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and test
uses: gradle/gradle-build-action@v2.11.0
with:
gradle-version: 'wrapper'
arguments: clean test assembleDist
uses: gradle/gradle-build-action@v3.1.0
run: ./gradlew clean test assembleDist
# 创建新的发行版本
- name: Create Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
draft: true
body_path: ${{ github.workspace }}/CURRENT_CHANGELOG.md
files: |
*/build/distributions/*
*/build/libs/*
*/build/libs/*

View File

@ -20,15 +20,12 @@ jobs:
with:
java-version: '11'
distribution: 'adopt-hotspot'
cache: 'gradle'
- uses: gradle/wrapper-validation-action@v1
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and test
uses: gradle/gradle-build-action@v2.11.0
with:
gradle-version: 'wrapper'
arguments: clean test installDist
run: ./gradlew clean test installDist
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
@ -46,4 +43,4 @@ jobs:
tags: ${{ env.IMAGE_NAME }}:latest, ${{ env.IMAGE_NAME }}:${{ github.ref_name }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max

View File

@ -20,15 +20,12 @@ jobs:
with:
java-version: '11'
distribution: 'adopt-hotspot'
cache: 'gradle'
- uses: gradle/wrapper-validation-action@v1
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build project and install Distribution package
uses: gradle/gradle-build-action@v2.11.0
with:
gradle-version: 'wrapper'
arguments: installDist
run: ./gradlew clean test installDist
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
@ -46,4 +43,4 @@ jobs:
tags: lamgc/scalabot:dev
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max

View File

@ -1,4 +1,4 @@
FROM openjdk:18
FROM eclipse-temurin:21-jdk-alpine
ENV BOT_DATA_PATH /scalabot/data/
WORKDIR /scalabot/run/

View File

@ -1,7 +1,7 @@
plugins {
kotlin("jvm") version "1.9.10" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.4" apply false
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" apply false
kotlin("jvm") version "1.9.23" apply false
id("org.jetbrains.kotlinx.kover") version "0.7.5" apply false
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.14.0" apply false
}
allprojects {
@ -13,5 +13,5 @@ allprojects {
}
group = "net.lamgc"
version = "0.6.1"
}
version = "0.7.0"
}

View File

@ -10,9 +10,9 @@ dependencies {
implementation(project(":scalabot-meta"))
implementation(project(":scalabot-extension"))
implementation("org.slf4j:slf4j-api:2.0.9")
implementation("org.slf4j:slf4j-api:2.0.11")
implementation("io.github.microutils:kotlin-logging:3.0.5")
implementation("ch.qos.logback:logback-classic:1.4.11")
implementation("ch.qos.logback:logback-classic:1.4.14")
val aetherVersion = "1.1.0"
implementation("org.eclipse.aether:aether-api:$aetherVersion")
@ -24,19 +24,19 @@ dependencies {
implementation("org.apache.maven:maven-aether-provider:3.3.9")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.21")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.23")
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.jdom:jdom2:2.0.6.1")
implementation("org.telegram:telegrambots-abilities:6.8.0")
implementation("org.telegram:telegrambots:6.8.0")
implementation("org.telegram:telegrambots-abilities:6.9.7.1")
implementation("org.telegram:telegrambots:6.9.7.1")
implementation("io.prometheus:simpleclient:0.16.0")
implementation("io.prometheus:simpleclient_httpserver:0.16.0")
testImplementation(kotlin("test"))
testImplementation("io.mockk:mockk:1.13.8")
testImplementation("io.mockk:mockk:1.13.9")
testImplementation("com.github.stefanbirkner:system-lambda:1.2.1")
}

View File

@ -9,6 +9,8 @@ import net.lamgc.scalabot.util.registerShutdownHook
import org.eclipse.aether.repository.LocalRepository
import org.telegram.telegrambots.bots.DefaultBotOptions
import org.telegram.telegrambots.meta.TelegramBotsApi
import org.telegram.telegrambots.meta.api.methods.GetMe
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException
import org.telegram.telegrambots.meta.generics.BotSession
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession
import java.io.File
@ -135,7 +137,11 @@ internal class Launcher(
launchBot(botConfig)
launchedCounts++
} catch (e: Exception) {
log.error(e) { "机器人 `${botConfig.account.name}` 启动时发生错误." }
if (e is TelegramApiRequestException && e.errorCode == 401) {
log.error { "机器人 `${botConfig.account.name}` 的 Bot Token 无效, 请检查配置: [${e.errorCode}] ${e.apiResponse}" }
} else {
log.error(e) { "机器人 `${botConfig.account.name}` 启动时发生错误." }
}
}
}
return if (launchedCounts != 0) {
@ -201,6 +207,10 @@ internal class Launcher(
extensionPackageFinders,
botConfig
)
val botUser = bot.execute(GetMe())
log.debug { "已验证 Bot Token 有效性, Bot Username: ${botUser.userName}" }
botSessionMap[bot] = botApi.registerBot(bot)
log.info { "机器人 `${bot.botUsername}` 已启动." }

View File

@ -1,6 +1,7 @@
package net.lamgc.scalabot
import mu.KotlinLogging
import net.lamgc.scalabot.extension.BotExtensionCreateOptions
import net.lamgc.scalabot.extension.BotExtensionFactory
import net.lamgc.scalabot.util.getPriority
import org.eclipse.aether.artifact.Artifact
@ -122,7 +123,12 @@ internal class ExtensionLoader(
for (factory in extClassLoader.serviceLoader) {
try {
val extension =
factory.createExtensionInstance(bot, getExtensionDataFolder(extensionArtifact))
factory.createExtensionInstance(
bot, getExtensionDataFolder(extensionArtifact),
BotExtensionCreateOptions(
bot.botConfig.proxy.copy()
)
)
if (extension == null) {
log.debug { "Factory ${factory::class.java} 创建插件时返回了 null, 已跳过. (BotName: ${bot.botUsername})" }
continue

View File

@ -29,7 +29,7 @@ internal class ScalaBot(
db: DBContext,
options: DefaultBotOptions,
extensionFinders: Set<ExtensionPackageFinder>,
botConfig: BotConfig,
val botConfig: BotConfig,
private val creatorId: Long = botConfig.account.creatorId,
val accountId: Long = botConfig.account.id,
val extensions: Set<Artifact> = botConfig.extensions

View File

@ -5,7 +5,7 @@ plugins {
dependencies {
compileOnly(project(":scalabot-extension"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

View File

@ -1,5 +1,6 @@
package net.lamgc.scalabot.simple;
import net.lamgc.scalabot.extension.BotExtensionCreateOptions;
import net.lamgc.scalabot.extension.BotExtensionFactory;
import org.telegram.abilitybots.api.bot.BaseAbilityBot;
import org.telegram.abilitybots.api.util.AbilityExtension;
@ -9,7 +10,7 @@ import java.io.File;
public class SimpleExtensionFactory implements BotExtensionFactory {
@Override
public AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder) {
public AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder, BotExtensionCreateOptions options) {
return new SayHelloExtension(bot);
}

View File

@ -7,11 +7,12 @@ plugins {
}
dependencies {
implementation("commons-codec:commons-codec:1.16.0")
api("org.telegram:telegrambots-abilities:6.8.0")
implementation("commons-codec:commons-codec:1.16.1")
api("org.telegram:telegrambots-abilities:6.9.7.1")
api(project(":scalabot-meta"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testImplementation("org.mockito:mockito-core:5.8.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testImplementation("org.mockito:mockito-core:5.11.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

View File

@ -0,0 +1,22 @@
package net.lamgc.scalabot.extension;
import net.lamgc.scalabot.config.ProxyConfig;
/**
* BotExtension 创建参数.
* <p>
* 通过该类可向 {@link BotExtensionFactory} 提供更多创建 BotExtension 时可用的参数.
*/
@SuppressWarnings("unused")
public class BotExtensionCreateOptions {
private final ProxyConfig proxy;
public BotExtensionCreateOptions(ProxyConfig proxy) {
this.proxy = proxy;
}
public ProxyConfig getProxy() {
return proxy;
}
}

View File

@ -31,7 +31,34 @@ public interface BotExtensionFactory {
* <b>同一个扩展包的 Factory</b> 接收到的共享数据目录<b>都是一样的</b>,
* 建议将数据存储在数据目录中, 便于数据的存储管理.
* @return 返回为该 Bot 对象创建的扩展对象, 如果不希望为该机器人提供扩展, 可返回 {@code null}.
* @deprecated 请使用 {@link #createExtensionInstance(BaseAbilityBot, File, BotExtensionCreateOptions)},
* 该方法最迟在 1.0.0 正式版中移除.
* @since 0.0.1
*/
AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder);
@Deprecated(since = "0.7.0", forRemoval = true)
default AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder) {
throw new UnsupportedOperationException("The method has not been implemented.");
}
/**
* 为给定的 {@link BaseAbilityBot} 对象创建扩展.
*
* <p> 如扩展无使用 {@link org.telegram.abilitybots.api.db.DBContext} 的话,
* 也可以返回扩展单例, 因为 AbilityBot 本身并不禁止多个机器人共用一个扩展对象
* (AbilityBot 只是调用了扩展中的方法来创建 Ability 对象).
*
* @param bot 机器人对象.
* @param shareDataFolder ScalaBot App 为扩展提供的共享数据目录.
* <p>路径格式为:
* <pre> $DATA_ROOT/data/extensions/{GroupId}/{ArtifactId}</pre>
* <b>同一个扩展包的 Factory</b> 接收到的共享数据目录<b>都是一样的</b>,
* 建议将数据存储在数据目录中, 便于数据的存储管理.
* @param options 创建扩展时可用的参数.
* @return 返回为该 Bot 对象创建的扩展对象, 如果不希望为该机器人提供扩展, 可返回 {@code null}.
* @since 0.7.0
*/
default AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder, BotExtensionCreateOptions options) {
return createExtensionInstance(bot, shareDataFolder);
}
}

View File

@ -12,13 +12,13 @@ dependencies {
api("org.eclipse.aether:aether-api:$aetherVersion")
implementation("org.eclipse.aether:aether-util:$aetherVersion")
implementation("org.telegram:telegrambots-meta:6.8.0")
implementation("org.telegram:telegrambots-meta:6.9.7.1")
api("com.google.code.gson:gson:2.10.1")
testImplementation(kotlin("test"))
testImplementation("io.mockk:mockk:1.13.8")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testImplementation("io.mockk:mockk:1.13.9")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
dokkaHtmlPlugin("org.jetbrains.dokka:javadoc-plugin:1.9.10")