机器人sdk添加撤回和更新接口
This commit is contained in:
@@ -982,7 +982,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputUserChatroom> userChatroomIMResult = ChatroomAdmin.getUserChatroom("hygqmws2k");
|
||||
IMResult<OutputUserChatroom> userChatroomIMResult = ChatroomAdmin.getUserChatroom("uygqmws2k");
|
||||
if(userChatroomIMResult != null && (userChatroomIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS || userChatroomIMResult.getErrorCode() == ErrorCode.ERROR_CODE_NOT_EXIST)) {
|
||||
System.out.println("get user chatroom success");
|
||||
} else {
|
||||
@@ -1181,7 +1181,7 @@ public class Main {
|
||||
payload.setType(1);
|
||||
payload.setSearchableContent("hello world");
|
||||
|
||||
IMResult<SendMessageResult> resultRobotSendMessage = robotService.sendMessage("robot1", conversation, payload);
|
||||
IMResult<SendMessageResult> resultRobotSendMessage = robotService.sendMessage(robotService.getRobotId(), conversation, payload);
|
||||
if (resultRobotSendMessage != null && resultRobotSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot send message success");
|
||||
} else {
|
||||
@@ -1189,6 +1189,37 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
if(commercialServer) {
|
||||
Thread.sleep(1000);
|
||||
IMResult<String> recallMessageResult = robotService.recallMessage(resultRobotSendMessage.result.getMessageUid());
|
||||
if (recallMessageResult != null && recallMessageResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot recall message success");
|
||||
} else {
|
||||
System.out.println("robot recall message failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
payload.setSearchableContent("hello world, hello world");
|
||||
resultRobotSendMessage = robotService.sendMessage(robotService.getRobotId(), conversation, payload);
|
||||
if (resultRobotSendMessage != null && resultRobotSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot send message success");
|
||||
} else {
|
||||
System.out.println("robot send message failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
payload.setSearchableContent("hello world, updated message content");
|
||||
IMResult<Void> updateMessageResult = robotService.updateMessage(resultRobotSendMessage.result.getMessageUid(), payload);
|
||||
if (updateMessageResult != null && updateMessageResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot update message success");
|
||||
} else {
|
||||
System.out.println("robot update message failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IMResult<InputOutputUserInfo> resultRobotGetUserInfo = robotService.getUserInfo("userId1");
|
||||
if (resultRobotGetUserInfo != null && resultRobotGetUserInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot get user info success");
|
||||
|
||||
@@ -17,6 +17,10 @@ public class RobotService {
|
||||
robotHttpUtils = new RobotHttpUtils(url, robotId, robotSecret);
|
||||
}
|
||||
|
||||
public String getRobotId() {
|
||||
return robotHttpUtils.getRobotId();
|
||||
}
|
||||
|
||||
public IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload) throws Exception {
|
||||
String path = APIPath.Robot_Message_Send;
|
||||
SendMessageData messageData = new SendMessageData();
|
||||
@@ -26,6 +30,23 @@ public class RobotService {
|
||||
return robotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||
}
|
||||
|
||||
public IMResult<String> recallMessage(long messageUid) throws Exception {
|
||||
String path = APIPath.Robot_Message_Recall;
|
||||
RecallMessageData messageData = new RecallMessageData();
|
||||
messageData.setMessageUid(messageUid);
|
||||
return robotHttpUtils.httpJsonPost(path, messageData, String.class);
|
||||
}
|
||||
|
||||
public IMResult<Void> updateMessage(long messageUid, MessagePayload payload) throws Exception {
|
||||
String path = APIPath.Robot_Message_Update;
|
||||
UpdateMessageContentData updateMessageContentData = new UpdateMessageContentData();
|
||||
updateMessageContentData.setMessageUid(messageUid);
|
||||
updateMessageContentData.setPayload(payload);
|
||||
updateMessageContentData.setUpdateTimestamp(0);
|
||||
updateMessageContentData.setDistribute(1);
|
||||
return robotHttpUtils.httpJsonPost(path, updateMessageContentData, Void.class);
|
||||
}
|
||||
|
||||
public IMResult<InputOutputUserInfo> getUserInfo(String userId) throws Exception {
|
||||
String path = APIPath.Robot_User_Info;
|
||||
InputGetUserInfo getUserInfo = new InputGetUserInfo(userId, null, null);
|
||||
|
||||
Reference in New Issue
Block a user