|
2 | 2 |
|
3 | 3 | import com.alibaba.fastjson.JSON;
|
4 | 4 | import com.alibaba.fastjson.JSONObject;
|
| 5 | +import io.github.kloping.judge.Judge; |
5 | 6 | import io.github.kloping.qqbot.api.SendAble;
|
6 | 7 | import io.github.kloping.qqbot.api.SenderV2;
|
7 | 8 | import io.github.kloping.qqbot.entities.ex.Image;
|
|
15 | 16 | import lombok.Getter;
|
16 | 17 | import lombok.experimental.Accessors;
|
17 | 18 |
|
| 19 | +import java.util.Base64; |
| 20 | + |
18 | 21 | import static io.github.kloping.qqbot.entities.qqpd.Channel.SEND_MESSAGE_HEADERS;
|
19 | 22 |
|
20 | 23 | /**
|
@@ -42,8 +45,13 @@ public Result<V2Result> send(String text, RawMessage message) {
|
42 | 45 | }
|
43 | 46 |
|
44 | 47 | private V2Result sendImage(Image msg) {
|
45 |
| - if (RawMessage.imagePrepare(msg, bot)) return null; |
46 |
| - V2Result result = bot.groupBaseV2.sendFile(getOpenid(), String.format("{\"file_type\": %s,\"url\": \"%s\",\"srv_send_msg\": false}", msg.getFile_type(), msg.getUrl()), Channel.SEND_MESSAGE_HEADERS); |
| 48 | + RawMessage.imagePrepare(msg, bot); |
| 49 | + V2Result result = null; |
| 50 | + if (Judge.isNotEmpty(msg.getUrl())) { |
| 51 | + result = bot.groupBaseV2.sendFile(getOpenid(), String.format("{\"file_type\": %s,\"url\": \"%s\",\"srv_send_msg\": false}", msg.getFile_type(), msg.getUrl()), Channel.SEND_MESSAGE_HEADERS); |
| 52 | + } else { |
| 53 | + result = bot.groupBaseV2.sendFile(getCid(), String.format("{\"file_type\": %s,\"file_data\": \"%s\",\"srv_send_msg\": false}", msg.getFile_type(), Base64.getEncoder().encodeToString(msg.getBytes())), Channel.SEND_MESSAGE_HEADERS); |
| 54 | + } |
47 | 55 | result.logFileInfo(bot.logger, msg);
|
48 | 56 | V2MsgData data = new V2MsgData();
|
49 | 57 | data.setMedia(new V2MsgData.Media(result.getFile_info()));
|
|
0 commit comments