FoxxMD / context-mod

an event-based, reddit moderation bot built on top of snoowrap and written in typescript
https://contextmod.dev
MIT License
49 stars 11 forks source link

Please help with config #150

Closed thracyturnix closed 11 months ago

thracyturnix commented 12 months ago

Thanks for creating and supporting this project.

I am having a bit of trouble with initial config.

Goal:

Bot checks any activity in subreddit against activity in blacklist of subreddits.

If submission or post originates from account with activity in blacklist, remove.

I took the FreeKarma recipe, and modified it, but I suck at any kind of code and have messed it up somewhere.

It loads as a valid config, but it is not removing comments

Testing method:

Use alt account to post in blacklist subreddit, then comment in sub where contextbot is a mod running this script

Expected outcome: comments removed

Actual outcome: no action taken

{
  "runs": [
    {
      "checks": [
        {
          "name": "Fetish-sub activity alert",
          "description": "Check if author has posted in fetish subreddits",
          // check will run on a new submission in your subreddit and look at the Author of that submission
          "kind": "submission",
          "rules": [
            {
              "name": "BBW",
              "kind": "recentActivity",
              "useSubmissionAsReference": false,
              // when `lookAt` is not present this rule will look for submissions and comments.
              // lookAt: "submissions"
              // lookAt: "comments"
              "thresholds": [
                {
                  // for all subreddits, if the number of activities (sub/comment) is equal to or greater than 1 then the rule is triggered
                  "threshold": ">= 1",
                  "subreddits": [
                    "BBW",
                    "BBWhardcore",
                    "BBWpussys",
                    "bbwmilf",
                    "ssbbw",
                    "ebonyBBW",
                    "SBBW_FANS",
                    "ssbbwbutt",
                    "BBWanal",
                    "BBWaddict",
                    "OnlyFansChubbyBBW",
                    "BBWorship",
                    "maturebbw",
                    "BBWass",
                    "Fat_Fetish",
                    "bfatIRL",
                    "stuffersNSFW"
                  ]
                }
              ],
              // will look at all of the Author's activities in the last 7 days
              "window": "7 days"
            }
          ],
          "actions": [
            {
              "kind": "remove",
              "content": "{{rules.BBW.totalCount}} activities in karma {{rules.BBW.subCount}} subs over {{rules.BBW.window}}: {{rules.BBW.subSummary}}"
            }
          ]
        }
      ]
    }
  ]
}

Any chance someone could tell me what I need to change to make this work?

thracyturnix commented 11 months ago

Hello?

FoxxMD commented 11 months ago

Your configuration was close! The major change needed was that check.kind was submission but needed to be comment. kind determines what type of event (new submission or new comment) the bot runs on. Here is an updated config with a few other minor changes:

{
  "runs": [
    {
      "checks": [
        {
          "name": "Fetish-sub activity alert",
          "description": "Check if author has posted in fetish subreddits",
          // check will run on a new submission in your subreddit and look at the Author of that submission
          "kind": "comment",
          "rules": [
            {
              "name": "BBW",
              "kind": "recentActivity",
              "useSubmissionAsReference": false,
              // when `lookAt` is not present this rule will look for submissions and comments.
              // lookAt: "submissions"
              // lookAt: "comments"
              "thresholds": [
                {
                  // for all subreddits, if the number of activities (sub/comment) is equal to or greater than 1 then the rule is triggered
                  "threshold": ">= 1",
                  "subreddits": [
                    "BBW",
                    "BBWhardcore",
                    "BBWpussys",
                    "bbwmilf",
                    "ssbbw",
                    "ebonyBBW",
                    "SBBW_FANS",
                    "ssbbwbutt",
                    "BBWanal",
                    "BBWaddict",
                    "OnlyFansChubbyBBW",
                    "BBWorship",
                    "maturebbw",
                    "BBWass",
                    "Fat_Fetish",
                    "bfatIRL",
                    "stuffersNSFW"
                  ]
                }
              ],
              // will look at all of the Author's activities in the last 7 days
              "window": {
                  "count": 100,
                  "duration": {
                      "days": 7
                  }
              }
            }
          ],
          "actions": [
            {
              "kind": "remove",
              "content": "{{rules.bbw.totalCount}} activities in fetish {{rules.bbw.subCount}} subs over {{rules.bbw.window}}: {{rules.bbw.subSummary}}"
            }
          ]
        }
      ]
    }
  ]
}
thracyturnix commented 11 months ago

I copy pasted the rule to a test sub. Thanks very much for your reply and for the revised code.

I then used an account to post a comment on one of the blacklisted subs, and came back to test sub and posted a comment with that account.

Expected result is that context mod would remove the comments.

Actual outcome is that the comments remain.

I checked the back end and the bot is running.

I tried restarting the docker and repeating the test but same result.

thracyturnix commented 11 months ago

Sorry to bump again but we would really like to get this up and running in the Sub. Is there anyone who could help us figure out why its not working?

thracyturnix commented 11 months ago

Hello?

FoxxMD commented 11 months ago

You are likely missing a polling option to tell the bot to look at new comments. You need this to the top of the config:

  "polling": [
    "newComm",
    "newSub"
  ]

Like this

{
  "polling": [
    "newComm",
    "newSub"
  ],
  "runs": [
    {
      "checks": [
        {
          "name": "Fetish-sub activity alert",
          "description": "Check if author has posted in fetish subreddits",
          // check will run on a new submission in your subreddit and look at the Author of that submission
          "kind": "comment",
          "rules": [
            {
              "name": "BBW",
              "kind": "recentActivity",
              "useSubmissionAsReference": false,
              // when `lookAt` is not present this rule will look for submissions and comments.
              // lookAt: "submissions"
              // lookAt: "comments"
              "thresholds": [
                {
                  // for all subreddits, if the number of activities (sub/comment) is equal to or greater than 1 then the rule is triggered
                  "threshold": ">= 1",
                  "subreddits": [
                    "BBW",
                    "BBWhardcore",
                    "BBWpussys",
                    "bbwmilf",
                    "ssbbw",
                    "ebonyBBW",
                    "SBBW_FANS",
                    "ssbbwbutt",
                    "BBWanal",
                    "BBWaddict",
                    "OnlyFansChubbyBBW",
                    "BBWorship",
                    "maturebbw",
                    "BBWass",
                    "Fat_Fetish",
                    "bfatIRL",
                    "stuffersNSFW"
                  ]
                }
              ],
              // will look at all of the Author's activities in the last 7 days
              "window": {
                "count": 100,
                "duration": {
                  "days": 7
                }
              }
            }
          ],
          "actions": [
            {
              "kind": "remove",
              "content": "{{rules.bbw.totalCount}} activities in fetish {{rules.bbw.subCount}} subs over {{rules.bbw.window}}: {{rules.bbw.subSummary}}"
            }
          ]
        }
      ]
    }
  ]
}
thracyturnix commented 11 months ago

Worked! Thankyou!!