Impl sendText

This commit is contained in:
Changhua 2023-03-21 21:32:52 +08:00
parent 7ed08d6e26
commit 00e0a71bb1

View File

@ -115,19 +115,23 @@ public class Client {
return tables;
}
/**
* @Description 发送文本消息
* @param msg: 消息内容如果是 @ 消息则需要有跟 @ 的人数量相同的 @
* @param receiver: 消息接收人私聊为 wxidwxid_xxxxxxxxxxxxxx群聊为 roomidxxxxxxxxxx@chatroom
* @param aters: 群聊时要 @ 的人私聊时为空字符串多个用逗号分隔@所有人 notify@all必须是群主或者管理员才有权限
* @return int
* @author Changhua
* @example sendText("Hello @某人1 @某人2", "xxxxxxxx@chatroom", "wxid_xxxxxxxxxxxxx1,wxid_xxxxxxxxxxxxx2");
**/
/**
* @Description 发送文本消息
* @param msg: 消息内容如果是 @ 消息则需要有跟 @ 的人数量相同的 @
* @param receiver: 消息接收人私聊为 wxidwxid_xxxxxxxxxxxxxx群聊为
* roomidxxxxxxxxxx@chatroom
* @param aters: 群聊时要 @ 的人私聊时为空字符串多个用逗号分隔@所有人
* notify@all必须是群主或者管理员才有权限
* @return int
* @author Changhua
* @example sendText("Hello @某人1 @某人2", "xxxxxxxx@chatroom",
* "wxid_xxxxxxxxxxxxx1,wxid_xxxxxxxxxxxxx2");
**/
public int sendText(String msg, String receiver, String aters) {
Wcf.TextMsg textMsg = Wcf.TextMsg.newBuilder().setMsg(msg).setReceiver(receiver).setAters(aters).build();
Request req = new Request.Builder().setFuncValue(Functions.FUNC_SEND_TXT_VALUE).setTxt(textMsg).build();
logger.debug(bytesToHex(req.toByteArray()));
logger.debug("{}", bytesToHex(req.toByteArray()));
Response rsp = sendCmd(req);
int ret = -1;
if (rsp != null) {