The attached ScripAction is basically, a range-based grep as applicable to
RT Transactions. It takes its patterns and ranges from the Template
object, and matches them against the current Transaction, eg:
body : -10 : : /^X-SamSpade-Version:\s*1\.14/ Search up to line 10 of the body for 'X-SamSpade-Version: 1.14'. head : 5-15: : /^X-Mailer:\s*Sam\s*Spade/ Search the headers (lines 5 to 15) for 'X-Mailer: Sam Spade' body : +30- : : /foo bar/ Search the last 30 lines for 'foo bar' (a contrived example) all : : : ! /fnord/ Search all the text for any non-occurences of the word 'fnord'.
( If there are two blank lines immediately above, seek brighter attention )
Further documentation on specifying patterns is available in a 'perldoc’
of the attached file.
OnCreate IsPattern with template DieSamSpadeDie
By itself, this ScripAction is pretty pointless. It doesn’t send any
email; it doesn’t set the status of the ticket, it just returns an
indicator as to whether the current transaction matched all of the
patterns in the template.
Requires the usage of ScripDependencies ([fsck.com #1551]) to actually be
of use, which basically modifies RT::Transaction to allow you to chain
Scrips together to have rather complicated conditionals ( eg bouncing
messages matching particular patterns (in this case spam complaints
generated by an out of date Windows version of Sam Spade which is very
irritating) to another address, and auto-resolving the ticket without
bothering to send an autoreply to the requestor ).
( As a side note, I could have implemented this particular functionality
in the .procmailrc which is in front of the queue. However, there are
other reasons for doing it this way. )
Bruce Campbell RIPE Systems/Network Engineer NCC www.ripe.net - PGP562C8B1B Operations/Security
IsPattern.pm (10.8 KB)