View Single Post
Old 17 Jun 2023, 07:46 PM   #50
qwertz123456
Essential Contributor
 
Join Date: Jan 2008
Posts: 378
Quote:
Originally Posted by JeremyNicoll View Post
Don't know (because I don't use FM's automatic spam-scoring stuff.) But if you go into the Sieve edit screen and click the "copy to clipboard" button, then paste that into your text editor, then look at what the FM-generated code does, you should be able to find out whether they have a variable of their own containing your current GUI-set threshold value. If they do, you could use it.
Thanks for your input!
As I'm not a coder I just try to follow examples and instructions to find out by trial and error how things work, which can be frustrating a lot of times

I currently have this in the FM generated part:
Code:
  if anyof(header :value "gt" :comparator "i;ascii-numeric" "X-Spam-score" "4", header :regex "X-Spam-score" "^4\.[2-9]$") {
    fileinto "\\Junk";
    stop;
So would my code be correct like this?

Code:
if allof(string :is "${ADD_SCORE}" "true",
         anyof(header :value "gt" :comparator "i;ascii-numeric" "X-Spam-score" "${ST1}",
               header :regex "X-Spam-score" "^${ST1}\.[${ST2}]$")) { # X-Spam-score >= SPAM_THRESHOLD
  if header :matches "Subject" "{SPAM*} *" {        # "Add score" is working
    if string :is "${known_sender}" "true" {        # if known sender...
      deleteheader "Subject";                       # ...strip "{SPAM xx.x}" from Subject line
      addheader "Subject" "${2}";                   # X-Spam-score still shows the spam score
    }
  } elsif allof(string :is "${known_sender}" "false", # FM's "Add score" is not working or off
                header :matches "Subject" "*") {    # don't have to worry about known senders
    set "Subject" "${1}";
    if header :matches "X-Spam-score" "*" {
      set "spam_score" "${1}";
      if header :value "lt" :comparator "i;ascii-numeric" "X-Spam-score" "4" {
        set "spam_score" "0${1}";                   # add leading 0 for spam scores < 10
      }
    }
    deleteheader "Subject";                         # prefix Subject with "{SPAM xx.x}"
    addheader "Subject" "{SPAM ${spam_score}} ${subject}";
  } else {                                          # known sender && spam && no {SPAM*} prefix
    # as in the 1st case X-Spam-score still shows the actual spam score
  }
} # ADD_SCORE && spam
I changed the
Code:
"X-Spam-score" "4"
I'm not sure if the part
Code:
"^4\.[2-9]$") {
is important and where I might need to input that.
qwertz123456 is offline   Reply With Quote