mirror of
https://github.com/jie65535/mirai-console-jcf-plugin.git
synced 2025-12-15 19:07:54 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d95b54182b | ||
|
|
a7d1370c39 | ||
|
|
05a50b3b44 |
@@ -10,6 +10,7 @@
|
|||||||
支持查看文件列表与其下载地址,单独查看文件的更新日志。
|
支持查看文件列表与其下载地址,单独查看文件的更新日志。
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
- /jcf id <projectId> # 根据id查找
|
||||||
- /jcf help # 帮助
|
- /jcf help # 帮助
|
||||||
- /jcf ss \<filter\> # 直接搜索
|
- /jcf ss \<filter\> # 直接搜索
|
||||||
- /jcf sspack \<filter\> # 搜索整合包
|
- /jcf sspack \<filter\> # 搜索整合包
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
- [x] 搜索整合包
|
- [x] 搜索整合包
|
||||||
- [x] 搜索资源包
|
- [x] 搜索资源包
|
||||||
- [x] ~~搜索存档~~
|
- [x] ~~搜索存档~~
|
||||||
|
- [x] 根据项目ID搜索
|
||||||
---
|
---
|
||||||
- [x] 分页选择
|
- [x] 分页选择
|
||||||
- [ ] 获取介绍
|
- [ ] 获取介绍
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "me.jie65535"
|
group = "me.jie65535"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://maven.aliyun.com/repository/public")
|
maven("https://maven.aliyun.com/repository/public")
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ object JCurseforge : KotlinPlugin(
|
|||||||
JvmPluginDescription(
|
JvmPluginDescription(
|
||||||
id = "me.jie65535.jcf",
|
id = "me.jie65535.jcf",
|
||||||
name = "J Curseforge Util",
|
name = "J Curseforge Util",
|
||||||
version = "0.1.0",
|
version = "0.1.1",
|
||||||
) {
|
) {
|
||||||
author("jie65535")
|
author("jie65535")
|
||||||
info("""
|
info("""
|
||||||
|
|||||||
@@ -50,4 +50,9 @@ object JcfCommand : CompositeCommand(
|
|||||||
// MinecraftService.search(this, MinecraftService.SECTION_ID_WORLDS, filter)
|
// MinecraftService.search(this, MinecraftService.SECTION_ID_WORLDS, filter)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@SubCommand("id")
|
||||||
|
@Description("根据id查找")
|
||||||
|
suspend fun UserCommandSender.getAddonById(projectId: Int) {
|
||||||
|
MinecraftService.searchAddonByProjectId(this, projectId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package me.jie65535.jcf
|
package me.jie65535.jcf
|
||||||
|
|
||||||
|
import io.ktor.client.features.*
|
||||||
|
import io.ktor.http.*
|
||||||
import kotlinx.coroutines.TimeoutCancellationException
|
import kotlinx.coroutines.TimeoutCancellationException
|
||||||
import me.jie65535.jcf.model.addon.Addon
|
import me.jie65535.jcf.model.addon.Addon
|
||||||
import me.jie65535.jcf.model.addon.AddonSortMethod
|
import me.jie65535.jcf.model.addon.AddonSortMethod
|
||||||
@@ -77,6 +79,27 @@ object MinecraftService {
|
|||||||
showAddon(sender, addon)
|
showAddon(sender, addon)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据项目ID搜索资源
|
||||||
|
*/
|
||||||
|
suspend fun searchAddonByProjectId(sender: UserCommandSender, projectId: Int) {
|
||||||
|
try {
|
||||||
|
val addon = curseClient.getAddon(projectId)
|
||||||
|
|
||||||
|
showAddon(sender, addon)
|
||||||
|
} catch (e: ClientRequestException) {
|
||||||
|
if (e.response.status == HttpStatusCode.NotFound) {
|
||||||
|
sender.sendMessage("未搜索到指定项目ID的资源,请使用正确的项目ID")
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("请求异常,错误代码:" + e.response.status)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
sender.sendMessage("内部发生异常,此次查询已取消,请重新查询。")
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun showAddon(sender: UserCommandSender, addon: Addon) {
|
private suspend fun showAddon(sender: UserCommandSender, addon: Addon) {
|
||||||
val builder = MessageHandler.parseAddon(addon, sender.subject)
|
val builder = MessageHandler.parseAddon(addon, sender.subject)
|
||||||
if (addon.latestFiles.isNotEmpty())
|
if (addon.latestFiles.isNotEmpty())
|
||||||
@@ -148,7 +171,7 @@ object MinecraftService {
|
|||||||
sort = AddonSortMethod.POPULARITY,
|
sort = AddonSortMethod.POPULARITY,
|
||||||
sortDescending = true,
|
sortDescending = true,
|
||||||
gameVersion = null,
|
gameVersion = null,
|
||||||
index = pageIndex,
|
index = pageIndex * pageSize,
|
||||||
pageSize = pageSize,
|
pageSize = pageSize,
|
||||||
searchFilter = filter,
|
searchFilter = filter,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user