Tom's Gravity Pages
[HOME] [INDEX]

Rule Examples

[BACK TO RULES]

If you are a new user I am not implying that you need these rules. I am presenting them for illustration purposes only. Some I use regularly, others I developed to help someone do something and I did not test them very thoroughly.

Some of these examples may seem pointless or trivial, but I have included them anyway. Maybe they will demonstrate something that you didn't know you could do before. Creating rules is straight forward. After you see a few rules you will realize how simple they are.

You may notice that I use 'T' to tag articles, as a user flag. This will NOT work where you are saving bodies (you can't tag an article that already has a local body).

You can use %s, the user input condition, as a regular expression. You can also combine it with other conditions.

Example Rules

Old rule examples

These are presented in Gravity's text script format and are not formatted with kewl HTML yet. Some may be outdated but I keep them around for more examples. Go to Old Rules.


Find articles less than 300 lines, greater than 3400 lines and that do not contain .jpg

From a Usenet request. This is an example rule condition to delete, or mark as read, an article which does NOT contain .jpg in the subject, or contains less than 300, or greater than 3400 lines. In other words, it leaves you with .jpgs between 300 and 3400 lines.

Subject does not contain ".jpg"
Or
Lines > 3400
Or
   (
   Not
   Lines > 300
   )

Notify Me Of Replies To My Posts

You can use any combination of the actions I have shown (or throw in more). I used to include the message box (show alert) but found it a little tedious to keep dismissing the boxes. You might like it. I have also included my email address to show my own posts but you don't have to.

NOTE: If your news server changes the article IDs, the "article is reply to my message" rule condition does not work. Also be sure that you letting Gravity assign the article ID under Server - Properties - Posting. The box should be checked.
From contains "nfn03862@naples.net"
Or
In reply to my message

Actions:

Play a sound (select a .wav)
Mark as Important
Add 2 to article's score

If you get a lot of replies you might want to increase the number of article IDs to keep in Global Options, Posting. Also, you need to have score colors defined for the scoring to have any effect.


A Rule To Find An Article By Message ID (manual)

Here is a way to search for a specific Message-ID. Note that the header must be present on your drive. Make a rule with this condition:

   Header contains "%s"

For an action have it tag the article or whatever. Then run the rule manually, paste in the ID and find it with the tag (the tagged article filter can help). (If you are storing local bodies then use something other than tag, like mark important). After the initial rule is set up the method is not really that involved.

I keep a rule like this around anyway for searching articles because it looks in 'from' and 'subject' and 'ID.'


Rules To Not Download Large Articles

These 2 rules are for those users who like to retrieve and store article bodies. But I suppose they could be applied to on-line reading. They are useful for filtering out large articles, like HTML or binary posts in discussion groups. You set the threshold value based on number of article lines. Method 1 totally discards (deletes) the article during download. You will never see it. Method 2 will allow you to get the header but not the body while continuing to fetch the smaller articles. The difference is that the header is available to view the subject.

If you are worried about deleting an FAQ you can specify that in the rule conditions. Also, did you know you can set storage options for each group individually, under newsgroup properties?

Make sure you are not applying Method 1 to binary groups (or you won't have any left)!

METHOD 1: Assumes you are set to retrieve and store all bodies locally. Make a rule:

Condition: lines > xxx
Action: discard

Apply to incoming and ONLY the group(s) in question or you will delete all your binaries, if it matters. With this method you will never see the article.

You might be tempted to use "mark article as read" for a rule action. That is ok but note that if you have Gravity set to retrieve and store ALL bodies you will fetch the body anyway which seems to be defeating our purpose. However, discard will not fetch the body.

METHOD 2: First, set the group or global storage options to NOT store bodies. Create a rule for this group or all applicable groups and apply to incoming.

Condition: NOT Lines > xxx
Action: retrieve bodies

Method 2 is also nice for applying to certain groups only. Lets say you want to connect and get headers for all groups and just bodies for special groups. Just set this rule to apply only to select groups and you don't have to worry about getting stuck retrieving a large article.


Create A Text File Archive of Posts

You can easily create a running archive of articles posted by an author (or any rule condition[s] you can dream up). I used to keep one of all of Tony's (MicroPlanet) posts. Apply the rule for the desired group(s) and enable for incoming. Make a different rule for each archive you want to keep. Just remember you have these text files or you may find they have grown very large over time.

Here is another tip: I think the headers that are stored in the text file are the same ones visible in the article pane, so if you want include other headers, simply add them to the article view.

Conditions:

  From contains "@microplanet.com "
Actions:
  Append to file: D:\Document\notes\gravity\tony.txt
  Mark as Unread
  Mark as Protected
  Fetch Body

The last two actions are optional and somewhat redundant but are nice if you want to view the posts within Gravity rather than a text file.


How-To Ignore Any Thread Started By A Specific Author

This rule should add any thread started by the specified author(s) to the ignore list. Let me warn you that it may have side-effects if the bozo author makes a followup and renames the thread. The rest of the thread may be ignored from that point onward. If you use something like this in a group with very long threads you should check periodically with the all articles filter to make sure this hasn't happened. In groups with typically short threads it shouldn't be a problem.

  From contains reg. expr. "that_author@domain.com"
  And
  Subject does not contain reg. expr. "<0>(re: )"

Actions:

1. Mark article read
2. Add to the ignore list

If a subject contains re: , it is a usually a follow up. So, if it is not present in subject we can assume it is a thread started by so and so (except see the warning above). You can easily modify this one rule to include several authors by separating the authors with the pipe (vertical slash) in a regular expression.

From contains reg. expr. "author1@domain|author2@domain2|author3@and.so.on"

How-To Filter Articles Cross Posted From A Specified Group

This is based on a Usenet thread. The problem was that annoying posters from alt.flame were posting to other discussion groups and a Gravity user wondered if there was a way to filter out these posts. There is no apparent way to do this with Gravity. Some preliminary testing shows the following method should work. Email me if you run into trouble with it or have improvements.

This solution is to actually subscribe to the offending group(s) (i.e. alt.flame), create a rule that marks everything read in alt.flame and let Gravity's cross post management mark them read in your regular groups.

As a pre-requisite, make sure "include cross post data" is checked under server properties.

Also, make sure that the rule to mark all articles read in alt.flame is applied only to alt.flame (under the rules general tab; applies to specific group). The rule condition for alt.flame would be:

No conditions -- always true

Of course this method requires some additional disk space and download time. You might want to over ride purge settings for the dummy groups to something very short. You can also nickname the dummy groups so they appear at the end of your newsgroup list and are out of the way.


Forward Articles To Multiple Email Recipients

If you like to forward articles by email you can send them to a whole list. The syntax is standard Internet email addressing. In other words, separate the addresses with a semicolon or comma or comma and space. You could have multiple lists by creating one rule per list. This is one list syntax that works for me. It is copied from a working rule.
  tb@zeone.net, nfn03862@naples.net, tb1107@here.net

You can apply a rule like this automatically to incoming articles based on special criteria (maybe like in reply to your articles, or from a special author). Or, I apply it manually. I tag the article and run the rule manually. In this case the rule condition is; tagged for download. The actions would be

  forward to (email recipient or list)
You might also need to include
  retrieve article body
I think older versions of Gravity required the fetch body condition for forward to work so, to be safe, you should include it.

Un-ignore Important Articles

The Ignore Thread Rule marks all articles in the thread as Read. This rule was developed to allow certain authors or articles with important words through ignored threads. The principal is simple, if it is marked as Important, simply mark it as Unread. This works, but I have heard reports of slightly erratic article counts which can be rectified with a catch up or mark all articles as read command.

Note that rule order is important in this case. Your Important Word rule(s) would come first, next is ignore thread, next would be a rule something like described below. This rule MUST follow the Ignore thread rule. Otherwise the Ignore thread will mark them as read.

Conditions:
 In an ignored thread
 And
 Marked as important
Action:
 Mark as Unread

Make sure to enable it for incoming.


Old Rules


   RULE: Filters out some SPAM
ACTIONS: Marks read

COMMENTS: The last line contains a curious regular expression
which targets any subject line not containing a lower case letter,
or response to a subject line with all caps. (Thanks to Paul Neubauer)
The two previous regular expressions target subjects with FREE and
MONEY (all caps).

rule = kill money
  enabled = Yes
  allgroups = No
begin groups
  alt.msdos.batch
  alt.usenet.offline-reader
  comp.infosystems.www.browsers.ms-windows
  comp.os.linux.questions
  comp.os.msdos.djgpp
  comp.os.ms-windows.win95.misc
  MediaOne.surfboard
  news.software.readers
end groups
begin condition
  Subject contains "$"
  Or
  Cross-posted to > 5 groups
  Or
  Subject contains reg. expr. "[F][R][E][E]"
  Or
  Subject contains reg. expr. "[M][O][N][E][Y]"
  Or
  Subject contains reg. expr. "<0>(R[eE]: )*[^a-z]*<~0>"
  
end condition
begin actions
  markAsRead
end actions
end rule


-------------------------------------

  RULE: Filter our HipCrime's reposts
ACTION: Marks them read

COMMENTS: Hipcrime's reposts always started with REPOST (all caps)
The regular expression specifies that the subject starts with
REPOST at the beginning of the line followed by a colon and
one or more spaces.

rule = Nuke HipCrime
  enabled = No
  allgroups = No
begin groups
  alt.usenet.offline-reader
  news.software.readers
end groups
begin condition
  Subject contains reg. expr. "<0>([R][E][P][O][S][T]): +"
end condition
begin actions
  markAsRead
end actions
end rule

-------------------------------------

  RULE: Filters out NAMBA
ACTION: Marks them read

COMMENTS: I used this temporarily while NAMBA
was doing their thing. The only consistent thing
I could find with their posts were that they were
cross posted to 4 groups. Every now and then you may hit
an innocent post but usually posts in NSR are only posted to
1 or 2 groups.


rule = kill NAMBA
  enabled = No
  allgroups = No
begin groups
  news.software.readers
end groups
begin condition
  Cross-posted to > 3 groups
end condition
begin actions
  markAsRead
end actions
end rule

-------------------------------------

   RULE: Forward an article to my work email account.
ACTIONS: Mail

COMMENTS: No need for floppies send it right to work. Run manually.

rule = Forward to Work
  enabled = No
  allgroups = No
begin groups
  MediaOne.test
end groups
begin condition
  Marked as tagged for download
end condition
begin actions
  forwardTo me@yuckywork.com
  markAsRead
  fetchBody
end actions
end rule

-------------------------------------

  RULE: Marks movies (avi, rm, mpeg, mpg)
ACTION: NA

COMMENTS: This is a rule condition only. I included it
to show the regular expression. To find file extensions
include the dot (period) but it must be "escaped" with
the backslash (only in regular expressions). The reason
is the dot has a special meaning. The vertical
"pipe" symbol acts as an OR condition.

 Subject contains reg. expr. "\.avi|\.mpg|\.rm|\.mpeg"

The equivalent way to do this without reg expressions is ...

  Subject contains ".avi"
  Or
  Subject contains ".rm"
  Or
  Subject contains ".mpg"

------------------------------------

  RULE: Marks old articles read, keeps new ones
ACTION: Marks read

COMMENTS: Every now and then one of those large groups
gets loaded with 3 or 4 thousand unread articles. This catches up.
by marking the older posts read. Run manually.

rule = Article catchup 3 day
  enabled = No
  allgroups = Yes
begin groups
end groups
begin condition
  Posted > 3 days ago
  And
  Marked as unread
end condition
begin actions
  markAsRead
end actions
end rule

--------------------------------------

  RULE: Condition to hit two line articles.
ACTION: NA

COMMENTS: Will hit articles containing exactly two lines.

begin condition
  Lines > 1
  And
  Not
  Lines > 2

------------------------------------

RULE: Will delete selected articles or, if only one is selected
every article in the group will be deleted.

COMMENTS:Kind of like a super catchup. Obviously, there is some
inherent danger in using this rule.

rule = b-delete
  enabled = No
  allgroups = No
begin groups
  MediaOne.test
end groups
begin condition
end condition
begin actions
  discard
end actions
end rule

-------------------------------------

   RULE: A test rule condition to search article IDs
ACTIONS: NA

COMMENTS: Article IDs are appended with strings from
posting hosts. This is just an example of how you could
find posts from a particular ISP or host.

begin condition
  Header contains reg. expr. "nnrp1\.dejanews\.com"

NOTE: Deja News or other ISPs may have more than one server. If so,
use the period as a wild card or specify a list something like this.
For reg expressions.

"nnrp.\.dejanews\.com" 
   OR
"nnrp[0-9]\.dejanews\.com" 

-------------------------------------
 
  RULE: Delete small binaries or articles
ACTION: Discards

COMMENTS: For those special binary moments 

rule = clean lines < 700
  enabled = No
  allgroups = Yes
begin groups
end groups
begin condition
  Not
  Lines > 700
end condition
begin actions
  discard
end actions
end rule

*****************************************
             USING  %s

Here are four examples of how to use 
a user-specified string in rules. All
are run manually. I do not show it but
you enter %s as a regular expression, or
combine it with other rule conditions.

*****************************************

Example 1. This one uses your phrase to search
           Subject and add 3 to the score.   
           
rule = search
  enabled = No
  allgroups = Yes
begin groups
end groups
begin condition
  Subject contains "%s"
end condition
begin actions
  addToScore 3
end actions
end rule

------------------------------------

Example 2. Similar to Example 1 but searches "From"
           and tags the article for download.

rule = User specified author
  enabled = No
  allgroups = Yes
begin groups
end groups
begin condition
  From contains "%s"
end condition
begin actions
  tag
end actions
end rule

-------------------------------------

Example 3. This one is a little more interesting
           because it demonstrates an often overlooked
           rule condition, or the Header. Searches the
           header (from, subject, Article ID) and tags
           the articles.

rule = User specified header
  enabled = No
  allgroups = Yes
begin groups
end groups
begin condition
  Header contains "%s"
end condition
begin actions
  tag
end actions
end rule

------------------------------------

Example 4. This rule deletes everything in a group except
           what is specified.

rule = deleteexcept
  enabled = No
  allgroups = Yes
begin groups
end groups
begin condition
  Subject does not contain "%s"
end condition
begin actions
  discard
end actions
end rule

Back to top of page