Appearance
消息构建
Bngeuit 静态方法覆盖了绝大多数常用消息发送场景。复杂场景通过 Bngeuit.api() 获取原始 BotApi 使用。
msgSeq 参数
所有发送方法都要求传入 msgSeq(消息序号),用于去重/排序。
Bngeuit 静态方法
群聊文本
java
Bngeuit.sendGroupText(groupOpenid, msgSeq, "你好"); // 主动发送
Bngeuit.sendGroupText(groupOpenid, msgSeq, "你好", keyboard); // 带键盘
Bngeuit.replyGroupText(groupOpenid, msgId, msgSeq, "回复"); // 被动回复
Bngeuit.quoteGroupText(groupOpenid, refIdx, msgSeq, "引用回复"); // 引用回复群聊 Markdown
java
Bngeuit.sendGroupMarkdown(groupOpenid, msgSeq, "**加粗**"); // 发送
Bngeuit.sendGroupMarkdown(groupOpenid, msgSeq, "**加粗**", keyboard);// 带键盘
Bngeuit.replyGroupMarkdown(groupOpenid, msgId, msgSeq, "**回复**");
Bngeuit.quoteGroupMarkdown(groupOpenid, refIdx, msgSeq, "**引用**");群聊富媒体(ByUrl 公网 URL / ByFile 本地文件)
java
Bngeuit.sendGroupImageByUrl(groupOpenid, msgSeq, "https://.../img.png");
Bngeuit.sendGroupImageByFile(groupOpenid, msgSeq, new File("img.png")); // 本地自动分片上传
Bngeuit.sendGroupVideoByUrl(groupOpenid, msgSeq, url);
Bngeuit.sendGroupVideoByFile(groupOpenid, msgSeq, new File("video.mp4"));
Bngeuit.sendGroupVoiceByUrl(groupOpenid, msgSeq, url);
Bngeuit.sendGroupVoiceByFile(groupOpenid, msgSeq, new File("voice.silk"));
Bngeuit.sendGroupFileByUrl(groupOpenid, msgSeq, url);
Bngeuit.sendGroupFileByFile(groupOpenid, msgSeq, new File("file.rar"));群聊卡片
java
Bngeuit.sendGroupCard(groupOpenid, msgSeq, "标题", "描述", "https://img.png", "https://link");
// 跳转 URL 需要 QQ 白名单域名,传 null 可展示不可点击私聊文本
java
Bngeuit.sendC2CText(openid, msgSeq, "你好"); // 主动发送
Bngeuit.sendC2CText(openid, msgSeq, "你好", keyboard); // 带键盘
Bngeuit.replyC2CText(openid, msgId, msgSeq, "回复");
Bngeuit.quoteC2CText(openid, refIdx, msgSeq, "引用回复");私聊 Markdown
java
Bngeuit.sendC2CMarkdown(openid, msgSeq, "**加粗**");
Bngeuit.sendC2CMarkdown(openid, msgSeq, "**加粗**", keyboard);
Bngeuit.replyC2CMarkdown(openid, msgId, msgSeq, "**回复**");
Bngeuit.quoteC2CMarkdown(openid, refIdx, msgSeq, "**引用**");私聊富媒体
java
Bngeuit.sendC2CImageByUrl(openid, msgSeq, "https://.../img.png");
Bngeuit.sendC2CImageByFile(openid, msgSeq, new File("img.png"));
Bngeuit.sendC2CVideoByUrl(openid, msgSeq, url);
Bngeuit.sendC2CVideoByFile(openid, msgSeq, new File("video.mp4"));
Bngeuit.sendC2CVoiceByUrl(openid, msgSeq, url);
Bngeuit.sendC2CVoiceByFile(openid, msgSeq, new File("voice.silk"));
Bngeuit.sendC2CFileByUrl(openid, msgSeq, url);
Bngeuit.sendC2CFileByFile(openid, msgSeq, new File("file.rar"));其他
java
Bngeuit.sendC2CTyping(openid, 5); // "正在输入..."
Bngeuit.deleteGroupMessage(groupOpenid, messageId); // 撤回群消息
Bngeuit.deleteC2CMessage(openid, messageId); // 撤回私聊消息
Bngeuit.respondInteraction(interactionId, BotApi.InteractionResponseCode.SUCCESS); // 互动响应高级场景:使用 BotApi
上传、流式消息等多步操作,通过 Bngeuit.api() 获取原始 API:
java
import cn.org.bukkit.bngeuit.Bngeuit;
import cn.org.bukkit.bngeuit.core.BotApi;
import cn.org.bukkit.bngeuit.dto.message.*;
BotApi api = Bngeuit.api();
// 上传富媒体(URL 方式)
UploadResponse r = api.uploadGroupFile(
groupOpenid, FileType.IMAGE, "https://example.com/img.jpg", false);
// 上传本地文件(分片方式,返回 UploadResponse)
UploadResponse r2 = api.uploadGroupFileByFile(
groupOpenid, FileType.IMAGE, new File("img.png"));
// 手动构建请求发送
api.sendGroupMessage(GroupMessageRequest.builder()
.groupOpenid(groupOpenid)
.msgType(MsgType.MEDIA)
.media(new MediaInfo(r.fileInfo()))
.msgSeq(1)
.build());消息类型
MsgType 枚举:
| 枚举 | 数值 | 说明 |
|---|---|---|
TEXT | 0 | 普通文本 |
MARKDOWN | 2 | Markdown |
INPUT_NOTIFY | 6 | 输入中状态(仅私聊) |
MEDIA | 7 | 富媒体(图片/视频/语音/文件) |
CARD | 8 | 图文卡片(仅群聊) |
其他枚举类型
CardType
图文卡片类型,用于 Card.type:
| 枚举 | JSON 值 | 说明 |
|---|---|---|
TUWEN | "tuwen" | 图文卡片 |
InputMode
流式消息输入模式,用于 StreamMessageRequest.inputMode:
| 枚举 | JSON 值 | 说明 |
|---|---|---|
APPEND | "append" | 追加模式 |
REPLACE | "replace" | 替换模式 |
StreamContentType
流式消息内容类型,用于 StreamMessageRequest.contentType:
| 枚举 | JSON 值 | 说明 |
|---|---|---|
TEXT | "text" | 纯文本 |
MARKDOWN | "markdown" | Markdown |
