Skip to content

Commit

Permalink
🎨 Replace forward msg args
Browse files Browse the repository at this point in the history
  • Loading branch information
MisakaTAT committed Dec 15, 2021
1 parent d37b001 commit 4310dbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions src/main/java/com/mikuac/shiro/common/utils/ShiroUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.mikuac.shiro.enums.ShiroUtilsEnum;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;

/**
* Created on 2021/8/10.
Expand Down Expand Up @@ -185,12 +183,12 @@ public static List<MsgChainBean> stringToMsgChain(String msg) {
* https://docs.go-cqhttp.org/cqcode/#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91
* @return 转发消息
*/
public static JSONArray generateForwardMsg(long uin, String name, ArrayList<String> msgList) {
JSONArray nodeList = new JSONArray();
public static List<Object> generateForwardMsg(long uin, String name, ArrayList<String> msgList) {
List<Object> nodeList = new ArrayList<>();
for (String msg : msgList) {
JSONObject node = new JSONObject();
Map<String, Object> node = new HashMap<>(5);
node.put("type", "node");
JSONObject data = new JSONObject();
Map<String, Object> data = new HashMap<>(5);
data.put("name", name);
data.put("uin", uin);
data.put("content", msg);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/mikuac/shiro/core/Bot.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mikuac.shiro.core;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mikuac.shiro.bean.HandlerMethod;
Expand Down Expand Up @@ -685,10 +684,11 @@ public ActionData<DownloadFileResp> downloadFile(String url) {
* 发送合并转发 (群)
*
* @param groupId 群号
* @param msg 自定义转发消息, 具体看 https://docs.go-cqhttp.org/cqcode/#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91
* @param msg 自定义转发消息 (可使用 ShiroUtils.generateForwardMsg() 方法创建)
* 自定义构建详见 https://docs.go-cqhttp.org/cqcode/#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91
* @return {@link ActionRaw}
*/
public ActionRaw sendGroupForwardMsg(long groupId, JSONArray msg) {
public ActionRaw sendGroupForwardMsg(long groupId, List<Object> msg) {
ActionPathEnum action = ActionPathEnum.SEND_GROUP_FORWARD_MSG;
JSONObject params = new JSONObject();
params.put("group_id", groupId);
Expand Down

0 comments on commit 4310dbc

Please sign in to comment.