« Monday Night Football - new announcers (WTF?)... | Main| Updated NOTESurvey Central database »

Blogsphere - Delete "Fake" Responses agent

QuickImage   
Category
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 



Lately I have been getting more and more "fake" responses created in my blog - these are responses created by spammers that are created without any "parent" document (i.e. they don't have a $REF field, etc.). They appear at the top of my Stories view, and they simply annoy me because I have to delete them all the time. So, I decided to write an agent to delete them for me - and I figured that others must be experiencing the same problem, so I thought I would share the agent here.

It is a really small agent - here's all the code:
Sub Initialize Dim s As New NotesSession Dim thisdb As NotesDatabase Dim col As NotesDocumentCollection Dim doc As NotesDocument,deldoc As NotesDocument On Error Goto errHandler Set thisdb = s.CurrentDatabase Set col = thisdb.UnprocessedDocuments If col.Count = 0 Then Exit Sub Set doc = col.getFirstDocument Do While Not(doc Is Nothing) If doc.GetItemValue("Form")(0) = "StoryResponse" Then If doc.HasItem("$REF") = False Then Set deldoc = doc End If End If Call s.UpdateProcessedDoc(doc) Set doc = col.GetNextDocument(doc) If Not(deldoc Is Nothing) Then Call deldoc.Remove(True) Loop getOut: Exit Sub errHandler: Msgbox Error$ & " (" & Err & ") [line: " & Erl & " in DeleteFakeResponses agent]",, "Error" Resume getOut End Sub

Not much to it. The agent is scheduled to run "after documents are created or modified", and is set to run on my blog server. It gets a collection of unprocessed documents, then loops through all of them. It first checks the form to see if it is "StoryResponse", and if it is then it checks to see if it has a $REF item. If it does not, the doc is set to a deldoc handle, and is deleted after the next document handle is gotten (so that it loops correctly).

I tested it, and I am running it now with great success. Hopefully it will help you too.

Enjoy!

Rock
**Mr. Scott, there are always alternatives. --Mr. Spock, Star Trek

Comments

1 - Nice, Rock... I recently wrote an agent to remove spam comments that all had a particular user name in them. But I hadn't taken the step to also remove the orphan spam comments. I had about five of them sitting there from today. I loaded your agent, it ran, and POOF! No more spam comments! Thanks...

2 - Thanks, Rock! I have the same issue (smaller scale, but still annoying). I put your agent in last night, and now I won't have to deal with them anymore. Sweet!

3 - Trying it out. But on my server, I named the agent "Rocky's Spam Deletion Agent" instead of "DeleteFakeResponses".

4 - Rock,
Dang, this is very nice ...simple and elegant.

A year (probably 2 yrs) ago I modified the agent in my Blogsphere db that notifies me when new comments are posted. I added some code that deletes the doc if it meets certain criteria (like no body text, no contact info, etc), AND I have it still notify me via email with the IP or whatever other info is available. I also added a line in the notification email that I can click to invoke an agent to delete the comment if it's obvious from the email address, IP, or site URL of the sender that it's bogus. The point is that it may still be useful to track the ip and/or other info.

I think I'll take your code and incorporate it. I'll try and make time in the next day or three to post the merged code (or email it to you :) re the delete agent and linking from the notification email (it's of course, painfully simple, not too elegant, etc., etc.).

5 - Cool, thanks! Will test it immediately, I had to remove 15 of those documents, today alone. And it's still in the morning!

6 - @Rock,

You read my mind. Thanks for this agent code.

Bruce

7 - The Housekeeping agent does the same on a daily basis starting Blogsphere version 2.1.1

8 - Bless you, my son.

Meet Rocky

Rocky Oliver
Rocky Oliver
If you see me at a conference, please stop me and say hi!

Calendar

Search

Categories

LotusGeek Tour 2008

DNUG08-2.png

Proudly Employed By

I am the Vice President of Products for TeamStudio

Our Corporate Blog

I am the Vice President of Products for TeamStudio

Thawte Notary

Thawte Web of Trust Notary

LOTUS GEEK gear

Social Networking


Add to Technorati Favorites

View Rocky Oliver's profile on LinkedIn

Rocky  Oliver

LotusGeek Blog Roll

Why display a blog roll when Planet Lotus does it so much better?

Dilbert

Buy my book!

Blog Buttons

Atheist - Unitarian - Humanist

Atheist Symbol

chalice_150.gif

Happy Humanist

Poker Players Alliance

This Site Designed By

YOU! If you would like to see your name and link here, read more about the Skin the Geek contest!