sendChatroomRobotMessage method

Future<NIMResult<NIMChatroomMessage>> sendChatroomRobotMessage({
  1. required String roomId,
  2. required String robotAccount,
  3. required NIMRobotMessageType type,
  4. String? text,
  5. String? content,
  6. String? target,
  7. String? params,
  8. bool resend = false,
  9. ChatroomMessageAction? action,
})

创建机器人消息

Implementation

Future<NIMResult<NIMChatroomMessage>> sendChatroomRobotMessage({
  required String roomId,
  required String robotAccount,
  required NIMRobotMessageType type,
  String? text,
  String? content,
  String? target,
  String? params,
  bool resend = false,
  ChatroomMessageAction? action,
}) async {
  return _createMessage({
    'roomId': roomId,
    'robotAccount': robotAccount,
    'robotMessageType': _robotMessageTypeMap[type],
    'text': text,
    'content': content,
    'target': target,
    'params': params,
    'messageType': 'robot',
  }).then((messageResult) async {
    if (messageResult.isSuccess) {
      final message = messageResult.data as NIMChatroomMessage;
      await action?.call(message);
      return sendChatroomMessage(message, resend);
    } else {
      return messageResult;
    }
  });
}