mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2006
Posts: 44
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Aug 2006
Posts: 44
I am a Co-Owner of an IRC Network, I used to code script but it has been a while, so I am asking for help in updating my spamfilter script written for UnrealIRCd-3.*. The Spamfilter command has changed in UnrealIRCd-4.*.
Code:
UnrealIRCd-3.*: /spamfilter [add|del|remove|+|-] [type] [action] [tkltime] [reason] [regex]

UnrealIRCd-4.*: /spamfilter [add|del|remove|+|-] [method] [type] [action] [tkltime] [reason] [string]


According to
Quote:
/helpop ?spamfilter

Code:
[method]  Matching method, must be one of:
          -regex (PCRE fast regex),
          -posix (old 3.2.x POSIX regex), or
          -simple (fastest but only supports ? and * wildcards)
[type]    specifies the target type, you can specify multiple targets:
          'c' channel msg, 'p' private msg, 'n' private notice,
          'N' channel notice, 'P' part msg, 'q' quit msg, 'd' dcc,
          'a' away, 't' topic, 'u' user (nick!user@host:realname ban)
[action]  specifies the action to be taken (only 1 action can be specified):
          'kill', 'tempshun' (only shun current session), 'shun',
          'kline', 'gline', 'zline', 'gzline', 'block' (blocks the msg),
          'dccblock' (unable to send any dccs), 'viruschan' (part all channels
          and join the virus help chan), 'warn' (warn for IRC Operators).
[string]  this is the actual string that should be blocked (regex or simple pattern)
[tkltime] the duration of the *LINEs placed by action (use '-' to use the default
          set::spamfilter::ban-time, this value is ignored for block/tempshun');
[reason]  the reason for the *LINE or blockmsg, CANNOT CONTAIN SPACES,
          '_' will be translated to spaces. Again, if you use '-' for this
          the default (set::spamfilter::ban-reason) is used.
- 
A few examples (note they will probably line-wrap!):
/spamfilter add -simple p block - - Come watch me on my webcam
/spamfilter add -simple p block - Possible_virus_detected,_join_#help Come watch me on my webcam
/spamfilter add -simple p tempshun - - You_are_infected me.mpg
/spamfilter add -simple p gline - - Come watch me on my webcam
/spamfilter add -simple p gline 3h Please_go_to_www.viruscan.xx/nicepage/virus=blah Come watch me on my webcam
/spamfilter add -simple p kill - Please_go_to_www.viruscan.xx/nicepage/virus=blah Come watch me on my webcam
/spamfilter del -simple p block - - Come watch me on my webcam*
/spamfilter add -regex cN gzline 1d No_advertising_please /come to irc\..+\..+/
-


I had a Dev Team helping me with this Script/Snippet at one time, so now I am asking others if they don't mind helping out.

Here is the Script/Snippet: (This creates a dialog)
Code:
[Addon]
Script=DragonRyder SpamFilter Addon
Version=3.0.0
Author=DR DevTeam
Desc=SpamFilter Addon For Blocking and Removing Spam From A Dialog Script
For=DragonRyder v13.5
Date=Nov. 2018
;This script/snippet was written for:
;Old Style: /spamfilter [add|del|remove|+|-] [type] [action] [tkltime] [reason] [regex]
;Needs updated to:
;New Style: /spamfilter [add|del|remove|+|-] [method] [type] [action] [tkltime] [reason] [string]

menu status,@Stats {
  »« SpamFilter »«
  .»« DragonSpam Manager Dialog »«:spamdlg
  .»« List All Set SpamFilters »«:Stats f
  -
}
;--------------- Spam Filter ---------------

;--return ini data file location
alias spamfiltdf { return $qt($mircdir $+ dr_spamfilt_data.ini) }
;--return ini file entries
alias filtinir {
  if (($1 == $null) && ($2 == $null)) return $null
  return $readini($spamfiltdf,$1,$2)
}

;-- get/reload spamfilter list (stats f)
alias gtspfltl {
  var %dn = dr_dev_spam_man, %f = $spamfiltdf, %htm = $+(%dn,.tmpflts)
  did -ra %dn 3,4 - | did -r %dn 5,6,10,11,16 | did -u %dn 1-2 | did -b %dn 6,20-22,24

  if ($hget(%htm)) { hfree %htm }
  hmake %htm | hload -i %htm %f spf_filters
  remini %f spf_filters

  if ($1 == reload) {
    var %x = 1
    while (%x <= $hget(%htm,0).item) { tmpspfltrs spf_filters $hget(%htm,%x).data | inc %x }
    dlgfltld | hfree %htm
  }
  else { stats f }
}
;--- handle raws when/while dialog is open..
raw *:*: {
  var %dn = dr_dev_spam_man, %httm = $+(%dn,.temp), %nm = $numeric
  if (($dialog(%dn)) && ($istok(8 219 221 229 381 481,%nm,32))) {
    if (%nm == 219) {
      if ($hget(%httm,wipe)) { hdel %httm wipe }
      dlgfltld
    }
    elseif (%nm == 221) { dialog -t %dn Dragon Spamfilter Managment - $+([,$network $chr(40),$2-,$chr(41),]) }
    elseif ((%nm == 229) && ($2 === F)) {
      if ($hget(%httm,wipe)) { spamfilter - $3-4 - - $10- }
      else { tmpspfltrs spf_filters $tgfltsrt($3) $4- }
    }
    elseif (%nm == 381) { mode $me }
    elseif (%nm == 481) { echo -ast 04Stats Fail!!! $2- | did -ra %dn 6,10,11 $2- | did -e %dn 21 }
    haltdef
  }
}
;--load up the captured (raw 229) filters to the inifile.
alias tmpspfltrs {
  var %f = $spamfiltdf
  if ($isid) { return $readini(%f,n,$1,$2) }
  writeini -n %f $1 $+(filter.,$iif($ini(%f,$$1,0) != 0,$calc($ini(%f,$$1,0) + 1),1)) $$2-
}
;--load dialog from ini file
alias dlgfltld {
  var %dn = dr_dev_spam_man
  var %f = $spamfiltdf, %x = 1, %t = $ini(%f,spf_filters,0)
  while (%x <= %t) { did -a %dn 6 $gettok($tmpspfltrs(spf_filters,$ini(%f,spf_filters,%x)),8-,32) | inc %x }
  did -e %dn 6,20-21 | if (%t > 0) { did -e %dn 24 }
}

;--dialog open/bring to front..
alias spamdlg {
  var %dn = dr_dev_spam_man
  if (!$dialog(%dn)) { dialog -mh %dn %dn }
  else { dialog -v %dn }
}
;--Spamfilter dialog
dialog dr_dev_spam_man {
  title "Dragon Spamfilter Managment"
  size -1 -1 292 145
  option dbu
  combo 2, 116 43 35 50, sort drop
  edit "-", 3, 170 43 27 10, center
  edit "-", 4, 116 29 118 10, autohs
  edit "", 5, 116 16 118 10, autohs
  list 6, 10 16 78 71, size
  list 1, 240 29 42 68, sort size extsel
  text "Reason", 7, 95 30 20 8, center
  text "Match", 8, 95 17 20 8, center
  text "Action", 9, 95 44 20 8, center
  text "", 10, 97 61 135 39
  box "Edit Filter", 12, 92 6 145 97
  text "", 11, 9 106 274 17
  button "Close", 13, 258 131 25 10, ok cancel
  box "Current Filters", 14, 6 6 87 97
  text "Time", 15, 152 44 17 8, center
  edit "", 16, 240 16 42 10, read center
  box "", 18, 6 99 281 29
  box "Filter Targets", 19, 236 6 51 97
  box "", 17, 92 55 145 48
  button "Add/Update", 20, 199 43 35 10, disable
  button "Get", 21, 11 90 20 10
  button "Del", 22, 39 90 20 10, disable
  button "Reset", 23, 229 131 25 10
  button "Wipe", 24, 67 90 20 10, disable
  check "Auto get filters", 25, 10 131 49 10
}

;--dialog events
on *:dialog:dr_dev_spam_man:*:*: {
  var %dn = $dname, %dev = $devent, %f = $spamfiltdf
  var %htt = $+(%dn,.types), %hta = $+(%dn,.actions), %httm = $+(%dn,.temp)
  if (%dev == init) {
    dialog -t %dn Dragon Spamfilter Managment - $+([,$network,])
    mode $me
    ;-- Load filter target types
    if ($hget(%htt)) { hfree %htt }
    hmake %htt | hload -i %htt %f spf_types
    var %x = 1, %t = $hget(%htt,0).item
    while (%x <= %t) { did -a %dn 1 $hget(%htt,%x).item | inc %x }

    ;-- Load filter match actions
    var %x = 1, %t = $ini(%f,spf_actions,0)
    while (%x <= %t) { did -a %dn 2 $ini(%f,spf_actions,%x) | inc %x }

    ;-- get spamfilters
    if ($filtinir(spf_settings,stonst)) { did -c %dn 25 | gtspfltl }

  }

  elseif ((%dev == edit) || (%dev == mouse)) {
    if ($did == 1) { did -ra %dn 10 $filtinir(spf_help,type) }
    elseif ($did == 2) { did -ra %dn 10 $filtinir(spf_help,action) }
    elseif ($did == 3) { did -ra %dn 10 $filtinir(spf_help,time) }
    elseif ($did == 4) { did -ra %dn 10 $filtinir(spf_help,reason) | did -ra %dn 11 $did(%dn,$did).text }
    elseif ($did == 5) { did -ra %dn 10 $filtinir(spf_help,match) | did -ra %dn 11 $did(%dn,$did).text }
    elseif ($did == 25) { did -ra %dn 10 $filtinir(spf_help,onopen) }
    elseif ($did == 21) { echo -a $did(%dn,$did).text - did -ra %dn 10 $filtinir(spf_help,$did(%dn,$did).text) }
  }

  elseif (%dev == sclick) {
    ;--spamfilter target type selection
    if ($did == 1) {
      var %x = 1
      while (%x <= $did($dname,$did,0).sel) {
        var %t = $gettok($filtinir(spf_types,$did(%dn,1,$did(%dn,1,%x).sel)),1,9)
        var %td = $gettok($filtinir(spf_types,$did(%dn,1,$did(%dn,1,%x).sel)),2,9)
        var %fl = $+(%fl,%t), %tl = $addtok(%tl,%td,124)
        did -ra %dn 16 $tgfltsrt(%fl) | did -ra %dn 11 %tl
        inc %x
      }
    }
    ;--spamfilter match action selection
    elseif ($did == 2) { did -ra %dn 10 $filtinir(spf_actions,$did(%dn,$did).seltext) }
    ;--spamfilter selection
    elseif ($did == 6) {
      tokenize 32 $tmpspfltrs(spf_filters,$+(filter.,$did(%dn,$did).sel))
      var %dadd = did -ra %dn, %tlt = $prsfiltmds($1)
      did -e %dn 22 | %dadd 16 $1
      %dadd 5,11 $did(%dn,$did).seltext | %dadd 4 $usfltprs($6).from
      did -c %dn 2 $didwm(%dn,2,$2) | %dadd 3 $dodur($5)
      %dadd 10 Set by: $chr(9) $7 $crlf On: $chr(9) $asctime($calc($ctime - $4))
    }
    ;--close dialog
    elseif ($did == 13) { remini %f spf_filters | hfree -w $+(%dn,*) }
    ;--add spamfilter
    elseif ($did == 20) {
      var %errm
      if (!$did(%dn,5).text) {
        var %errm = $filtinir(spf_errors,match), %errinp = $input(%errm,oeh,ERROR - Match Filter Missing)
        did -ra %dn 10 ERROR: $str($crlf,2) %errm | did -ra %dn 5 %errinp | did -f %dn 5
      }
      elseif (!$did(%dn,16)) {
        var %errm = $filtinir(spf_errors,types), %errinp = $input(%errm,oh,ERROR - Target Type missing.)
        did -ra %dn 10 ERROR: $str($crlf,2) %errm | did -f %dn 1
      }
      elseif (!$did(%dn,2).seltext) {
        var %errm = $filtinir(spf_errors,action), %errinp = $input(%errm,oh,ERROR - Target Action missing.)
        did -ra %dn 10 ERROR: $str($crlf,2) %errm | did -f %dn 2
      }
      elseif (!$did(%dn,3)) {
        var %errm = $filtinir(spf_help,time), %errinp = $input(%errm,oeh,ERROR - Action Duration missing.,-)
        did -ra %dn 3 %errinp | did -f %dn 3
      }
      if (%errm != $null) { return }
      var %fgs = $$did(%dn,16), %act = $$did(%dn,2).seltext, %dur = $did(%dn,3)
      var %rea = $iif($usfltprs($did(%dn,4)),$v1,-), %mch = $$did(%dn,5).text
      var %rl = $read(%f,s,[spf_filters]), %rd = $read(%f,w,$+(filter.,*=,%fgs %act,*,%mch),$readn)
      if (%rd != $null) { writeini -n %f spf_filters $gettok(%rd,1,61) %fgs %act 0 0 $dodur(%dur) %rea $address($me,5) %mch }
      else { tmpspfltrs spf_filters %fgs %act 0 0 $dodur(%dur) %rea $address($me,5) %mch }
      spamfilter add -simple %fgs %act %dur %rea %mch | gtspfltl reload
    }
    ;--reload filter list
    elseif ($did == 21) { gtspfltl }
    ;--remove spamfilter
    elseif ($did == 22) {
      if ($input($filtinir(spf_errors,del),yq,Warning)) {
        tokenize 32 $tmpspfltrs(spf_filters,$+(filter.,$did(%dn,6).sel))
        spamfilter - $1-2 - - $$8 $9-
        remini %f spf_filters $+(filter.,$did(%dn,6).sel)
        gtspfltl reload
      }
    }
    ;--reset dialog
    else if ($did == 23) { did -ra %dn 3,4 - | did -r %dn 5,6,10,11,16 | did -u %dn 1-2 }
    ;--wipe all network filters
    elseif ($did == 24) {
      if ($input($filtinir(spf_errors,wipe),yw,!!!WARNING!!! - Wipe Spamfilters)) {
        hadd -m %httm wipe $true | gtspfltl
      }
    }
    elseif ($did == 25) { writeini -n %f spf_settings stonst $did(%dn,$did).state }
    else echo -a Did click: %dn $did
  }
}
;-- letter sort
alias tgfltsrt { return $remove($sorttokcs($regsubex($1,/(.)/g,\1 $+ $chr(32)),32),$chr(32)) }
;-- parse target filter letters [acdNnPpqtu]
alias prsfiltmds {
  var %x = 1, %dn = dr_dev_spam_man, %ht = $+(%dn,.types)
  var %t = $regsubex($1,/(.)/g,\1 $+ $chr(32)) | did -u %dn 1
  while (%x <= $numtok(%t,32)) {
    var %hd = $hfind(%ht,$+(/^,$gettok(%t,%x,32),.*/),1,r).data
    did -ck %dn 1 $didwm(%dn,1,%hd)
    inc %x
  }
}
;--parse underscores (_) in the filter reason.
alias usfltprs {
  if ($prop == from) { return $replacex($1-,__,_,_,$chr(32)) }
  else return $replacex($1-,_,__,$chr(32),_)
}
alias dodur {
  if ($1 isnum) { return $remove($replace($duration($1),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32)) }
  elseif ($regex($1,/(\d+)([a-z])/ig)) {
    var %x = 1, %t = $regml(0), %rtt
    while (%x <= %t) {
      var %d1 = $regml(%x), %d2 = $regml($calc(%x + 1)), %rt
      if (%d2 == m) { %rt = $calc(%d1 * 60) }
      elseif (%d2 == h) { %rt = $calc((%d1 * 60) * 60) }
      elseif (%d2 == d) { %rt = $calc(((%d1 * 60) * 60) * 24) }
      elseif (%d2 == w) { %rt = $calc((((%d1 * 60) * 60) * 24) * 7) }
      else { %rt = %d1 }
      var %rtt = $calc(%rt + %rtt)
      inc %x 2
    }
    return %rtt
  }
  return $1
}


Thanks in advance to any and/or all that help in either updating or re-writing this. I will make sure to note the help in my about script.

Joined: Aug 2006
Posts: 44
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Aug 2006
Posts: 44
I am willing to pay a fair price for the help

Joined: Aug 2006
Posts: 44
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Aug 2006
Posts: 44
Anyone know where I can pay to get help with this script, as no one here seems able or willing?


Link Copied to Clipboard