Skip to content

Markdown with Bad Entities #71

@surfer190

Description

@surfer190

When the bot sends a message that has unclosed/invalid markdown and parse_mode is set to Markdown. An error is raised from the telegram api and the message is never sent.

This is a problem, as the message delivery should be our number 1 concern.

My proposal is that a check be made in the send function:

  ###*
  # Send a message to a specific room via the Telegram API
  ###
  send: (envelope, strings...) ->
    self = @
    text = strings.join()
    data = @applyExtraOptions({chat_id: envelope.room, text: text}, envelope.telegram);

    @apiSend data, (err, message) =>
      if (err)
        @robot.logger.debug "Error received: " + err
        found = err.search /entities/
        if (found > 0)
          # send the message again without markdown set
          ...
        self.emit 'error', err
      else
        self.robot.logger.info "Sending message to room: " + envelope.room

Please look over and add to this code if you think it is an acceptable way, if not let me know ways to improve it.
Also, @gburgett if you have a minute please let me know your thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions