Closed wchristian closed 1 year ago
I'm not sure I understand what you are trying to do, could you give me an example configuration with your desired behavior?
You can used named rules to reference defined rules, if this is what you are looking for. The same naming behavior works for rules as well.
In short, i'm trying to golf this.
runs:
- checks:
- name: dgg Dual Citizen
kind: comment
rules:
- condition: AND
rules:
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 6', subreddits: ["destiny"] } ]
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 6', subreddits: ["vaushv"] } ]
actions:
- kind: report
content: bot report - dgg Dual Citizen
- name: dgg Hardcore
kind: comment
rules:
- condition: AND
rules:
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 6', subreddits: ["destiny"] } ]
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 1', subreddits: ["vaushv"] } ]
actions:
- kind: report
content: bot report - dgg Hardcore
- name: dgg Ambassador
kind: comment
rules:
- condition: AND
rules:
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 1', subreddits: ["destiny"] } ]
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 6', subreddits: ["vaushv"] } ]
actions:
- kind: report
content: bot report - dgg Ambassador
- name: dgg Newbie
kind: comment
rules:
- condition: AND
rules:
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 1', subreddits: ["destiny"] } ]
- kind: recentActivity
window: 30 days
thresholds: [ { threshold: '>= 1', subreddits: ["vaushv"] } ]
actions:
- kind: report
content: bot report - dgg Newbie
Ok, I see what you mean now.
The content
rendering function doesn't have access to the check name but I can add that in pretty easily! I'll make sure that gets added for the next release.
In the meantime you can shorten your config somewhat by re-using rules:
runs:
- checks:
- name: dgg Dual Citizen
kind: comment
rules:
- condition: AND
rules:
- kind: recentActivity
name: destinySixRecent
window: '30 days'
thresholds:
- threshold: '>= 6'
subreddits:
- destiny
- kind: recentActivity
name: vaushSixRecent
window: '30 days'
thresholds:
- threshold: '>= 6'
subreddits:
- vaushv
actions:
- kind: report
content: bot report - dgg Dual Citizen
- name: dgg Hardcore
kind: comment
rules:
- condition: AND
rules:
- destinySixRecent
- kind: recentActivity
name: vaushOneRecent
window: '30 days'
thresholds:
- threshold: '>= 1'
subreddits:
- vaushv
actions:
- kind: report
content: bot report - dgg Hardcore
- name: dgg Ambassador
kind: comment
rules:
- condition: AND
rules:
- kind: recentActivity
name: destinyOneRecent
window: '30 days'
thresholds:
- threshold: '>= 1'
subreddits:
- vaushv
- vaushSixRecent
actions:
- kind: report
content: bot report - dgg Ambassador
- name: dgg Newbie
kind: comment
rules:
- condition: AND
rules:
- destinyOneRecent
- vaushOneRecent
actions:
- kind: report
content: bot report - dgg Newbie
P.S. you can write the whole config in JSON if you are more familiar with that ;)
Suggested by @CuriousLyz -- add {{subreddit}}
to template
hey @wchristian ! Sorry this is so late but you can now use {{check}}
to get the check name. This is in the edge
branch now and I'll do a release next week. You would use it like this:
actions:
- kind: report
content: {{check}}
You could also re-use the action if you named it, like this:
checks:
- name: myCheck
#...
actions:
- name: reportCheck
kind: report
content: {{check}}
- name: mySecondCheck
#...
actions:
- reportCheck
my own work has been very busy, but i want you to know i appreciate this :)
I want to have a bunch of checks that have different rules, but the same action (create a report) and indicate which check they belong to, and i think i could save some space by having the action report template just use the check's name.