-
Couldn't load subscription status.
- Fork 2
Update groups.groovy #3
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
base: master
Are you sure you want to change the base?
Conversation
|
swarm.groovy also requires changes to GetGroupMembers |
| if(discordID?.trim()) { | ||
| mentionString += "${tagTemplate.replace('[id]', discordID)}, "; | ||
| } | ||
|
|
||
| // Not needed anymore? | ||
| Remove trailing ', ' | ||
| message = message.substring(0, message.length() - 2); |
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.
I suppose the , at the end of the mention string might not be needed at all if this now tags a single Discord ID rather than a list of them.
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.
Yea
| groupsParsed.groups.each { group -> | ||
| if (group.name == groupName) | ||
| { | ||
| groupType = group.type | ||
| discordID = group.discordID | ||
| } | ||
| } |
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.
Is it possible to break out of this loop prematurely?
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.
Breaking out of for-each loops in Groovy is illegal ([https://stackoverflow.com/questions/3049790/can-you-break-from-a-groovy-each-closure]). However using find ([https://www.tutorialspoint.com/groovy/groovy_find.htm]) we can break out of the loop prematurely using return true.
| } | ||
| def groupType = "" | ||
| def discordID = "" | ||
| def groupsParsed = new JsonSlurper().parseText(groups) |
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.
Doesn't loadGroups already parse the groups?
If you're passing the full group json into this function, maybe split loadGroups up into loadGroupsFromFile and loadGroupsFromString, or have loadGroups return the json string rather than a parsed version. (This would also mean that saveGroups shouldn't convert the groups to json, as they would already be in that format).
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.
Oh yeah missed that function. I suppose we can remove loadGroups (and pass file as string as argument) or convert loadGroups to just reading in the file and parsing it using JsonSlurper and return the JsonObject.
Group JSON files can now be read in as: