All pastes #636828 Raw Edit

Miscellany

public text v1 · immutable
#636828 ·published 2007-07-28 07:48 UTC
rendered paste body
;;##START SCRIPT##;;

;;##CID START##;;

on *:START:/scid $activecid | .timersweep 0 $calc($readini(settings.ini,settings,sweepmins) * 300) /xsweep

;;##DIALOG##;;

dialog -l o {
  title "Bebop's Black List"
  size -1 -1 226 107
  option dbu
  icon black.ico, 0
  list 1, 2 3 56 102, sort size extsel
  edit "", 2, 60 87 164 19, read multi
  button "+", 3, 61 5 20 20
  button "-", 4, 61 25 20 20
  button "Edit", 5, 61 45 20 20
  button "Clear", 6, 61 65 20 20
  radio "Ban and Kick", 7, 91 10 51 10, left
  radio "Ban", 8, 91 19 51 10, left
  radio "Kick", 9, 91 29 51 10, left
  box "Options", 10, 84 3 60 83
  radio "Kill", 11, 91 39 51 10, left
  box "Do not Enforce on Channels...", 12, 145 3 78 83
  text "Every", 14, 90 60 16 8
  edit "", 15, 107 59 16 10
  text "mins", 16, 124 60 12 8
  list 17, 148 11 50 72, sort size extsel
  button "+", 18, 201 11 18 18
  button "-", 19, 201 29 18 18
  button "Edit", 20, 201 47 18 18
  button "Clear", 21, 201 65 18 18
  check "Alert Me", 22, 90 69 52 10, left
  check "Sweep Regularly", 13, 91 48 51 10, left
}

;;##DIALOG INIT##;;

on *:Dialog:o:init:0: { dialog.init }

;;##DIALOG SCLICKS##;;

on *:Dialog:o:sclick:*: {
  If ($did = 1) { did -ra o 2 $reason($did(1).seltext) }
  If ($did = 3) {
    %add = $input(Nickname to Add?,idegvua)
    If ($$read(list.txt,w,%add $+ *)) || (!%add) { goto end }
    %reason = $input(Reason? (Optional),idegvua)
    write list.txt %add $iif(%reason,%reason,Black Listed.)
    did -a o 1 %add
    did -e o 4,5,6
    xsweep
  }
  :end
  If ($did = 4) {
    If (!$did(1).seltext) { halt }
    %i = 0
    While ($did(o,1,$did(o,1,%i).sel)) {
      write -ds $+ $did(o,1,$did(o,1,%i).sel) list.txt
      did -d o 1 $did(o,1,%i).sel
      inc %i
    }
    dec %i
    If ($did(o,1,%i).sel) { did -d o 1 $did(o,1,%i).sel }
    did -r o 2
    If ($lines(list.txt) = 0) { did -b o 4,5,6 }
  }
  If ($did = 5) {
    If (!$did(1).seltext) { halt }
    %edit = $input(,idegvua,,$did(2))
    write -ds $+ $did(1).seltext list.txt
    write list.txt $did(1).seltext %edit
    did -ra o 2 %edit
    unset %edit
  }
  If ($did = 6) {
    %Y/N = $input(Are you sure you wish to clear your Black List? It will be lost forever.,yvgdw)
    If (%Y/N = $no) { unset %Y/N | halt }
    If (%Y/N = $yes) {
      did -r o 1,2
      did -b o 4,5,6
      unset %Y/N
      write -c list.txt
    }
  }
  If ($istok(7.8.9.11,$did,46)) { writeini settings.ini settings enforce $replace($did,7,1,8,2,9,3,11,4) }
  If ($did = 13) { writeini settings.ini settings sweep $iif($readini(settings.ini,settings,sweep) = Y,N,Y) | .timerxsweep $iif($timer(xsweep),off,0 $calc($did(15) * 300) /xsweep) }
  If ($did = 22) { writeini settings.ini settings alert $iif($readini(settings.ini,settings,alert) = Y,N,Y) }
  If ($did = 18) {
    %add = $input(Channel to Add?,idegvua)
    If ($read(nochans.txt,w,%add)) || (!%add) || ($left(%add,1) != $chr(35)) { goto end.3 }
    write nochans.txt %add
    did -a o 17 %add
    did -e o 19,20,21
    :end.3
    unset %add
  }
  If ($did = 19) {
    If (!$did(17).seltext) { halt }
    %i = 0
    While ($did(o,17,$did(o,17,%i).sel)) {
      write -ds $+ $did(o,17,$did(o,17,%i).sel) nochans.txt
      did -d o 17 $did(o,17,%i).sel
      inc %i
    }
    dec %i
    If ($did(o,17,%i).sel) { did -d o 17 $did(o,17,%i).sel }
    If ($lines(nochans.txt) = 0) { did -b o 19,20,21 }
  }
  If ($did = 20) {
    If (!$did(17).seltext) { halt }
    %edit = $input(,idegvua,,$did(2))
    write -ds $+ $did(17).seltext nochans.txt
    write nochans.txt %edit
    did -d o 17 $did(o,17,1).sel
    did -a o 17 %edit
    unset %edit
  }
  If ($did = 21) {
    %Y/N = $input(Are you sure you wish to clear your Channel List? It will be lost forever.,yvgdw)
    If (%Y/N = $no) { unset %Y/N | halt }
    If (%Y/N = $yes) {
      did -r o 17
      did -b o 19,20,21
      unset %Y/N
      write -c nochans.txt
    }
  }
}

;;##DIALOG EDIT##;;

on *:Dialog:o:edit:15: { writeini settings.ini settings sweepmins $did(15) | .timerxsweep 0 $calc($did(15) * 300) /xsweep }

;;##EVENTS TO TRIGGER ON##;;

on *:JOIN:#: { xsweep # }
on *:NICK: { xsweep }
on *:RAWMODE:#: { If ($nick != $me) { xsweep # } }

;;##ALIASES##;;

alias F6 dialog $iif($dialog(o),-x,-m) o o

alias xsweep {
  halt
  If ($status = connected) {
    If ($1) {
      %i = 1
      While ($nick($1,%i)) {
        If ($fopen(q)) .fclose q
        .fopen q list.txt
        While (!$feof) && (!$ferr) {
        }
      }
    }
  }
  unset %t %x %i %kickedpeople
}

alias -l dialog.init {
  If ($lines(list.txt) = 0) { did -b o 4,5,6 | goto end }
  %i = 1
  If ($fopen(q)) .fclose q
  .fopen q list.txt
  While (!$feof) && (!$ferr) { did -a o 1 $fread(q) }
  .fclose q
  :end
  If ($lines(nochans.txt) = 0) { did -b o 19,20,21 | goto end.2 }
  If ($fopen(q)) { .fclose q }
  .fopen q nochans.txt
  While (!$ferr) && (!$feof) { did -a o 17 $fread(q) }
  .fclose q
  :end.2
  %t = $replace($readini(settings.ini,settings,enforce),1,7,2,8,3,9,4,11)
  did -c o %t
  unset %t
  did -a o 15 $readini(settings.ini,settings,sweepmins)
  If ($readini(settings.ini,settings,sweep) = Y) { did -c o 13 | .timerxsweep 0 $calc($readini(settings.ini,settings,sweepmins) * 300) /xsweep }
  If ($readini(settings.ini,settings,alert) = Y) { did -c o 22 }
}

alias -l reason return $gettok($read(list.txt,w,$1 $+ *),2-,32)