question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Probot double-posting comments.

See original GitHub issue

Bug Report

Current Behavior The bot for some reason posts 2 identical comments instead of 1. I’m sure I’ve made a mistake somewhere, but I’ve tried everything from reverting to plain code to trying other requests such as deleting the issue.

/**
 * This is the main entrypoint to your Probot app
 * @param {import('probot').Application} app
 */
const id_regex = /\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/gm;
const token_regex = /s[.][a-zA-Z0-9]{24}/gm;

module.exports = (app) => {
  app.on("issues.opened", async (context) => {
    reply_text = "";
    const id_of_issue = context["payload"]["issue"]["node_id"];
    const number_of_issue = context["payload"]["issue"]["number"];
    const body_of_issue = context["payload"]["issue"]["body"];
    const title_of_issue = context["payload"]["issue"]["title"];
    const user_of_issue = context["payload"]["sender"]["login"];
    if (body_of_issue.search(id_regex) != -1) {
      reply_text =
        reply_text + "\n" + construct_reply("ROLE-ID/SECRET-ID", "BODY");
    }
    if (title_of_issue.search(id_regex) != -1) {
      reply_text =
        reply_text + "\n" + construct_reply("ROLE-ID/SECRET-ID", "TITLE");
    }
    if (body_of_issue.search(token_regex) != -1) {
      reply_text = reply_text + "\n" + construct_reply("TOKEN", "BODY");
    }
    if (title_of_issue.search(token_regex) != -1) {
      reply_text = reply_text + "\n" + construct_reply("TOKEN", "TITLE");
    }
    var issue_body = body_of_issue;
    var issue_title = title_of_issue;
    issue_body = issue_body.replace(id_regex, " [REDACTED] ");
    issue_body = issue_body.replace(token_regex, " [REDACTED] ");
    issue_title = issue_title.replace(id_regex, " [REDACTED] ");
    issue_title = issue_title.replace(token_regex, " [REDACTED] ");
    issueComment = context.issue({
      body:
        "@" +
        user_of_issue +
        "\n" +
        reply_text +
        "\nYour post has been deleted but please re-submit as follows, without sensitive data: \n Title: >" +
        issue_title +
        "\n Body: >" +
        issue_body +
        "\n\n Thanks,\n Vault Team",
    });
    context.github.issues.createComment(issueComment);
    if (reply_text != "") {
      context.github.issues.createComment(issueComment);
      //delete_issue(context, id_of_issue)
      //create_issue(context,title,body)
    }
  });

  function create_issue(context, title, body) {
    return 1;
  }

  function delete_issue(context, id) {
    const mutate = `mutation deleteIssue($input: DeleteIssueInput!) {
                 deleteIssue(input: $input){
                     clientMutationId
                 }
               }
           `;

    const a = context.github.graphql(mutate, {
      input: {
        issueId: id,
      },
    });
  }

  function construct_reply(what, type) {
    return (
      "I've detected that you've used a " +
      what +
      " in your post's " +
      type +
      ". Keep in mind that role-id, secret-id and tokens are CONFIDENTIAL and must be treated as such."
    );
  }
};

SCREENSHOTS: (of terminal + git-issue) https://imgur.com/a/aj8JOLD

I’m using npm start instead of probot run. Not sure if that’s what’s causing it.

It acts the same way for all requests, by the way including deletes and new issues.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
issue-label-bot[bot]commented, Jul 20, 2020

Issue-Label Bot is automatically applying the label bug 🐞 to this issue, with a confidence of 0.96. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

0reactions
alaamubcommented, May 19, 2022

Different network fixed the issue… Weird. Anyway, thanks for the help @gr2m

what did you end up using for network?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ProBot Commands
Welcome images, moderation, leveling, reaction roles, logs, high quality music and many many more!
Read more >
/give-xp : r/probot - Reddit
I have currently one PrimeServer and one PrimeBot. On one of my servers we currently have a other admin bot.
Read more >
GitHub Apps and Probot - Dummies.com
Learn about GitHub's Probot framework and walk through how to build a simple GitHub App and explore Glitch, a web application hosting ...
Read more >
Probot - Wikipedia
Probot was a heavy metal side project of ex-Nirvana drummer and Foo Fighters rhythm guitarist and lead-singer Dave Grohl. Described by Grohl as...
Read more >
Top 5 Discord Moderation Bots to Keep Your Server Safe
Posted on September 21, 2020 ... In addition to the above free features, ProBot Discord offers two paid ... Questions or comments?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found