Package com.mikuac.shiro.common.utils
Class MsgUtils
java.lang.Object
com.mikuac.shiro.common.utils.MsgUtils
Created on 2021/7/8.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionat(long userId) at 某人atAll()at 全体成员build()构建消息链static MsgUtilsbuilder()消息构建一种 xml 的图片消息 xml 接口的消息都存在风控风险, 请自行兼容发送失败后的处理 ( 可以失败后走普通图片模式 )cardImage(String file, long minWidth, long minHeight, long maxWidth, long maxHeight, String source, String icon) 一种 xml 的图片消息 xml 接口的消息都存在风控风险, 请自行兼容发送失败后的处理 ( 可以失败后走普通图片模式 )face(int id) QQ 表情 对照表闪照发送合并转发消息gift(long userId, int giftId) 礼物 仅支持免费礼物, 发送群礼物消息 无法撤回, 返回的 message id 恒定为 0img(byte[] image) 图片img(OneBotMedia media) 图片图片 支持本地图片、网络图片、Base64 详见 消息构建工具JSON 消息JSON 消息发送长消息音乐分享音乐分享poke(long userId) 戳一戳reply(int msgId) 回复回复-频道rps(int value) 发送猜拳消息文本内容文本转语音 通过腾讯的 TTS 接口, 采用的音源与登录账号的性别有关短视频voice(OneBotMedia media) 语音语音XML 消息XML 消息
-
Constructor Details
-
MsgUtils
public MsgUtils()
-
-
Method Details
-
builder
消息构建- Returns:
MsgUtils
-
text
文本内容- Parameters:
text- 内容- Returns:
MsgUtils
-
img
图片 支持本地图片、网络图片、Base64 详见 消息构建工具- Parameters:
img- 图片- Returns:
MsgUtils
-
img
图片- Parameters:
media-OneBotMedia- Returns:
MsgUtils
-
img
图片- Parameters:
image- 图片字节数组- Returns:
MsgUtils
-
video
短视频- Parameters:
video- 视频地址, 支持 http 和 file 发送cover- 视频封面, 支持 http, file 和 base64 发送, 格式必须为 jpg- Returns:
MsgUtils
-
flashImg
闪照- Parameters:
img- 图片- Returns:
MsgUtils
-
face
QQ 表情 对照表- Parameters:
id- QQ 表情 ID- Returns:
MsgUtils
-
voice
语音- Parameters:
media-OneBotMedia- Returns:
MsgUtils
-
voice
语音- Parameters:
voice- 语音, 支持本地文件和 URL- Returns:
MsgUtils
-
at
at 某人- Parameters:
userId- at 的 QQ 号, all 表示全体成员- Returns:
MsgUtils
-
atAll
at 全体成员- Returns:
MsgUtils
-
poke
戳一戳- Parameters:
userId- 需要戳的成员- Returns:
MsgUtils
-
reply
回复- Parameters:
msgId- 回复时所引用的消息 id, 必须为本群消息.- Returns:
MsgUtils
-
reply
回复-频道- Parameters:
msgId- 回复时所引用的消息 id, 必须为本频道消息.- Returns:
MsgUtils
-
gift
礼物 仅支持免费礼物, 发送群礼物消息 无法撤回, 返回的 message id 恒定为 0- Parameters:
userId- 接收礼物的成员giftId- 礼物的类型- Returns:
MsgUtils
-
tts
文本转语音 通过腾讯的 TTS 接口, 采用的音源与登录账号的性别有关- Parameters:
text- 内容- Returns:
MsgUtils
-
xml
XML 消息- Parameters:
data- xml内容, xml 中的 value 部分, 记得实体化处理- Returns:
MsgUtils
-
xml
XML 消息- Parameters:
data- xml 内容, xml 中的 value部分, 记得实体化处理resId- 可以不填- Returns:
MsgUtils
-
json
JSON 消息- Parameters:
data- json 内容, json 的所有字符串记得实体化处理- Returns:
MsgUtils
-
json
JSON 消息- Parameters:
data- json 内容, json 的所有字符串记得实体化处理resId- 默认不填为 0, 走小程序通道, 填了走富文本通道发送- Returns:
MsgUtils
-
cardImage
一种 xml 的图片消息 xml 接口的消息都存在风控风险, 请自行兼容发送失败后的处理 ( 可以失败后走普通图片模式 )- Parameters:
file- 和 image 的 file 字段对齐, 支持也是一样的- Returns:
MsgUtils
-
cardImage
public MsgUtils cardImage(String file, long minWidth, long minHeight, long maxWidth, long maxHeight, String source, String icon) 一种 xml 的图片消息 xml 接口的消息都存在风控风险, 请自行兼容发送失败后的处理 ( 可以失败后走普通图片模式 )- Parameters:
file- 和 image 的 file 字段对齐, 支持也是一样的minWidth- 默认不填为 400, 最小 widthminHeight- 默认不填为 400, 最小 heightmaxWidth- 默认不填为 500, 最大 widthmaxHeight- 默认不填为 1000, 最大 heightsource- 分享来源的名称, 可以留空icon- 分享来源的 icon 图标 url, 可以留空- Returns:
MsgUtils
-
music
音乐分享- Parameters:
type- qq 163 xm (分别表示使用 QQ 音乐、网易云音乐、虾米音乐)id- 歌曲 ID- Returns:
MsgUtils
-
music
音乐分享- Parameters:
type- 音乐类型params- 包含音乐信息的键值对(如title, url, image, singer, audio等)- Returns:
MsgUtils
-
rps
发送猜拳消息- Parameters:
value- 0石头 1剪刀 2布- Returns:
MsgUtils
-
longMsg
发送长消息- Parameters:
id- 长消息Id- Returns:
MsgUtils
-
forward
发送合并转发消息- Parameters:
id- 合并转发消息Id- Returns:
MsgUtils
-
build
构建消息链- Returns:
String
-