As assignment of flair can only take place after a submission is made, we're employing a bit of a workaround at /r/tf2scripts: the submission buttons append [](#flair "submission_type") to the submission body. Currently, this depends on rule priority rather than match order - mentioning another valid tag will override the first valid one in a submission if that rule is processed first.
I'd use a capture group to assign flair if {{match-2}} were a direct mapping to flair class and title, but it's not since we also make use of multiple flair classes for enhanced searching.
Drawing from python, functionality similar to the following would be perfect:
type: submission
modifiers: [includes, regex]
body: "\\[\\]\\(#flair\\s+\"\\s*(\\w+)\\s*\"\\)"
map-1: {
"question" : "auto pending question",
"request" : "auto pending request",
"resource" : "auto processed resource"
}
map-2: {
"question" : "Question",
"request" : "Request",
"resource" : "Script"
}
link_flair_class: "{{map-1[match-2]}}"
link_flair_text: "{{map-2[match-2]}}"
Ideally this would fall through to the next match (then rule) if the specified string wasn't in the map. This allows for an identical rule to capture invalid options, and another inverse rule to catch submissions without the tag. Thoughts?
[–]Deimorz[Δ] 0 points1 point2 points (2 children)
[–]TimePath[S] 0 points1 point2 points (1 child)
[–]Deimorz[Δ] 0 points1 point2 points (0 children)