New Message: Re: Manila TrackBack Callbacks

webmaster at userland.com webmaster at userland.com
Mon May 29 16:58:45 CDT 2006


A new message was posted:

Address: http://frontier.userland.com/discuss/msgReader$14423

By: Matt Deatherage (frontier at gcsf.com)

So, here's how to write a callback that rejects all trackbacks for messages older then "dayLimit" days (as specified in the script):

on blockSpambacks (pta) {

 «workspace.tbpt = pta^ //debugging

 local (msgnum = pta^.pathArgs);
 local (adrmsg = mainresponder.discuss.getMessageTable (msgnum, pta));
 local (msgTitle = adrmsg^.newsitem.title);
 local (msgDate = adrmsg^.lastUpdate);
 local (dayLimit = 30);

 local (tbName = string.lower (pta^.postArgs.blog_name));
 local (tbURL = string.lower (pta^.postArgs.url));
 local (tbTitle = string.lower (pta^.postArgs.title));
 local (tbExcerpt = string.lower (pta^.postArgs.excerpt));
 local (tbContent = tbName + " " + tbURL + " " + tbTitle + " " + tbExcerpt);

 «First things first: if it's too old, reject it outright
 if !(workspace.lessThanXDaysAgo(msgDate, dayLimit)) {
 msg("Age-rejected trackback for \"" + msgTitle + "\" from " + tbURL);
 return (false)};

 «If we get this far, there's no reason to reject it
 return (true)}

I didn't need to pad the name of the message out to seven characters because I called mainResponder.discuss.getMessageTable to get the message table rather than do it myself. If the routine is there, I'm going to use it, so if you change the format, I don't have to fix my code. :-)

I showed how to get the blog_name, URL, title, and excerpt from the trackback. My full routine does more with those, but sample code is best when it shows you all the pieces.

--Matt

This is a Manila site... http://manila.userland.com/.




More information about the Manila-Server mailing list