Skip to content

Commit

Permalink
support get group file url
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Dec 11, 2023
1 parent 3028c30 commit 022b945
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ public enum ActionPathEnum implements ActionPath {
* 删除群文件夹
*/
DELETE_GROUP_FOLDER("delete_group_folder"),
/**
* 获取群文件下载链接
*/
GET_GROUP_FILE_URL("get_group_file_url"),

;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cn.evole.onebot.sdk.response.group;

import lombok.Data;

/**
* @author MrXiaoM
*/
@Data
public class GroupFileUrlResp {

public String url;

}
21 changes: 21 additions & 0 deletions onebot/src/main/kotlin/cn/evolvefield/onebot/client/core/Bot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,27 @@ class Bot(
object : TypeToken<ActionData<GroupFilesResp>>() {}.type
)
}
/**
* 获取群文件下载链接
*
* @param groupId 群号
* @param fileId 文件ID
* @param busid 此参数可在群文件相关接口中获取
* @return [ActionData] of [GroupFileUrlResp]
*/
@JvmBlockingBridge
suspend fun getGroupFileUrl(groupId: Long, fileId: String, busid: Int): ActionData<GroupFileUrlResp> {
val action = ActionPathEnum.GET_GROUP_FILE_URL
val params = JsonObject()
params.addProperty("group_id", groupId)
params.addProperty("file_id", fileId)
params.addProperty("busid", busid)
val result = actionHandler.action(channel, action, params)
return GsonUtil.fromJson(
result.toString(),
object : TypeToken<ActionData<GroupFileUrlResp>>() {}.type
)
}

/**
* 自定义请求 ActionData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class FileWrapper(
}

override suspend fun getUrl(): String? {
TODO("Not yet implemented")
return contact.botWrapper.impl.getGroupFileUrl(contact.id, id, busid).data?.url
}

override suspend fun moveTo(folder: AbsoluteFolder): Boolean {
Expand Down

0 comments on commit 022b945

Please sign in to comment.