sendTextEvent method

Future<String?> sendTextEvent(
  1. String message, {
  2. String? txid,
  3. Event? inReplyTo,
  4. String? editEventId,
  5. bool parseMarkdown = true,
  6. bool parseCommands = true,
  7. String msgtype = MessageTypes.Text,
  8. String? threadRootEventId,
  9. String? threadLastEventId,
})

Sends a normal text message to this room. Returns the event ID generated by the server for this message.

Implementation

Future<String?> sendTextEvent(String message,
    {String? txid,
    Event? inReplyTo,
    String? editEventId,
    bool parseMarkdown = true,
    bool parseCommands = true,
    String msgtype = MessageTypes.Text,
    String? threadRootEventId,
    String? threadLastEventId}) {
  if (parseCommands) {
    return client.parseAndRunCommand(this, message,
        inReplyTo: inReplyTo,
        editEventId: editEventId,
        txid: txid,
        threadRootEventId: threadRootEventId,
        threadLastEventId: threadLastEventId);
  }
  final event = <String, dynamic>{
    'msgtype': msgtype,
    'body': message,
  };
  if (parseMarkdown) {
    final html = markdown(event['body'],
        getEmotePacks: () => getImagePacksFlat(ImagePackUsage.emoticon),
        getMention: getMention);
    // if the decoded html is the same as the body, there is no need in sending a formatted message
    if (HtmlUnescape().convert(html.replaceAll(RegExp(r'<br />\n?'), '\n')) !=
        event['body']) {
      event['format'] = 'org.sdn.custom.html';
      event['formatted_body'] = html;
    }
  }
  return sendEvent(event,
      txid: txid,
      inReplyTo: inReplyTo,
      editEventId: editEventId,
      threadRootEventId: threadRootEventId,
      threadLastEventId: threadLastEventId);
}