sendChatroomRobotMessage method
- {required String roomId,
- required String robotAccount,
- required NIMRobotMessageType type,
- String? text,
- String? content,
- String? target,
- String? params,
- bool resend = false,
- 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;
}
});
}