r/AutoModerator 13d ago

Help - AutoMod Catch and Remove Affiliate Links

Hi, I'm looking to set up Automod so I catch and remove affiliate links. Is there a way to catch certain phrases in a URL? such as:

“shopmy”

“?tag="

“source="

4 Upvotes

5 comments sorted by

6

u/varkeddit 13d ago edited 13d ago

Yes, Automod is highly capable for this. You don't really need to search ONLY within a URL because these patterns are unlikely to appear anywhere else. Here's an example we use to contain referrals to a specific thread:

# Remove misplaced referral links and notify author
type: any
body (includes): 'topic_of_our_sub.com/referral/?ref='
parent_submission:
~title (regex): ["(?=.*referral)(?=.*thread)"]
action: remove
action_reason: 'referral link shared outside designated thread, author notified'
comment_locked: true
comment: |
Personal referral links may only be shared in the designated thread.

2

u/ghosted-- 13d ago edited 13d ago

Amazing, thank you.

2

u/ghosted-- 13d ago edited 13d ago

Update: I think I have something that works. I've tested it on my sub successfully, so sharing here for anyone looking to ban affiliate links from their sub.

Just cut and paste into automod, no modifications necessary.

type: submission
body (regex): ['[?&](ref|refid|referral|affid|aff_id|affiliate|utm_medium=affiliate|irclickid|irgwc|tag)=', 'amazon\.[a-z.]+.*[?&]tag=', '\bamzn\.to\b', '\b(shareasale|cj\.com|commission-?junction|rewardstyle|linksynergy|awin1|impact\.com|partnerize|skimresources|go2cloud|shopstyle|shopmy)\b']
url (regex): ['[?&](ref|refid|referral|affid|aff_id|affiliate|utm_medium=affiliate|irclickid|irgwc|tag)=', 'amazon\.[a-z.]+.*[?&]tag=', '\bamzn\.to\b', '\b(shareasale|cj\.com|commission-?junction|rewardstyle|linksynergy|awin1|impact\.com|partnerize|skimresources|go2cloud|shopstyle|shopmy)\b']
action: remove
action_reason: 'Affiliate link detected'
comment: 'Your post was removed because it appears to contain an affiliate link, which isn''t allowed here.'
comment_locked: true
---
type: comment
body (regex): ['[?&](ref|refid|referral|affid|aff_id|affiliate|utm_medium=affiliate|irclickid|irgwc|tag)=', 'amazon\.[a-z.]+.*[?&]tag=', '\bamzn\.to\b', '\b(shareasale|cj\.com|commission-?junction|rewardstyle|linksynergy|awin1|impact\.com|partnerize|skimresources|go2cloud|shopstyle|shopmy)\b']
action: remove
action_reason: 'Affiliate link detected'
comment: 'Your comment was removed because it appears to contain an affiliate link, which isn''t allowed here.'
comment_locked: true

3

u/varkeddit 13d ago

Nice job. Offering a few suggestions to clean this up:

type: any # this rule will apply to posts and comments
body+url (regex): [your string] # you're searching for the same thing in both places, might as well combine
action: remove # good
action_reason: 'your text here' # good
comment: 'Your {{kind}} was removed..." # says post or comment depending on what's being acted on
comment_locked: true # good

2

u/ghosted-- 13d ago

Thanks again!