Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown with Bad Entities #71

Open
surfer190 opened this issue May 23, 2019 · 0 comments
Open

Markdown with Bad Entities #71

surfer190 opened this issue May 23, 2019 · 0 comments

Comments

@surfer190
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant