This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
feat: selectivly enable incentives #781
Closed
Closed
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b0944d4
chore: t
BeanieMen 1efcc22
chore: t
BeanieMen 390fc25
chore: t
BeanieMen dadcde8
Merge branch 'ubiquity:development' into development
BeanieMen d3e8230
feat: selectivly enable incentives
BeanieMen a428f89
feat: selectivly enable incentives
BeanieMen 66b1296
feat: selectivly enable incentives
BeanieMen 922e827
feat: selectivly enable incentives
BeanieMen dc2a547
feat: selectivly enable incentives
BeanieMen e8c8f7c
feat: selectivly enable incentives
BeanieMen 207a243
Merge branch 'development' into dev-6
BeanieMen 887c3a2
Merge branch 'ubiquity:development' into dev-6
BeanieMen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getBotContext, getLogger } from "../../../bindings"; | ||
import { Payload } from "../../../types"; | ||
|
||
export const commentIncentive = async (body: string) => { | ||
const context = getBotContext(); | ||
const logger = getLogger(); | ||
const payload = context.payload as Payload; | ||
const sender = payload.sender.login; | ||
|
||
logger.info(`Received '/comment-incentive' command from user: ${sender}`); | ||
|
||
if (!payload.issue) { | ||
logger.info(`Skipping '/comment-incentive' because of no issue instance`); | ||
return `Skipping '/comment-incentive' because of no issue instance`; | ||
} | ||
const parts = body.split(" "); | ||
parts.shift(); | ||
if (parts.pop() !== "true" && parts.pop() !== "false") { | ||
return `invalid syntax for /comment-incentive \n usage /comment-incentive @user @user1... true|false \n ex /comment-incentive @user true`; | ||
} else { | ||
return; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,32 @@ export const listAllIssuesForRepo = async (state: "open" | "closed" | "all" = "o | |
return issuesArr; | ||
}; | ||
|
||
export const getIncentivizedUsers = async (issue_number: number) => { | ||
const comments = await getAllIssueComments(issue_number); | ||
const incentiveComments = comments.filter((comment) => comment.body.startsWith("/comment-incentives")); | ||
let users: { [key: string]: boolean } = {}; | ||
for (const incentiveComment of incentiveComments) { | ||
const parts = incentiveComment.body.split(" "); | ||
parts.shift(); | ||
if (parts.pop() == "true") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this relies on command order. just use a for loop and check for |
||
for (const part of parts) { | ||
if (part.startsWith("@")) { | ||
users[part.substring(1)] = true; | ||
} | ||
} | ||
} else if (parts.pop() == "false") { | ||
for (const part of parts) { | ||
if (part.startsWith("@")) { | ||
users[part.substring(1)] = true; | ||
} | ||
} | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
return users; | ||
}; | ||
|
||
export const addCommentToIssue = async (msg: string, issue_number: number) => { | ||
const context = getBotContext(); | ||
const logger = getLogger(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can create a helper function that parses the command so you can use it here and in
getIncentivizedUsers
to avoid repeating code