mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-07-01 04:47:24 +00:00
Compare commits
1 Commits
v0.7.0
...
bump-tgbot
Author | SHA1 | Date | |
---|---|---|---|
6f8ec737b4
|
@ -26,11 +26,11 @@ jobs:
|
||||
java-version: '11'
|
||||
distribution: 'adopt-hotspot'
|
||||
cache: 'gradle'
|
||||
- uses: gradle/wrapper-validation-action@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build and run binary compatibility verification
|
||||
uses: gradle/gradle-build-action@v3.1.0
|
||||
uses: gradle/gradle-build-action@v2.11.0
|
||||
with:
|
||||
gradle-version: 'wrapper'
|
||||
arguments: apiCheck
|
||||
|
4
.github/workflows/build-and-test.yml
vendored
4
.github/workflows/build-and-test.yml
vendored
@ -25,11 +25,11 @@ jobs:
|
||||
java-version: '11'
|
||||
distribution: 'adopt-hotspot'
|
||||
cache: 'gradle'
|
||||
- uses: gradle/wrapper-validation-action@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build and test
|
||||
uses: gradle/gradle-build-action@v3.1.0
|
||||
uses: gradle/gradle-build-action@v2.11.0
|
||||
with:
|
||||
gradle-version: 'wrapper'
|
||||
arguments: test
|
||||
|
6
.github/workflows/create-release.yml
vendored
6
.github/workflows/create-release.yml
vendored
@ -45,18 +45,18 @@ jobs:
|
||||
java-version: '11'
|
||||
distribution: 'adopt-hotspot'
|
||||
cache: 'gradle'
|
||||
- uses: gradle/wrapper-validation-action@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build and test
|
||||
uses: gradle/gradle-build-action@v3.1.0
|
||||
uses: gradle/gradle-build-action@v2.11.0
|
||||
with:
|
||||
gradle-version: 'wrapper'
|
||||
arguments: clean test assembleDist
|
||||
|
||||
# 创建新的发行版本
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: true
|
||||
body_path: ${{ github.workspace }}/CURRENT_CHANGELOG.md
|
||||
|
4
.github/workflows/publish-artifacts.yml
vendored
4
.github/workflows/publish-artifacts.yml
vendored
@ -21,11 +21,11 @@ jobs:
|
||||
java-version: '11'
|
||||
distribution: 'adopt-hotspot'
|
||||
cache: 'gradle'
|
||||
- uses: gradle/wrapper-validation-action@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build and test
|
||||
uses: gradle/gradle-build-action@v3.1.0
|
||||
uses: gradle/gradle-build-action@v2.11.0
|
||||
with:
|
||||
gradle-version: 'wrapper'
|
||||
arguments: clean test installDist
|
||||
|
@ -21,11 +21,11 @@ jobs:
|
||||
java-version: '11'
|
||||
distribution: 'adopt-hotspot'
|
||||
cache: 'gradle'
|
||||
- uses: gradle/wrapper-validation-action@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build project and install Distribution package
|
||||
uses: gradle/gradle-build-action@v3.1.0
|
||||
uses: gradle/gradle-build-action@v2.11.0
|
||||
with:
|
||||
gradle-version: 'wrapper'
|
||||
arguments: installDist
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM eclipse-temurin:21-jdk-alpine
|
||||
FROM openjdk:18
|
||||
|
||||
ENV BOT_DATA_PATH /scalabot/data/
|
||||
WORKDIR /scalabot/run/
|
||||
|
@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
allprojects {
|
||||
@ -13,5 +13,5 @@ allprojects {
|
||||
|
||||
}
|
||||
group = "net.lamgc"
|
||||
version = "0.7.0"
|
||||
}
|
||||
version = "0.6.1"
|
||||
}
|
@ -10,9 +10,9 @@ dependencies {
|
||||
implementation(project(":scalabot-meta"))
|
||||
implementation(project(":scalabot-extension"))
|
||||
|
||||
implementation("org.slf4j:slf4j-api:2.0.11")
|
||||
implementation("org.slf4j:slf4j-api:2.0.9")
|
||||
implementation("io.github.microutils:kotlin-logging:3.0.5")
|
||||
implementation("ch.qos.logback:logback-classic:1.4.14")
|
||||
implementation("ch.qos.logback:logback-classic:1.4.11")
|
||||
|
||||
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.23")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.21")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
|
||||
implementation("org.jdom:jdom2:2.0.6.1")
|
||||
|
||||
implementation("org.telegram:telegrambots-abilities:6.9.7.1")
|
||||
implementation("org.telegram:telegrambots:6.9.7.1")
|
||||
implementation("org.telegram:telegrambots-abilities:6.8.0")
|
||||
implementation("org.telegram:telegrambots:6.8.0")
|
||||
|
||||
implementation("io.prometheus:simpleclient:0.16.0")
|
||||
implementation("io.prometheus:simpleclient_httpserver:0.16.0")
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation("io.mockk:mockk:1.13.9")
|
||||
testImplementation("io.mockk:mockk:1.13.8")
|
||||
testImplementation("com.github.stefanbirkner:system-lambda:1.2.1")
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,6 @@ 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
|
||||
@ -137,11 +135,7 @@ internal class Launcher(
|
||||
launchBot(botConfig)
|
||||
launchedCounts++
|
||||
} catch (e: Exception) {
|
||||
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}` 启动时发生错误." }
|
||||
}
|
||||
log.error(e) { "机器人 `${botConfig.account.name}` 启动时发生错误." }
|
||||
}
|
||||
}
|
||||
return if (launchedCounts != 0) {
|
||||
@ -207,10 +201,6 @@ 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}` 已启动." }
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
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
|
||||
@ -123,12 +122,7 @@ internal class ExtensionLoader(
|
||||
for (factory in extClassLoader.serviceLoader) {
|
||||
try {
|
||||
val extension =
|
||||
factory.createExtensionInstance(
|
||||
bot, getExtensionDataFolder(extensionArtifact),
|
||||
BotExtensionCreateOptions(
|
||||
bot.botConfig.proxy.copy()
|
||||
)
|
||||
)
|
||||
factory.createExtensionInstance(bot, getExtensionDataFolder(extensionArtifact))
|
||||
if (extension == null) {
|
||||
log.debug { "Factory ${factory::class.java} 创建插件时返回了 null, 已跳过. (BotName: ${bot.botUsername})" }
|
||||
continue
|
||||
|
@ -29,7 +29,7 @@ internal class ScalaBot(
|
||||
db: DBContext,
|
||||
options: DefaultBotOptions,
|
||||
extensionFinders: Set<ExtensionPackageFinder>,
|
||||
val botConfig: BotConfig,
|
||||
botConfig: BotConfig,
|
||||
private val creatorId: Long = botConfig.account.creatorId,
|
||||
val accountId: Long = botConfig.account.id,
|
||||
val extensions: Set<Artifact> = botConfig.extensions
|
||||
|
@ -5,7 +5,7 @@ plugins {
|
||||
dependencies {
|
||||
compileOnly(project(":scalabot-extension"))
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
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;
|
||||
@ -10,7 +9,7 @@ import java.io.File;
|
||||
public class SimpleExtensionFactory implements BotExtensionFactory {
|
||||
|
||||
@Override
|
||||
public AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder, BotExtensionCreateOptions options) {
|
||||
public AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder) {
|
||||
return new SayHelloExtension(bot);
|
||||
}
|
||||
|
||||
|
@ -7,12 +7,11 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("commons-codec:commons-codec:1.16.1")
|
||||
api("org.telegram:telegrambots-abilities:6.9.7.1")
|
||||
api(project(":scalabot-meta"))
|
||||
implementation("commons-codec:commons-codec:1.16.0")
|
||||
api("org.telegram:telegrambots-abilities:6.8.0")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
|
||||
testImplementation("org.mockito:mockito-core:5.11.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||
testImplementation("org.mockito:mockito-core:5.8.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
}
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -31,34 +31,7 @@ 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
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
AbilityExtension createExtensionInstance(BaseAbilityBot bot, File shareDataFolder);
|
||||
|
||||
}
|
||||
|
@ -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.9.7.1")
|
||||
implementation("org.telegram:telegrambots-meta:6.8.0")
|
||||
|
||||
api("com.google.code.gson:gson:2.10.1")
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation("io.mockk:mockk:1.13.9")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
|
||||
testImplementation("io.mockk:mockk:1.13.8")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
|
||||
|
||||
dokkaHtmlPlugin("org.jetbrains.dokka:javadoc-plugin:1.9.10")
|
||||
|
Reference in New Issue
Block a user