
- 添加 FileList 和 SingleFile 数据模型用于解析 JSON 响应 - 集成 AlistService 获取文件列表和文件信息 - 使用 OkHttpClient 下载图片 - 更新 application.yml 配置,添加 AList 相关设置 - 修改 ExampleService 中的 entrance 方法返回值
48 lines
1.3 KiB
Kotlin
48 lines
1.3 KiB
Kotlin
package info.alinadace.sakuramiki.service
|
|
|
|
import info.alinadace.sakuramiki.annotation.BotFunction
|
|
import info.alinadace.sakuramiki.configuration.BotConfig
|
|
import io.github.kloping.qqbot.api.v2.FriendMessageEvent
|
|
import io.github.kloping.qqbot.api.v2.GroupMessageEvent
|
|
import io.github.kloping.qqbot.api.v2.MessageV2Event
|
|
import io.github.kloping.qqbot.entities.ex.PlainText
|
|
import jakarta.annotation.Resource
|
|
import org.slf4j.Logger
|
|
import org.slf4j.LoggerFactory
|
|
|
|
/**
|
|
* @author Kane
|
|
* @since 2024/8/29 下午3:47
|
|
*/
|
|
@BotFunction(FriendMessageEvent::class, GroupMessageEvent::class)
|
|
class ExampleService : Service<MessageV2Event> {
|
|
|
|
companion object {
|
|
val log: Logger = LoggerFactory.getLogger(this::class.java)
|
|
}
|
|
|
|
@Resource
|
|
lateinit var botConfig: BotConfig
|
|
|
|
/**
|
|
* 服务入口
|
|
*/
|
|
override fun entrance(event: MessageV2Event): Boolean {
|
|
val chain = event.message
|
|
if (chain.size == 1 && chain[0] is PlainText && event.sender.id == botConfig.admin) {
|
|
if (chain[0].toString() == "测试") {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
/**
|
|
* 服务行为
|
|
*/
|
|
override fun active(event: MessageV2Event) {
|
|
log.info("ExampleService: sender:{}", event.sender.id)
|
|
event.send("测试成功")
|
|
}
|
|
}
|