octaviuslabs / walter

AI-powered software development assistant built right into GitHub so it can act as your junior developer.
MIT License
8 stars 1 forks source link

New Comment Type #81

Closed jsfour closed 1 year ago

jsfour commented 1 year ago

We need a new comment type here: https://github.com/octaviuslabs/walter/blob/main/src/index.ts#L199 for "status" messages which are messages sent by the bot and say "Queued for processing..." or "Processing this now".

imwalterbot commented 1 year ago

We need a new comment type here: https://github.com/octaviuslabs/walter/blob/main/src/index.ts#L199 for "status" messages which are messages sent by the bot and say "Queued for processing..." or "Processing this now".

Queued for processing...

imwalterbot commented 1 year ago

To add a new comment type for "status" messages, you can modify the parseComment function to include a new regex pattern to match the status messages. Here is the updated pseudocode:

function parseComment(comment: any): CommentAction {
  const approveRegex = new RegExp(`@${BOT_NAME}\\s*APPROVED`, "i");
  const statusRegex = new RegExp(`@${BOT_NAME}\\s*(Queued for processing...|Processing this now)`, "i");

  if (approveRegex.test(comment.body)) {
    return { type: "approve", body: comment.body };
  }

  if (statusRegex.test(comment.body)) {
    return { type: "status", body: comment.body };
  }

  // design by default
  return { type: "design", body: comment.body };
}

This new code checks if the comment body matches the "status" message pattern, and if it does, it returns a new comment action with the type "status" and the comment body. The rest of the code remains unchanged.

jsfour commented 1 year ago

The comment will be from the bot (not tagged for the bot). Also update type for "comment" its a comment from the octokit webhook event.

imwalterbot commented 1 year ago

The comment will be from the bot (not tagged for the bot). Also update type for "comment" its a comment from the octokit webhook event.

Queued for processing...

imwalterbot commented 1 year ago

I understand your requirements now. You want to update the parseComment function to handle the status messages sent by the bot and update the type for "comment" from the octokit webhook event. Here's the updated pseudocode:

function parseComment(comment: any): CommentAction {
  const approveRegex = new RegExp(`@${BOT_NAME}\\s*APPROVED`, "i");
  const statusRegex = new RegExp(`(Queued for processing...|Processing this now)`, "i");

  if (comment.user.login === BOT_NAME && statusRegex.test(comment.body)) {
    return { type: "status", body: comment.body };
  }

  if (approveRegex.test(comment.body)) {
    return { type: "approve", body: comment.body };
  }

  // design by default
  return { type: "comment", body: comment.body };
}

This updated code checks if the comment user is the bot and if the comment body matches the "status" message pattern. If both conditions are met, it returns a new comment action with the type "status" and the comment body. The rest of the code remains unchanged, but the default type is now "comment" instead of "design".

jsfour commented 1 year ago

@imwalterbot APPROVED https://github.com/octaviuslabs/walter/blob/main/src/index.ts#L199 for changes

imwalterbot commented 1 year ago

@imwalterbot APPROVED https://github.com/octaviuslabs/walter/blob/main/src/index.ts#L199 for changes

Queued for processing...

imwalterbot commented 1 year ago

@imwalterbot APPROVED https://github.com/octaviuslabs/walter/blob/main/src/index.ts#L199 for changes

Processing this now