NO /ame script

By krimson on Jun 21, 2006

Features:

- Multi server /ame's (using -m switch)<br />
- Force sending of /ame's no matter if the channels are<br />
  in the exclude list or not (using -f switch)<br />
- Can exclude entire networks<br />
- Can exclude channels globaly, or only at network level<br />
- Complex dialog to add/remove channels and networks (via /noame)<br /><br />

I'll leave it up to you to find the rest of the features :P<br />
on 1:START:{
  hmake noame.exclude 20
  if ($findfile($mircdir\noame,exclude.hash,1)) { 
    hload noame.exclude noame\exclude.hash
  }
  else {
    hsave noame.exclude noame\exclude.hash
  }
}
on 1:UNLOAD:{
  hfree noame.exclude
}
alias ame {
  if ($1- == $null) || ($1- == $chr(45)) { echo * /ame: insufficient parameters | return }
  var %noame.force = 0
  var %noame.multi = 0
  if ($regex($$1,-[fm])) {
    if (*f* iswm $$1) { var %noame.force = 1 } 
    if (*m* iswm $$1) { var %noame.multi = 1 }    
  }
  var %text = $regsubex($1-,-[fm][fm]|-[fm],$chr(0))
  if (%noame.multi) {
    var %x = 1
    while $scon(%x) {
      var %y = $ifmatch, %z = 1
      scid %y
      while $chan(%z) {
        if (%noame.force) { describe $chan(%z) %text }
        elseif (!$istok($hget(noame.exclude,NETWORKS),$network,44) && !$istok($hget(noame.exclude,GLOBAL),$chan(%z),44) && !$istok($hget(noame.exclude,$network),$chan(%z),44)) { describe $chan(%z) %text }
        inc %z
      }
      inc %x
    }
    scid -r
  }
  elseif (%noame.force == 1) { !ame $2- }
  else {
    var %i = 1 
    while ($chan(%i)) { 
      if (!$istok($hget(noame.exclude,GLOBAL),$chan(%i),44) && !$istok($hget(noame.exclude,$network),$chan(%z),44) ) { 
        describe $chan(%i) %text 
      } 
      inc %i 
    } 
  }
}

alias noame.savehash {
  if (!$finddir($mircdir,noame,1)) { mkdir noame }
  hsave noame.exclude noame/exclude.hash
} 
alias noame.addexclude { 
  var %name = $$1
  var %item = $$2
  hadd noame.exclude %name $addtok($hget(noame.exclude,%name),%item,44)
  noame.savehash
} 
alias noame.remexclude { 
  var %name = $$1
  var %item = $$2
  hadd noame.exclude %name $remtok($hget(noame.exclude,%name),%item,1,44) 
  if ($hget(noame.exclude,%name) == $null) { hdel noame.exclude %name }
  noame.savehash
}
alias noame.clearitem {
  var %name = $$1
  hdel noame.exclude %name
  noame.savehash
}

dialog noame {
  title "NO /ame script"
  size -1 -1 235 149
  option dbu
  tab "Channels", 1, 2 1 230 129
  box "Channel Exclude List", 6, 5 16 111 112, tab 1
  list 7, 9 24 104 61, tab 1 sort size vsbar
  box "Add Channel Exclusion", 8, 118 16 111 69, tab 1
  box "Remove Channel Exclusion", 9, 118 85 111 43, tab 1
  text "Here is the list with all the channels that are skipped when performing an /ame. You can bypass this setting by using /ame with the -f switch.", 10, 9 86 104 28, tab 1
  edit "", 11, 168 25 58 11, tab 1
  button "Add", 12, 189 68 37 12, tab 1
  text "Channel:", 13, 124 27 40 7, tab 1 center
  text "Network:", 16, 124 39 40 7, tab 1 center
  button "Remove", 14, 189 111 37 12, disable tab 1
  edit "", 31, 168 36 58 11, tab 1
  text "Example: /ame -f this goes to all channels", 32, 11 116 100 9, tab 1
  text "Add excluded channel:", 33, 124 49 66 8, tab 1
  text "Skip channel when doing /ame's", 34, 125 57 61 15, tab 1
  text "Remove excluded channel:", 35, 124 96 66 8, tab 1
  text "Remove a channel from the exclude list", 36, 125 104 61 15, tab 1
  tab "Networks", 2
  box "Network Exclude List", 17, 5 16 111 112, tab 2
  list 18, 9 24 104 61, tab 2 sort size vsbar
  text "Here is the list with all the networks that are skipped when performing a multi-server /ame. You can bypass this setting by using /ame with the -m switch.", 19, 9 86 104 28, tab 2
  box "Add Network Exclusion", 15, 118 16 111 69, tab 2
  box "Remove Network Exclusion", 20, 118 85 111 43, tab 2
  button "Remove", 21, 189 111 37 12, disable tab 2
  button "Add", 22, 189 68 37 12, tab 2
  text "Network:", 24, 124 27 40 7, tab 2 center
  edit "", 23, 168 25 58 11, tab 2
  text "Skip network when doing multi-server /ame's", 27, 125 57 61 15, tab 2
  text "Add excluded network:", 28, 124 49 66 8, tab 2
  text "Remove excluded network:", 29, 124 96 66 8, tab 2
  text "Remove a network from the exclude list", 30, 125 104 61 15, tab 2
  text "Example: /ame -m this goes to all networks", 37, 9 116 103 9, tab 2
  button "Close", 5, 195 134 37 12, ok cancel
}

alias noame { 
  $dialog(noame,noame) 
}

alias noame.refresh {
  did -r noame 7
  did -r noame 18
  didtok noame 7 44 $noame.getinfo(GLOBAL)
  var %i = 1
  while ($hfind(noame.exclude,*,%i,w)) {
    if ($hfind(noame.exclude,*,%i,w) != GLOBAL && $hfind(noame.exclude,*,%i,w) != NETWORKS) {
      didtok noame 7 44 $noame.getinfo($hfind(noame.exclude,*,%i,w))
    }
    inc %i
  }
  didtok noame 18 44 $hget(noame.exclude,NETWORKS)
}

alias noame.getinfo {
  var %text = $hget(noame.exclude,$$1)
  var %output = $chr(0)
  while ($numtok(%text,44)) {
    var %output = $addtok(%output,$addtok($gettok(%text,1,44),$+($chr(40),$hfind(noame.exclude,$$1),$chr(41)),32),44)
    var %text = $deltok(%text,1,44)
  }
  return %output
}

on 1:DIALOG:noame:*:*:{
  if ($devent == init) { noame.refresh }
  elseif ($devent == sclick) {
    if ($did == 7) { did -e noame 14 }
    elseif ($did == 18) { did -e noame 21 }
    elseif ($did == 14) { 
      noame.remexclude $left($right($gettok($did(7).seltext,2,32),-1),-1) $gettok($did(7).seltext,1,32) 
      noame.refresh
    }
    elseif ($did == 12) {
      if ($did(noame,11) != NETWORKS && #* iswm $did(noame,11)) { var %chan = $did(noame,11).text }
      if ($did(noame,31).text == $null) { var %network = GLOBAL }
      else { var %network = $did(noame,31).text }
      if (%chan) { 
        noame.addexclude %network %chan 
        did -r noame 11
        did -r noame 31
        noame.refresh
      }
    }
    elseif ($did == 21) { 
      noame.remexclude NETWORKS $did(18).seltext 
      noame.refresh
    }
    elseif ($did == 22) {
      if ($did(noame,23).text != $null && #* !iswm $did(noame,23).text) {
        noame.addexclude NETWORKS $did(noame,23).text
        did -r noame 23
        noame.refresh
      }
    }
  }
}

Comments

Sign in to comment.
xplo   -  Aug 21, 2008

too complicated for nothing.

alias ame { 
  var %i = 1 
  while ($chan(%i)) { 
    if (!$istok(%exclude,$chan(%i),44)) { 
      describe $chan(%i) $1- 
    } 
    inc %i 
  } 
} 
alias addchan { 
  set %exclude $addtok(%exclude,$1,44) 
} 
alias delchan { 
  set %exclude $remtok(%exclude,$1,1,44) 
}
alias noame { $dialog(ame_dialog,ame_dialog) } 
dialog ame_dialog { 
  title "Anti /ame script" 
  size -1 -1 167 69 
  option dbu 
  list 1, 2 13 69 53, sort size vsbar 
  text "Channels currently added:", 3, 2 4 68 8, center 
  button "Exit", 2, 125 53 37 12, ok 
  button "Add", 4, 125 10 37 12 
  text "Add a channel to the current list", 5, 77 8 46 15, center 
  button "Remove", 6, 125 30 37 12 
  text "Remove a channel from the current list", 7, 77 26 46 21, center 
  box "Channels", 8, 74 1 90 48 
} 
on 1:DIALOG:ame_dialog:init:0:{ 
  didtok ame_dialog 1 44 %exclude 
} 
on 1:DIALOG:ame_dialog:sclick:4:{ 
  addchan $?="Insert a channel" 
  did -r ame_dialog 1 
  didtok ame_dialog 1 44 %exclude 
} 
on 1:DIALOG:ame_dialog:sclick:6:{ 
  delchan $did(1).seltext 
  did -r ame_dialog 1 
  didtok ame_dialog 1 44 %exclude 
}

menu channel {
  Channel Restricted /ame:/noame
}

doing the same thing ;)
enjoy

 Respond  
Rage   -  Aug 09, 2006

Very Clean, I had no errors. No problems.

 Respond  
Puppy_Love   -  Jun 22, 2006

Nice one mate :)

How did you get \" Reviewer Score \" ?

-- Once again, well done :)

~ Puppy

 Respond  
krimson   -  Jun 21, 2006

I am interested in any feedback, as long as it\'s at least a little bit constructive :)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.