I'm writing a basic anti-spam filter that checks added_lines
but it seems to only work on edits of already existing pages, not for new pages, which have no diffs. Would new_text
do the job? Any other alternative?
Topic on Extension talk:AbuseFilter/Rules format/Archive 2
added_lines works for new pages too. On page creation, added_lines and new_text are the same
I'm asking this because the spam filter prevented all edits including an URL except one, which was a newly created page.
added_lines is likely not the cause. The variable is available for all edits, including new page creations. As an alternative, you may try new_wikitext (not new_text), but the result will be the same.
You're right, now I see where the problem is: there's a & !"://" in removed_lines
to allow edits on already existing URLs so that only new URLs are prevented, but that doesn't work on new pages because they have no previous version without an URL. I have no idea how to make this work logic-wise, can you help me?
If you want to catch the addition of new links exclusively, you can use added_links; but beware, that tends to be slowish. You'd better evaluate that variable only as the last condition of the filter (i.e. after user_groups checks etc.).
I thought about that but it's not very clear how it works, especially where it says "Only unique links are added to the array." Would a generic search for "https://" or such work, or does it only accept full URLs to specific websites?
That means that every link only appears once. Being an array, you can use length() on that, or string manipulation functions.
Oops, yes, I meant to say added_lines was the same as new_wikitext, not new_text