Spyder AntiSpam — File Browser

SpyderAntiSpamv1.09 / SpyderAntiSpamv1.09 / Spyder AntiSpam / antispam.mrc

antispam.mrc — 11.27 KB — Download this file

; Spyder AntiSpam v1.09
; Author: Hage Yaapa
; E-mail: spyderwares@yahoo.com
; Date: 04/02/2006
; Copyright © Hage Yaapa

; -- About --
dialog spas.about {
  title "About Spyder AntiSpam"
  size -1 -1 250 100
  icon $shortfn($scriptdirsystem\icon.ico)
  text "Info", 1, 24 14 200 60, center
  ; link "http://", 2, 67 75 120 25 
}

on *:dialog:spas.about:init:0: {
  did -ra $dname 1 Spyder AntiSpam v1.09 $crlf $crlf By Hage Yaapa $crlf Copyright © Hage Yaapa
}

on *:dialog:spas.about:sclick:*: {
  dialog -x $dname
  dialog -v spas.dialog
  ;if ($did == 2) { run 'website_url' | return }
}

; ----------


menu status,channel {
  Spyder AntiSpam: spas.dialog
}

alias spas.dialog {
  if ($dialog(spas.dialog)) {
    dialog -v spas.dialog
  }
  else {
    dialog -md spas.dialog spas.dialog
  }
}

dialog spas.dialog {
  title "Spyder AntiSpam"
  size -1 -1 290 220
  icon $shortfn($scriptdirsystem\icon.ico)
  menu "File", 1
  item "Disable", 2, 1
  item "Enable", 3, 1
  item "break", 4, 1
  item "Unload", 5, 1
  item "break", 6, 1
  item "Close", 7, 1, ok

  menu "Options", 8
  item "Silent Mode", 9, 8
  item "Verbose Mode", 10, 8

  menu "Help", 11
  item "ReadMe", 12, 11
  item "Help File", 13, 11
  ; item "Website", 14, 11
  item "break", 15, 11
  item "About", 16, 11

  tab "Status", 17, 1 2 288 171
  tab "Exceptions", 18
  tab "Keywords", 19
  tab "Time", 20

  text "Status", 21, 30 45 190 70
  text "No. of spammers swatted: ", 22, 30 126 127 14
  text "00000000", 23, 159 126 100 14


  list 24, 10 35 120 120, sort, size, hsbar
  edit "", 25, 153 53 110 23, autohs, limit 12
  button "Add", 26, 177 83 58 23
  button "Remove", 27, 177 113 58 23


  text "Warning Period:", 28, 60 53 80 25
  edit "", 29, 145 50 50 20
  text "secs.", 30, 205 53 30 20

  text "Ignore Duration:", 31, 60 78 80 25
  edit "", 32, 145 76 50 20
  text "secs.", 33, 205 78 40 20

  button "Apply", 34, 81 115 55 23
  button "Reset", 35, 147 115 55 23


  button "Close", 100, 113 183 60 25

}

alias spas.hideStatus { did -h $dname 21,22,23 }
alias spas.showStatus { did -v $dname 21,22,23 }
alias spas.hideList { did -h $dname 24,25,26,27 }
alias spas.showList { did -v $dname 24,25,26,27 }
alias spas.hideTime { did -h $dname 28,29,30,31,32,33,34,35 }
alias spas.showTime { did -v $dname 28,29,30,31,32,33,34,35 }

on *:connect: {
  set %sp.as.n 0
}

on *:dialog:spas.dialog:init:0: {
  spas.hideTime
  spas.hideList
  spas.displayStatus
  if (%sp.as.status == ENABLED) { did -c $dname 3 }
  if (%sp.as.status == DISABLED) { did -c $dname 2 }
  if (%sp.as.s) { did -c $dname 9 }
  if (%sp.as.v) { did -c $dname 10 }
  did -ra $dname 23 %sp.as.n
}

alias spas.displayStatus {
  did -ra $dname 21 Spyder AntiSpam $iif(%sp.as.status == ENABLED, ENABLED., DISABLED.) $crlf $crlf $&
    Running in $iif(%sp.as.s == 1, Silent Mode., Verbose Mode.) $crlf $&
    Warning Period: %sp.as.p secs. $crlf $&
    Ignore Duration: %sp.as.d secs.
}


on *:dialog:spas.dialog:menu:2: { spas.disable | spas.displayStatus }
on *:dialog:spas.dialog:menu:3: { spas.enable | spas.displayStatus }
on *:dialog:spas.dialog:menu:12: { run $shortfn($scriptdirreadme.txt) }
on *:dialog:spas.dialog:menu:13: { run $shortfn($scriptdirhelp.htm) }
; on *:dialog:spas.dialog:menu:14: { run  }
on *:dialog:spas.dialog:menu:16: { if ($dialog(spas.about)) {
    dialog -v spas.about
  } 
  else { 
    var %i = $dialog(spas.about, spas.about) 
  }
}

on *:dialog:spas.dialog:menu:5: {
  if ($input(Are you sure you want to $crlf unload Spyder AntiSpam?,w,Confirmation) == $true) {
    dialog -x $dname
    .unload -rs $shortfn($script)
  }
  else { dialog -v $dname }
}

on *:dialog:spas.dialog:menu:9: {
  unset %sp.as.v
  set %sp.as.s 1
  did -c $dname 9
  did -u $dname 10
  spas.displayStatus
}

on *:dialog:spas.dialog:menu:10: {
  unset %sp.as.s
  set %sp.as.v 1
  did -c $dname 10
  did -u $dname 9
  spas.displayStatus
}


; Status tab
on *:dialog:spas.dialog:sclick:17: {
  spas.hideList
  spas.hideTime
  spas.showStatus
  spas.displayStatus
}

; Exceptions tab
on *:dialog:spas.dialog:sclick:18: {
  spas.hideStatus
  spas.hideTime
  spas.showList
  if (%spas.lists.k) { unset %spas.lists.k }
  set %spas.lists.e 1
  did -r $dname 24,25
  spas.displayList e $shortfn($scriptdirexceptions.txt)
}

; Keywords tab
on *:dialog:spas.dialog:sclick:19: {
  spas.hideStatus
  spas.hideTime
  spas.showList
  if (%spas.lists.e) { unset %spas.lists.e }
  set %spas.lists.k 1
  did -r $dname 24,25
  spas.displayList k $shortfn($scriptdirkeywords.txt)
}


; Time tab
on *:dialog:spas.dialog:sclick:20: {
  spas.hideStatus
  spas.hideList
  spas.showTime
  did -ra $dname 29 %sp.as.p
  did -ra $dname 32 %sp.as.d
}


; Apply time
on *:dialog:spas.dialog:sclick:34: {
  set %sp.as.p $did(29).text
  set %sp.as.d $did(32).text
}

; Reset time
on *:dialog:spas.dialog:sclick:35: {
  did -ra $dname 29 15
  did -ra $dname 32 60
  set %sp.as.p 15
  set %sp.as.d 60
}


; Close button 
on *:dialog:spas.dialog:sclick:100: {
  unset %spas.lists.*
  dialog -x $dname
}

on *:dialog:spas.dialog:close:*: {
  unset %spas.lists.*
}


; Add new entry
on *:dialog:spas.dialog:sclick:26: {

  ;// New Exception
  if (%spas.lists.e) {

    var %e = $did(25).text

    if ((%e == $null) || ($chr(32) isin %e)) {
      var %i = $input(Erroneous Nickname,o,Error)
      dialog -v $dname
    }
    else if ($sp.check($scriptdirexceptions.txt,%e) == 1) {
      var %i = $input(' $+ %e $+ ' already an Exception.,o,Error)
      did -r $dname 25
      dialog -v $dname
    }
    else {
      write -a $shortfn($scriptdirexceptions.txt) %e
      dialog -v $dname
      did -r $dname 24,25
      spas.displayList e $shortfn($scriptdirexceptions.txt)
    }

  }
  else {
    ;// New Keyword
    var %k = $did(25).text

    if (%k == $null) {
      var %i = $input(No Word Specified.,o,Error)
      dialog -v $dname
    }
    else if ($sp.check($scriptdirkeywords.txt,%k) == 1) {
      var %i = $input(' $+ %k $+ ' already a Keyword.,o,Error)
      did -r $dname 25
      dialog -v $dname
    }
    else {
      write -a $shortfn($scriptdirkeywords.txt) %k
      dialog -v $dname
      did -r $dname 24,25
      spas.displayList k $shortfn($scriptdirkeywords.txt)
    }

  }
}


; Remove entry
on *:dialog:spas.dialog:sclick:27: {

  ;// Exception
  if (%spas.lists.e) {

    var %e = $did(24).seltext

    if (%e == $null) {
      var %i = $input(No Nick selected.,o,Error)
      dialog -v $dname
      return
    }
    if ($input(Remove ' $+ %e $+ ' from Exceptions?,w,Confirmation) == $true) {
      write -ds $+ %e $shortfn($scriptdirexceptions.txt)
      dialog -v $dname
      did -r $dname 24,25
      spas.displayList e $shortfn($scriptdirexceptions.txt)
    }
    else {
      dialog -v $dname
      return
    }
  }


  ;// Keyword
  else {

    var %k = $did(24).seltext

    if (%k == $null) {
      var %i = $input(No word selected.,o,Error)
      dialog -v $dname
      return
    }    
    if ($input(Remove ' $+ %k $+ ' from Keywords?,w,Confirmation) == $true) {
      spas.rm %k
      dialog -v $dname
      did -r $dname 24,25
      spas.displayList k $shortfn($scriptdirkeywords.txt)
    }
    else { 
      dialog -v $dname
      return 
    }
  }

}

; Alias to remove Keyword entries (compatible with Keywords containing spaces also)
alias spas.rm {
  var %re = $chr(47) $+ $chr(94) $+ $1- $+ $chr(36) $+ $chr(47)
  var %i = 1
  while (%i <= $lines($shortfn($scriptdirkeywords.txt))) {
    var %r = $read($shortfn($scriptdirkeywords.txt), %i)
    if ($regex(%r,%re) == 1) { write -dl $+ %i $shortfn($scriptdirkeywords.txt) | return }
    inc %i
  }
}

;// Alias to display Exceptions or Keywords
alias spas.displayList {
  var %l $lines($2)
  if ($1 == e) {
    var %i 1
    while (%i <= %l) {
      did -a spas.dialog 24 $read($2,%i)
      inc %i
    }
  }
  else {
    var %i 1
    while (%i <= %l) {
      did -a spas.dialog 24 $read($2,%i)
      inc %i
    }
  }
}

alias spas.disable {
  set %sp.as.status DISABLED
  did -u $dname 3
  did -c $dname 2
}


alias spas.enable {
  set %sp.as.status ENABLED
  did -u $dname 2
  did -c $dname 3
}


on *:unload: {
  unset %sp.as.*
  unset %spas.lists.*
  echo -a - Spyder AntiSpam v1.09 Unloaded!
  echo -a - 
}

on *:load: {
  set %sp.as.p 15
  set %sp.as.d 60
  set %sp.as.status ENABLED
  set %sp.as.s 1
  set %sp.as.n 0
  echo -a - Spyder AntiSpam v1.09 Loaded!
  echo -a - RightClick to open it.
  echo -a - 
}


; ---- The Brain ---------------

alias -l sp.check {
  set %sp.c.f $shortfn($1)
  set %sp.c.l $lines(%sp.c.f)
  while (%sp.c.l > 0) {
    set %sp.c.c $read(%sp.c.f,%sp.c.l)
    if ((%sp.c.c == $2) || (%sp.c.c isin $2)) {
      unset %sp.c.*
      return 1
    }
    dec %sp.c.l
  }
  unset %sp.c.*
  return 0
}

on ^*:open:?:*: {
  if ((%sp.as.status == DISABLED) || ($sp.check($scriptdirexceptions.txt,$nick) == 1)) { return }
  else {
    var %i = $strip($1-,burc)
    if ((www. isin %i) || (http: isin %i) || ($chr(35) isin %i) || ($sp.check($scriptdirkeywords.txt,%i) == 1)) {
      if (% [ $+ [ $nick ] $+ ] .stat == 1) sp.ignore
      else if (% [ $+ [ $nick ] $+ ] .stat == i) sp.ignore
      else {
        set % [ $+ [ $nick ] $+ ] .stat 1
        .timer 1 %sp.as.p unset % [ $+ [ $nick ] $+ ] .stat
        sp.spam open
      }
      .timer 1 %sp.as.p unset % [ $+ [ $nick ] $+ ] .stat
      ;haltdef
    }
    else {
      set % [ $+ [ $nick ] $+ ] .stat o
      .timer 1 %sp.as.p unset % [ $+ [ $nick ] $+ ] .stat
    }
  }
}

on *:text:*:?: {
  if ((%sp.as.status == DISABLED) || ($sp.check($scriptdirexceptions.txt,$nick) == 1)) { return }
  else { 
    var %i = $strip($1-,burc)
    var %sp.stat % [ $+ [ $nick ] $+ ] .stat
    if ((www. isin %i) || (http: isin %i) || ($sp.check($scriptdirkeywords.txt,%i) == 1)) {
      if (%sp.stat == o) {
        set % [ $+ [ $nick ] $+ ] .stat i
        sp.spam text
      } 
    }
  }
}

on *:action:*:?: {
  if ((%sp.as.status == DISABLED) || ($sp.check($scriptdirexceptions.txt,$nick) == 1)) { return }
  else { 
    var %i = $strip($1-,burc)
    if ((www. isin %i) || (http: isin %i) || ($sp.check($scriptdirkeywords.txt,%i) == 1)) {
      sp.spam action
    }
  }
}

on ^*:notice:*:?: {
  if ((%sp.as.status == DISABLED) || ($sp.check($scriptdirexceptions.txt,$nick) == 1)) { return }
  else { 
    var %i = $strip($1-,burc)
    if ((www. isin %i) || (http: isin %i) || ($sp.check($scriptdirkeywords.txt,%i) == 1)) {
      sp.spam notice
      haltdef
    }
  }
}


alias -l sp.ignore {
  .ignore $nick
  window -c $nick
  unset % [ $+ [ $nick ] $+ ] .stat
  .timer 1 %sp.as.d .ignore -r $nick
  if (%sp.as.v) {
    echo -a - 4Spyder AntiSpam:14 Ignoring $nick for %sp.as.d seconds!
    echo -a -
  }
}

;// This alias will recieve $1 as "open" "text" "notice" or "action"

alias -l sp.spam {
  inc %sp.as.n
  if ($dialog(spas.dialog)) { did -ra spas.dialog 23 %sp.as.n }
  if (($1 == text) || ($1 == action)) { window -c $nick }
  if (%sp.as.v) {
    echo -a - 4Spyder AntiSpam:14 $nick swatted!
    echo -a - 
  }
  if ($1 == open) { halt }
}


; ----