All pastes #996246 Raw Edit

channel controls

public text v1 · immutable
#996246 ·published 2008-04-24 20:23 UTC
rendered paste body
on *:load: {
  scid -a .msg chanserv owner 
  scid -a .msg chanserv protect 
}
menu channel,menubar {
  Open channel controls: {
    if ($dialog(ChanControl)) dialog -x ChanControl
    dialog -m ChanControl ChanControl
  }
}
dialog ChanControl {
  title "Channel Controls"
  size -1 -1 170 222
  option dbu
  tab "Channel Modes", 1, 0 0 168 200
  check "Invite Only", 2, 5 18 50 10, tab 1
  check "Moderated", 3, 5 28 50 10, tab 1
  check "No external messges", 4, 5 38 63 10, tab 1
  check "Private", 5, 5 48 50 10, tab 1
  check "Secret", 6, 5 58 50 10, tab 1
  check "Topic lock", 7, 5 68 50 10, tab 1
  check "SSL connections only", 8, 5 78 65 10, tab 1
  check "Block CTCP's", 9, 5 88 50 10, tab 1
  check "Block Channel Notices", 10, 5 98 66 10, tab 1
  check "Filter Badwords", 11, 5 108 50 10, tab 1
  check "Only registered users may talk", 12, 75 18 88 10, tab 1
  check "Disable /KNOCK", 13, 75 28 50 10, tab 1
  check "No nick changes", 14, 75 38 50 10, tab 1
  check "No kicks allowed", 15, 75 48 50 10, tab 1
  check "Only registered nicks may join", 16, 75 58 85 10, tab 1
  check "Strip Colours", 17, 75 68 50 10, tab 1
  check "No inites", 18, 75 78 50 10, tab 1
  check "Block Colour", 19, 75 88 50 10, tab 1
  check "Auditorium mode", 20, 75 98 50 10, tab 1
  check "Password Protected", 21, 5 118 60 10, tab 1
  edit "", 22, 65 118 50 10, tab 1
  check "User Limit", 23, 5 130 36 10, tab 1
  edit "", 24, 41 130 20 10, tab 1
  check "Linked Channel", 25, 5 142 48 10, tab 1
  edit "", 26, 53 142 50 10, tab 1
  check "Throttle Joins", 27, 5 154 43 10, tab 1
  edit "", 28, 49 154 14 10, tab 1
  text "Joins/", 29, 64 155 16 8, tab 1
  edit "", 30, 79 154 18 10, tab 1
  text "Seconds", 31, 98 155 25 8, tab 1
  edit "", 32, 6 170 153 28, disable tab 1 multi
  button "Change Key", 109, 127 118 37 12, tab 1
  button "Change Limit", 110, 127 130 37 12, tab 1
  button "Change Link", 111, 127 142 37 12, tab 1
  button "Change Joins", 112, 127 154 37 12, tab 1
  tab "Flood Protect", 33
  check "Enabled", 34, 8 37 33 10, tab 33
  edit "", 35, 42 37 17 10, tab 33
  combo 36, 42 49 25 10, tab 33 drop
  edit "", 37, 42 61 17 10, tab 33
  text "Action:", 40, 21 50 20 8, tab 33 right
  box "Nick Change", 41, 5 125 71 42, tab 33
  check "Enabled", 42, 8 132 31 10, tab 33
  edit "", 44, 42 132 17 10, tab 33
  edit "", 45, 42 154 17 10, tab 33
  text "Action:", 48, 20 144 21 8, tab 33 right
  text "Action:", 49, 107 144 21 8, tab 33 right
  edit "", 50, 130 132 17 10, tab 33
  check "Enabled", 52, 95 132 33 10, tab 33
  edit "", 53, 130 154 17 10, tab 33
  box "Knocks", 56, 92 125 71 42, tab 33
  check "Enabled", 57, 95 37 32 10, tab 33
  box "CTCP's", 58, 5 31 71 42, tab 33
  text "Action:", 59, 21 96 20 8, tab 33 right
  edit "", 60, 42 83 17 10, tab 33
  check "Enabled", 61, 8 84 33 10, tab 33
  combo 64, 42 95 25 10, tab 33 drop
  box "Text", 66, 5 77 71 43, tab 33
  check "Enabled", 67, 95 84 33 10, tab 33
  edit "", 68, 130 107 17 10, tab 33
  edit "", 71, 130 83 17 10, tab 33
  text "Action:", 72, 108 96 21 8, tab 33 right
  combo 73, 130 95 25 10, tab 33 drop
  box "Messages", 74, 92 77 71 43, tab 33
  box "Joins", 75, 92 31 71 42, tab 33
  combo 76, 130 49 25 10, tab 33 drop
  text "Action:", 77, 108 50 21 8, tab 33 right
  edit "", 78, 129 37 17 10, tab 33
  edit "", 80, 130 61 17 10, tab 33
  edit "", 82, 54 18 17 10, tab 33
  text "Time (in seconds):", 83, 6 19 46 8, tab 33
  edit "", 84, 5 170 158 27, disable tab 33 multi
  text "Time:", 38, 21 62 20 8, tab 33 right
  text "Time:", 39, 107 62 22 8, tab 33 right
  text "Time:", 46, 108 108 21 8, tab 33 right
  text "Time:", 51, 21 155 19 8, tab 33 right
  text "Time:", 54, 106 155 22 8, tab 33 right
  button "Update Flood Controls", 62, 92 17 70 12, tab 33
  text "+N", 47, 43 144 13 8, tab 33
  text "+K", 55, 131 144 11 8, tab 33
  tab "User Controls", 85
  list 86, 99 18 65 141, tab 85 size vsbar
  button "Kick ", 87, 6 23 29 12, tab 85
  button "Ban", 88, 35 23 29 12, tab 85
  button "Unban", 89, 64 35 29 12, tab 85
  button "Add Except", 91, 6 88 43 12, tab 85
  button "Delete Except", 92, 6 100 43 12, tab 85
  button "Add Invite", 93, 49 88 43 12, tab 85
  button "Delete Invite", 94, 49 100 43 12, tab 85
  edit "", 95, 4 162 161 35, disable tab 85 multi
  button "Deop", 96, 6 66 29 12, tab 85
  button "Op", 97, 6 54 29 12, tab 85
  button "Halfop", 98, 35 54 29 12, tab 85
  button "Dehalfop", 99, 35 66 29 12, tab 85
  button "Voice", 100, 64 54 29 12, tab 85
  button "Devoice", 101, 64 66 29 12, tab 85
  button "Unmute", 102, 35 35 29 12, tab 85
  button "Mute", 103, 6 35 29 12, tab 85
  button "Notice", 63, 6 120 43 12, tab 85
  button "Timed Ban", 43, 64 23 29 12, tab 85
  button "Query", 65, 49 120 43 12, tab 85
  combo 69, 7 147 84 10, tab 85 drop
  text "Select default host mask", 105, 8 138 69 8, tab 85
  button "Close", 108, 129 204 37 15, ok
  box "Actions", 90, 4 16 93 143, tab 85
}
on *:dialog:ChanControl:init:*: {
  if ($active !ischan) { 
    dialog -x ChanControl
    echo 4 -a ERROR: The channel control dialog is only avaliable from a channel
    halt 
  }
  set %ChanControl.Chan $active
  who %ChanControl.Chan

  getmodes %ChanControl.Chan
  dialog -t $dname Channel controls for %ChanControl.Chan

  ; Disable input boxes. These are set through buttons
  did -b $dname 22,24,26,28,30

  ; Check which control set should be used
  var %netchan = $+($network,.,%ChanControl.Chan)
  if ($hget(Owner,%netchan)) founderAccess
  elseif ($hget(admin,%netchan)) adminAccess
  elseif ($me isop %ChanControl.Chan) opAccess
  elseif ($me ishelp %ChanControl.Chan) halfopAccess
  else noAccess

  ; Populate +f drop down options
  did -ca $dname 36 +C
  did -a $dname 36 +m
  did -a $dname 36 +M
  did -ca $dname 76 +i
  did -a $dname 76 +R
  did -ca $dname 64 kick
  did -a $dname 64 ban
  did -ca $dname 73 +m
  did -a $dname 73 +M

  RefreshUserslist

  ; Populate host mask list
  var %x = 1, %masks = 9 
  while (%x <= %masks) {
    did -a $dname 69 $address($me,%x)
    inc %x
  }
  if (%ChanControl.mask) did -c ChanControl 69 %ChanControl.mask
}
on *:dialog:ChanControl:mouse:*: {
  ; *********************************
  ; * Tab 1 - Channel modes         *
  ; *********************************
  if ($did == 2) var %msg = If the channel is invite only users may only join if they are invited by someone already in the channel
  elseif ($did == 3) var %msg = If the channel is moderated only users with voice or higher will be able to talk
  elseif ($did == 4) var %msg = This is set by default, if unset people will be able to message the channel without actually being in it
  elseif ($did == 5) var %msg = Being set to private means that a user needs to knock in order to gain access. [/knock #CHANNEL MESSAGE]
  elseif ($did == 6) var %msg = Secret channels do not appear in the channel list or in whois messages.
  elseif ($did == 7) var %msg = This is set by default, if unset anybody is able to change the topic, instead of being restricted to halfops and above
  elseif ($did == 8) var %msg = This mode is rarely used and will only allow users to join if they are using a secure socket layer connection
  elseif ($did == 9) var %msg = Stops CTCP's from being able to be sent to the channel
  elseif ($did == 10) var %msg = Stops Notices from being able to be sent to the channel
  elseif ($did == 11) var %msg = Causes common swear words to be replaced with <CENSORED>
  elseif ($did == 12) var %msg = If this is set users who have not registered their nicks will be unble to talk
  elseif ($did == 13) var %msg = Stops users being able to knock on the channel. (IE request invite to invite only channels, or private channels)
  elseif ($did == 14) var %msg = Stops users from being able to change their nicks while in the channel
  elseif ($did == 15) var %msg = Stops ops and halfops from being able to kick, does not affect the founder
  elseif ($did == 16) var %msg = If this is set only users who have registered their nicks will be able to join the channel
  elseif ($did == 17) var %msg = This strips colours from any messages sent to the channel
  elseif ($did == 18) var %msg = This option stops users being able to invite others into the channel
  elseif ($did == 19) var %msg = Blocks colour codes, any message that has colour codes in it will not be sent to the channel
  elseif ($did == 20) var %msg = hides all non ops from the users list
  elseif ($did == 21) var %msg = Users must enter a password to join the channel [/join #CHANNEL PASSWORD]. Enter the password in the box provided
  elseif ($did == 23) var %msg = Sets a user limit on the channel, if the limit is reached no users will be able to join. Enter the limit in the box provided
  elseif ($did == 25) var %msg = This sets a linked channel and works with the channel limit. If the limit is reached users will instead be sent to the linked channel. Enter the linked channel in the box provided
  elseif ($did == 27) var %msg = This option provides some protection against join floods. If a user joins more then the specified number of times in the set number of seconds they will be banned.
  elseif ($did == 109) var %msg = Click here to change the channel key
  elseif ($did == 110) var %msg = Click here to change the channel limit
  elseif ($did == 111) var %msg = Click here to change the linked channel
  elseif ($did == 112) var %msg = Click here to change the join throttle paramaters
  if (%msg) did -ra $dname 32 %msg 
  unset %msg
  ; *********************************
  ; * Tab 2 - flood control         *
  ; *********************************
  if ($did == 82) || ($did == 83) var %msg = The time (in seconds) that the amount of messages specified for each control must occur in to trigger flood protection
  elseif ($did == 62) var %msg = Update flood control settings, to prevent mode setting spam in the channel while deciding on options, flood control is set all at once when you click here  
  elseif ($mouse.x isnum 14-151) && ($mouse.y isnum 68-146) var %msg = CTCP flood options. The actions for this option are: +C: Blocks channel CTCP's, +m: Mutes the channel, +M: allows only registered nicks to speak
  elseif ($mouse.x isnum 187-324) && ($mouse.y isnum 68-146) var %msg = Join flood options. The actions for this option are: +i: Sets the channel to invite only, +R: only allows registered nicks to join
  elseif ($mouse.x isnum 14-151) && ($mouse.y isnum 162-240) var %msg = Text (for the entire channel) flood options. The only avaliable option here is setting +k to prevent knocks
  elseif ($mouse.x isnum 187-324) && ($mouse.y isnum 162-240) var %msg = Message (per nick) flood options. The actions for this option are: +m: Mute the channel, +M: Allows only registered nicks to speak
  elseif ($mouse.x isnum 14-151) && ($mouse.y isnum 257-334) var %msg = Nick Change flood options. The only avaliable option here is setting +N to block nick changes
  elseif ($mouse.x isnum 187-324) && ($mouse.y isnum 257-334) var %msg = Knock flood options. The actions for this option are: kick: Kick the flooder, b: ban the flooder
  else var %msg =  For each enabled flood control section, the action specified will be performed by the set time for that section, if the limit (top input box) for that section is exceeded
  if (%msg) did -ra $dname 84 %msg
  unset %msg 
  ; *********************************
  ; * Tab 3 - user controls         *
  ; *********************************
  if ($did == 87) var %msg = Kick the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) from the room. $crlf $+ NOTE: may not work if user has higher access then yourself
  elseif ($did == 88) var %msg = Kick and ban the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) $crlf $+ NOTE: may not work if user has higher access then yourself
  elseif ($did == 90)  var %msg = Ban the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) for a set time $crlf $+ NOTE: may not work if user has higher access then yourself
  elseif ($did == 103) var %msg = Mute the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) without kicking them $crlf $+ NOTE: may not work if user has higher access then yourself
  elseif ($did == 102) var %msg = Unmute the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) 
  elseif ($did == 89) var %msg = View the banlist to remove a ban.
  elseif ($did == 97) var %msg = Give the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) op status
  elseif ($did == 96) var %msg = Remove op access from the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41)))
  elseif ($did == 98) var %msg = Give the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) halfop status
  elseif ($did == 99) var %msg = Remove halfop status from the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41))) 
  elseif ($did == 100) var %msg = Give the selected user voice status $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41)))
  elseif ($did == 101) var %msg = Remove voice status from the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41)))
  elseif ($did == 91) var %msg = Add an exception for the selected user $+($chr(40),$did(86).seltext,$chr(41),.) This means that they will not be affected by bans placed upon them
  elseif ($did == 92) var %msg = Remove exception for the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41)))
  elseif ($did == 93) var %msg = Add an invite exception for the selected user $+($chr(40),$did(86).seltext,$chr(41),.) This means that they will not be affected if the channel is invite only
  elseif ($did == 94) var %msg = Remove invite exception for the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41)))
  elseif ($did == 63) var %msg = Send a notice to the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41)))
  elseif ($did == 65) var %msg = Send a query (Opens a new window) to the selected user $iif($did(86).seltext,$+($chr(40),$ifmatch,$chr(41)))
  elseif ($did == 69) || ($did == 105) var %msg = Select the host mask you wish to use for bans, invites and excepts from the drop down list. The examples are taken from you're own host, not what will be used in the command
  if (%msg) did -ra $dname 95 %msg
}

on *:dialog:ChanControl:sclick:*: {
  ; *********************************
  ; * Tab 1 - Channel modes         *
  ; *********************************
  var %chan = %ChanControl.Chan
  if ($did == 2) togglemode %chan i
  elseif ($did == 3) togglemode %chan m
  elseif ($did == 4) togglemode %chan n
  elseif ($did == 5) togglemode %chan p
  elseif ($did == 6) togglemode %chan s
  elseif ($did == 7) togglemode %chan t
  elseif ($did == 8) togglemode %chan z
  elseif ($did == 9) togglemode %chan C
  elseif ($did == 10) togglemode %chan T
  elseif ($did == 11) togglemode %chan G
  elseif ($did == 12) togglemode %chan M
  elseif ($did == 13) togglemode %chan K
  elseif ($did == 14) togglemode %chan M
  elseif ($did == 15) togglemode %chan Q
  elseif ($did == 16) togglemode %chan R
  elseif ($did == 17) togglemode %chan S
  elseif ($did == 18) togglemode %chan V
  elseif ($did == 19) togglemode %chan c
  elseif ($did == 20) togglemode %chan u

  ; k
  elseif ($did == 21) { 
    if ($did(22)) togglemode %chan k $did(22)
    elseif ($did == 21) && ($did(21).state == 1) {
      var %key = $?="Enter desired Channel Key" 
      if (%key) togglemode %chan k %key
      else { 
        did -ra $dname 32 Key not set as no key was specified 
        did -u $dname 21 
      }
    }
  }
  elseif ($did == 109) {
    if ($did(21).state == 1) mode %chan +k %key $?="Enter desired channel key"
    else {
      var %key = $?="Enter desired channel key"
      if (%key) did -ra $dname 22 %key
      else did -r $dname 22 
    }
  }

  ; l
  elseif ($did == 23) {
    if ($did(24)) togglemode %chan l $did(24) 
    elseif ($did(23).state == 1) {
      var %limit = $?="Enter the desired channel limit"
      if (%limit isnum 1-) togglemode %chan l %limit
      else {
        did -ra $dname 32 limit not set as $iif(%limit,the limit must be a number above 0,no limit was specified)
        did -u $dname 23
      }
    }
  }
  elseif ($did == 110) {
    if ($did(23).state == 1) mode %chan +l $$?="Enter desired channel limit"
    else {
      var %limit = $?="Enter the channel limit"
      if (%limit) did -ra $dname 24 %limit
      else did -r $dname 24
    }
  }

  ; L
  elseif ($did == 25) {
    if ($did(26)) togglemode %chan L $did(26)
    elseif ($did(25).state == 1) {
      var %link = #$?="Enter the desired Channel Link"
      if (%link) togglemode %chan L %link
      else {
        did -ra $dname 32 Link was not set as no link was specified
        did -u $dname 25
      }
    }
  }
  elseif ($did == 111) {
    if ($did(25).state == 1) mode %chan +L #$?="Enter desired channel Link"
    else {
      var %link = #$?="Enter desired channel Link"
      if (%link) did -ra $dname 26 %link
      else did -r $dname 26
    }
  }

  ; j
  elseif ($did == 27) {
    if ($did(28)) && ($did(30)) togglemode %chan j $+($did(28),:,$did(30))
    elseif ($did(27).state == 1) {
      var %joins = $?="Enter max number of joins", %seconds = $?="Enter time limit for these joins (in seconds)"
      if (%joins isnum 1-) && (%seconds isnum 1-) togglemode %chan j $+(%joins,:,%seconds)
      else {
        did -ra $dname 32 Join throttle was not set as both joins and seconds must be numbers greater than 0
        did -u $dname 27
      }
    }
  }
  elseif ($did == 112) {
    if ($did(27).state == 1) mode %chan +j $$?="Enter max number of joins" $+ : $+ $$?="Enter number of seconds these joins may occur in"
    else {
      var %joins = $?="Enter max number of joins to be allowed", %seconds = $?="Enter the time for these joins to occur in"
      if (%joins isnum 1-) && (%seconds isnum 1-) { did -ra $dname 28 %joins | did -ra $dname 30 %seconds }
      else did -r $dname 28,30
    }
  }

  ; *********************************
  ; * Tab 2 - Flood protect         *
  ; *********************************

  if ($did == 34) {
    if ($did(34).state == 1) did -e $dname 35,37,36 
    else did -b $dname 35,37,36
  }
  elseif ($did == 57) {
    if ($did(57).state == 1) did -e $dname 78,80,76
    else did -b $dname 78,80,76
  }
  elseif ($did == 61) {
    if ($did(61).state == 1) did -e $dname 60,64
    else did -b $dname 60,64
  }
  elseif ($did == 67) {
    if ($did(67).state == 1) did -e $dname 71,68,73
    else did -b $dname 71,68,73
  }
  elseif ($did == 42) {
    if ($did(42).state == 1) did -e $dname 44,45
    else did -b $dname 44,45  
  }
  elseif ($did == 52) {
    if ($did(52).state == 1) did -e $dname 50,53
    else did -b $dname 50,53
  }
  elseif ($did == 62) {
    if ($did(34).state == 1) && ($did(35)) && ($did(37)) {
      var %option = $+($did(35),c,$chr(35),$remove($did(36),+),$did(37))
      var %f = $addtok(%f,%option,44)
    }
    elseif ($did(34).state == 1) { 
      var %notset = $addtok(%notset,CTCP,44) 
      did -u $dname 34
      did -b $dname 35,36,37
    }
    if ($did(57).state == 1) && ($did(78)) && ($did(80)) {
      var %option = $+($did(78),j,$chr(35),$remove($did(76),+),$did(80))
      var %f = $addtok(%f,%option,44)
    }
    elseif ($did(57).state == 1) {
      var %notset = $addtok(%notset,join,44)
      did -u $dname 57
      did -b $dname 76,78,80
    }
    if ($did(61).state == 1) && ($did(60)) {
      var %option = $+($did(60),t,$chr(35),$left($did(64),1))
      var %f = $addtok(%f,%option,44)
    }
    elseif ($did(61).state == 1) {
      var %notset = $addtok(%notset,text,44)
      did -u $dname 61
      did -b $dname 60,64
    }
    if ($did(67).state == 1) && ($did(71)) && ($did(68)) {
      var %option = $+($did(71),m,$chr(35),$remove($did(73),+),$did(68))
      var %f = $addtok(%f,%option,44)
    }
    elseif ($did(67).state == 1) {
      var %notset = $addtok(%notset,message,44)
      did -u $dname 67
      did -b $dname 71,68,73
    }
    if ($did(42).state == 1) && ($did(44)) && ($did(45)) {
      var %option = $+($did(44),n,$chr(35),N,$did(45))
      var %f = $addtok(%f,%option,44)
    }
    elseif ($did(42).state == 1) {
      var %notset = $addtok(%notset,nick change,44)
      did -u $dname 42
      did -r $dname 44,45
    }
    if ($did(52).state == 1) && ($did(50)) && ($did(53)) {
      var %option = $+($did(50),k,$chr(35),K,$did(53))
      var %f = $addtok(%f,%option,44)
    }
    elseif ($did(52).state == 1) {
      var %notset = $addtok(%notset,knock,44)
      did -u $dname 52
      did -r $dname 50,53
    }

    if ($did(82) && (%f)) { 
      var %f = $+([,%f,]:,$did(82)) 
      mode %chan +f %f 
      did -ra $dname 84 Flood control settings have been updated! $crlf
      if (%notset) did -a $dname 84 The following options were not set due to missing input: %notset
    }
    elseif (!%f) { mode %chan -f }
    else did -ra $dname 84 ERROR: you must specify time (in seconds) for the flood to trigger in
  }
  ; *********************************
  ; * Tab 2 - user Controls         *
  ; *********************************
  if (!%ChanControl.mask) set %ChanControl.mask 2 
  if ($did == 69) set  %ChanControl.mask $did(69).sel
  var %pnick = $did(86).seltext
  var %nick = $remove($did(86).seltext,~,&,@,%,+) 
  var %netchan = $+($network,.,%chan)

  if ($did == 87) kick %chan %nick $?="Enter a kick reason (optional)"
  elseif ($did == 88) ban -k %chan %nick %ChanControl.mask $?="Enter a ban reason (optional)"
  elseif ($did == 43) ban -ku $+ $calc(60 * $$?="How long (in minutes) do you want the ban to last?") %chan %nick %ChanControl.Mask $?="Enter a kick reason (optional)"
  elseif ($did == 103) { mode %chan -vhaoq $str(%nick $+ $chr(32),5) | ban %chan %nick %ChanControl.mask } 
  elseif ($did == 102) ban -r %chan %nick %ChanControl.mask
  ;  elseif ($did == 89) { BAN LIST THINGY - DO THIS LATER }     
  elseif ($did == 97) mode %chan +o %nick
  elseif ($did == 96) mode %chan -o %nick
  elseif ($did == 98) mode %chan +h %nick
  elseif ($did == 99) mode %chan -h %nick
  elseif ($did == 100) mode %chan +v %nick
  elseif ($did == 101) mode %chan -v %nick
  elseif ($did == 91) mode %chan +e $address(%nick,%ChanControl.mask)
  elseif ($did == 92) mode %chan -e $address(%nick,%ChanControl.mask)
  elseif ($did == 93) mode %chan +I $address(%nick,%ChanControl.mask)
  elseif ($did == 94) mode %chan -I $address(%nick,%ChanControl.mask)
  elseif ($did == 63) notice %nick $$?="What mesage do you want to send?"
  elseif ($did == 64) query %nick $$?="What message do you want to send?"
}

on *:dialog:Chancontrol:edit:*: {
  if (($did == 24) || ($did == 28) || ($did == 30)) && ($did($did) !isnum) {
    did -ra $dname $did $left($did($did),-1)
    did -ra $dname 32 This filed may only contain a numeric value
  }
}

; ##################################################################################
; # Process the output of /mode to refresh all info                                #
; ##################################################################################
alias getmodes {
  .enable #getmodes
  mode $1
}
#getmodes off
raw 329:*: { haltdef |  .disable #getmodes }
raw 324:*: {
  haltdef
  ;nick chan modes [limit] [key] [LINK] [+f] [+j]
  if ($2 == %ChanControl.chan) {
    set %ChanControl.modes $remove($3,+)
    var %modes = %ChanControl.modes
    var %offmodes = kfLljpsmntirRcQKVGCuzNSMTG
    var %x = 1, %chars = $len(%modes)
    while (%x <= %chars) {
      var %char = $mid(%modes,%x,1)
      var %offmodes = $removecs(%offmodes,%char)
      inc %x
    }
    var %token = 4

    if (l isincs %modes) { var %modes.limit = $ [ $+ [ %token ] ] | inc %token }
    if (k isincs %modes) { var %modes.key = $ [ $+ [ %token ] ] | inc %token }
    if (L isincs %modes) { var %modes.link = $ [ $+ [ %token ] ] | inc %token }
    if (f isincs %modes) { var %modes.flood = $ [ $+ [ %token ] ] | inc %token }
    if (j isincs %modes) var %modes.join = $ [ $+ [ %token ] ] , %modes.joins = $gettok(%modes.join,1,58), %modes.seconds = $gettok(%modes.join,2,58)

    ; Set appropriate modes in tab 1
    if ($findid(%modes)) did -c ChanControl $findID(%modes)
    if ($findid(%offmodes)) did -u ChanControl $findid(%offmodes)
    if (k isincs %modes) did -ra ChanControl 22 %modes.key
    if (l isincs %modes) { 
      did -ra ChanControl 24 %modes.limit 
      if ($checkaccess == founder) did -e ChanControl 25 
    }
    else did -b ChanControl 25
    if (L isincs %modes) did -ra ChanControl 26 %modes.Link
    if (j isincs %modes) { did -ra ChanControl 28 %modes.joins | did -ra ChanControl 30 %modes.seconds }

    ; Set appropriate options in tab 2  
    if (%modes.flood) {
      var %time = $gettok(%modes.flood,2,58)
      did -ra ChanControl 82 %time
      if ($regex(%modes.flood,/(\d)c#(.)(\d)/)) {
        did -c ChanControl 34
        did -ra ChanControl 35 $regml(1)
        did -ra ChanControl 37 $regml(3)
        did -c ChanControl 36 $iif($regml(2) == C,1,$iif($regml(2) === m,2,3))
      }
      else { did -b ChanControl 35,37,36 | did -u ChanControl 34 }
      if ($regex(%modes.flood,/(\d)k#(.)(\d)/)) {
        did -c ChanControl 52
        did -ra ChanControl 50 $regml(1)
        did -ra ChanControl 53 $regml(3)
      }
      else { did -b ChanControl 50,53 | did -u ChanControl 52 }
      if ($regex(%modes.flood,/(\d)j#(.)(\d)/)) {
        did -c ChanControl 57
        did -ra ChanControl 78 $regml(1)
        did -ra ChanControl 80 $regml(3)
        did -c ChanControl 76 $iif($regml(2) == i,1,2)
      } 
      else { did -b ChanControl 78,80,76 | did -u ChanControl 57 }
      if ($regex(%modes.flood,/(\d)m#(.)(\d)/)) {
        did -c ChanControl 67
        did -ra ChanControl 71 $regml(1)
        did -ra ChanControl 68 $regml(3)
        did -c ChanControl 73 $iif($regml(2) === m,1,2)
      }
      else { did -b ChanControl 71,68,73 | did -u ChanControl 67 }
      if ($regex(%modes.flood,/(\d)n#(.)(\d)/)) {
        did -c ChanControl 42
        did -ra ChanControl 44 $regml(1)
        did -ra ChanControl 45 $regml(3)
      }
      else { did -b ChanControl 44,45 | did -u ChanControl 42 }
      if ($regex(%modes.flood,/(\d)t#(.{3,4})(\d)/)) {
        did -c ChanControl 61
        did -ra ChanControl 60 $regml(1)
        did -c ChanControl 64 $iif($regml(2) == k,1,2)
      }
      else { did -b ChanControl 60,64 | did -u ChanControl 61 }
    }
  }
}
#getmodes end

; ##################################################################################
; # Find which Id(s) are associated with the check box for specific modes          #
; ##################################################################################
alias FindID {
  if (i isincs $1) var %return = 2
  if (m isincs $1) var %return = $addtok(%return,3,44)
  if (n isincs $1) var %return = $addtok(%return,4,44)
  if (p isincs $1) var %return = $addtok(%return,5,44)
  if (s isincs $1) var %return = $addtok(%return,6,44)
  if (t isincs $1) var %return = $addtok(%return,7,44)
  if (z isincs $1) var %return = $addtok(%return,8,44)
  if (C isincs $1) var %return = $addtok(%return,9,44)
  if (T isincs $1) var %return = $addtok(%return,10,44)
  if (G isincs $1) var %return = $addtok(%return,11,44)
  if (M isincs $1) var %return = $addtok(%return,12,44)
  if (K isincs $1) var %return = $addtok(%return,13,44)
  if (N isincs $1) var %return = $addtok(%return,14,44)
  if (Q isincs $1) var %return = $addtok(%return,15,44)
  if (R isincs $1) var %return = $addtok(%return,16,44)
  if (S isincs $1) var %return = $addtok(%return,17,44)
  if (V isincs $1) var %return = $addtok(%return,18,44)
  if (c isincs $1) var %return = $addtok(%return,19,44)
  if (u isincs $1) var %return = $addtok(%return,20,44)
  if (k isincs $1) var %return = $addtok(%return,21,44)
  if (l isincs $1) var %return = $addtok(%return,23,44)
  if (L isincs $1) var %return = $addtok(%return,25,44)
  if (j isincs $1) var %return = $addtok(%return,27,44)
  return %return 
}

; ##################################################################################
; # Events to check when access should be changed                                  #
; ##################################################################################
on *:op:%ChanControl.chan: {
  if ($opnick == $me) checkaccess
  RefreshUserslist
}
on *:deop:%ChanControl.chan: {
  if ($opnick == $me) checkaccess
  RefreshUserslist
}
on *:halfop:%ChanControl.chan: {
  if ($hnick == $me) checkaccess
  RefreshUserslist
}
on *:dehalfop:%ChanControl.chan: {
  if ($hnick == $me) checkaccess
  RefreshUserslist
}
on *:voice:%ChanControl.chan: {
  if ($vnick == $me) checkaccess
  RefreshUserslist
}
on *:voice:%ChanControl.chan: {
  if ($vnick == $me) checkaccess
  RefreshUserslist
}
on *:join:%ChanControl.chan: RefreshUserslist
on *:part:%ChanControl.chan: RefreshUserslist
on *:quit: {
  if ($me ison %ChanControl.chan) RefreshUserslist
}
on *:nick: {
  if ($me ison %ChanControl.chan) RefreshUserslist
}
; ##################################################################################
; # rawmode event. Upkeep owner and admin status in hash tables, refresh set modes #
; ##################################################################################
on *:rawmode:#: {
  if ($chan == %ChanControl.Chan) && ($dialog(ChanControl)) getmodes $chan
  var %x = 1, %modes = $len($1), %parammodes+ = vhoaqklLfj, %parammodes- = vhaoqkLf, %token = 1
  if ((q isincs $1) || (a isincs $1)) && ($me isin $2-) {
    while (%x <= %modes) {
      var %char = $mid($1,%x,1) 
      if (%char isin +-) var %status = %char
      elseif (%char isincs $($+(%,parammodes,%status),2)) inc %token
      if (%char == q) && ($($+($,%token),2) == $me) {
        if (%status == +) hadd -m Owner $+($network,.,$chan) $me 
        else hdel Owner $chan
      }
      elseif (%char == a) && ($($+($,%token),2) == $me) {
        if (%status == +) hadd -m Admin $+($network,.,$chan) $me
        else hdel Admin $chan
      }
      inc %x
    }
    if ($dialog(ChanControl)) checkaccess
  }
}



; ##################################################################################
; # Access  aliases. Adjust avaliable controls accordingly                         #
; ##################################################################################
alias CheckAccess {
  var %netchan = $+($network,.,%ChanControl.Chan)
  if ($hget(Owner,%netchan)) { founderAccess | return founder }
  elseif ($hget(admin,%netchan)) { adminAccess | return admin }
  elseif ($me isop %ChanControl.Chan) { opAccess | return op }
  elseif ($me ishelp %ChanControl.Chan) { halfopAccess | return halfop }
  else { noAccess | return $null }
}
alias founderAccess {
  did -e ChanControl 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,23,25,27,109,110,111,112
  did -e ChanControl 34,35,36,37,42,44,45,50,52,53,57,60,61,62,64,67,68,71,73,76,78,80,82  
  did -e ChanControl 43,87,88,89,91,92,93,94,96,97,98,99,100,101,102,103
  did -ra ChanControl 32 You have founder access in $+(%ChanControl.chan,$chr(44)) giving you full access to all options here
  did -ra ChanControl 84 You have founder access in $+(%ChanControl.chan,$chr(44)) giving you full access to all options here
  did -ra ChanControl 95 You have founder access in $+(%ChanControl.chan,$chr(44)) giving you access to all options here
}
alias adminAccess {
  did -b ChanControl 20,25,111  
  did -e ChanControl 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,21,23,27,109,110,112
  did -e ChanControl 34,35,36,37,42,44,45,50,52,53,57,60,61,62,64,67,68,71,73,76,78,80,82  
  did -e ChanControl 43,87,88,89,91,92,93,94,96,97,98,99,100,101,102,103
  did -ra ChanControl 32 You are an admin in  $+(%ChanControl.chan,$chr(44)) giving you access to all options apart from those limited to channel founders
  did -ra ChanControl 84 You are an admin in $+(%ChanControl.chan,$chr(44)) giving you access to all options on this page
  did -ra ChanControl 95 You are an admin in $+(%ChanControl.chan,$chr(44)) giving you access to all options here, apart from attempting to kick or ban users with founder access
}
alias OpAccess {
  did -b ChanControl 20,25,111
  did -e ChanControl 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,21,23,27,109,110,112
  did -e ChanControl 34,35,36,37,42,44,45,50,52,53,57,60,61,62,64,67,68,71,73,76,78,80,82  
  did -e ChanControl 43,87,88,89,91,92,93,94,96,97,98,99,100,101,102,103
  did -ra ChanControl 32 You are an op in $+(%ChanControl.chan,$chr(44)) giving you access to all options apart from those limited to channel founders
  did -ra ChanControl 84 You are an op in $+(%ChanControl.chan,$chr(44)) giving you access to all options on this page
  did -ra ChanControl 95 You are an op in $+(%ChanControl.chan,$chr(44)) giving you access to all options here, apart from attempting to kick or ban users with higher access.
}
alias HalfopAccess {
  did -b ChanControl 5,6,8,9,10,11,12,13,14,15,16,17,18,19,20,22,23,24,25,26,27,28,30,110,111,112
  did -b ChanControl 34,35,36,37,42,44,45,50,52,53,57,60,61,62,64,67,68,71,73,76,78,80,82  
  did -b ChanControl 96,97,98,99
  did -e ChanControl 2,3,4,7,21,109 
  did -e ChanControl 43,87,88,89,91,92,93,94,100,101,102,103
  did -ra ChanControl 32 You are only a halfop in $+(%ChanControl.chan,$chr(44)) giving you limited access to the basic options
  did -ra ChanControl 84 You need to have op or above to be able to access any options on this plage
  did -ra ChanControl 95 You hare a halfop in $+(%ChanControl.chan,$chr(44)) giving you limited access to these commands

}
alias NoAccess {
  did -b ChanControl 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,30,109,110,111,112
  did -b ChanControl 34,35,36,37,42,44,45,50,52,53,57,60,61,62,64,67,68,71,73,76,78,80,82  
  did -b ChanControl 43,87,88,89,91,92,93,94,96,97,98,99,100,101,102,103
  did -ra ChanControl 32 You need to have halfop or above to be able to access any options on this page
  did -ra ChanControl 84 You need to have op or above to be able to access any options on this plage
  did -ra ChanControl 95 You Are only a regular or voiced user in $+(%ChanControl.chan,$chr(44)) meaning that you can only use the notice and query controls.
}
; ##################################################################################
; # Other aliases                                                                  #
; ##################################################################################
alias togglemode {
  if ($2 isincs %Chancontrol.modes) mode $1 $+(-,$2-)
  else mode $1 $+(+,$2-)
}
alias RefreshUserslist {
  if (!$dialog(ChanControl)) halt  
  did -r ChanControl 86
  var %x = 1, %total = $nick(%ChanControl.Chan,0)  
  while (%x <= %total) {
    did -a ChanControl 86 $nick(%ChanControl.Chan,%x).pnick
    inc %x
  }
}