ChanModePro

By |MELIORITE| on Mar 24, 2007

Protects most "major" modes of up to 8 channels by stopping ops from annoying changes. Some servers already have these protected, but mostly good to use in channels that don't have such protections and where the modes might be changed while you're afk. Ideal to load on a bot. Grab the snippet from here, load into remotes, then right click in any channel and choose ChanModePro. Enter channel names and modes to protect. This might have a few 'glitches', such as every so often it will not register what you have selected to protect. The snippet does work though! Any comments and suggestions are, as always, most welcome to assist my learning.

*Updates of version 1.0 to 1.1 - sclicks all under $did, seems to work a little faster. Some minor changes to if and elseif conditions.

dialog CMP {
  title "ChanModePro v 1.1 by MELIORITE"
  size -1 -1 235 165
  option dbu
  text "ChanModePro v 1.1 -by MELIORITE", 1, 8 155 160 8, disable center
  box "Channel List", 3, 1 1 118 140
  box "Modes", 4, 118 1 115 140
  edit "", 5, 3 9 47 10, disable
  edit "", 6, 3 21 47 10, disable
  edit "", 7, 3 33 47 10, disable
  edit "", 8, 3 45 47 10, disable
  edit "", 9, 3 57 47 10, disable
  edit "", 10, 3 69 47 10, disable
  edit "", 11, 3 81 47 10, disable
  edit "", 12, 3 93 47 10, disable
  button "Add", 13, 50 9 15 10, flat
  button "Add", 14, 50 21 15 10, flat
  button "Add", 15, 50 33 15 10, flat
  button "Add", 16, 50 45 15 10, flat
  button "Add", 17, 50 57 15 10, flat
  button "Add", 18, 50 69 15 10, flat
  button "Add", 19, 50 81 15 10, flat
  button "Add", 20, 50 93 15 10, flat
  button "Remove", 21, 65 9 30 10, flat
  button "Remove", 22, 65 21 30 10, flat
  button "Remove", 23, 65 33 30 10, flat
  button "Remove", 24, 65 45 30 10, flat
  button "Remove", 25, 65 57 30 10, flat
  button "Remove", 26, 65 69 30 10, flat
  button "Remove", 27, 65 81 30 10, flat
  button "Remove", 28, 65 93 30 10, flat
  button "OK", 29, 3 150 37 12, flat, ok
  check "Topic Protect",30,125 9 150 15
  check "Moderated +m",31,125 21 150 15
  check "Protect +n",32,125 33 150 15
  check "Colour +c",33,125 45 150 15
  check "Private +p",34,125 57 150 15
  check "Invite +i",35,125 69 150 15
  check "Secret +s",36,125 81 150 15
  check "Ops +o",37,125 93 150 15
  check "Voice +v",38, 125 105 150 15
  radio "Enable",48,125 117 100 15
  radio "Disable",49,125 129 100 15

}
menu status,channel,nicklist,query,menubar { 
  ChanModePro:dialog -m CMP CMP 
  -
}

on *:dialog:CMP:sclick:*: {
  if ($did == 13) { 
    set %CMPchan1 $$?="Enter Channel Name" 
  did -a CMP 5 %CMPchan1 }
  if ($did == 14) { 
    set %CMPchan1 $$?="Enter Channel Name" 
  did -a CMP 6 %CMPchan2 }
  if ($did == 15) { 
    set %CMPchan3 $$?="Enter Channel Name" 
  did -a CMP 7 %CMPchan3 }
  if ($did == 16) { 
    set %CMPchan4 $$?="Enter Channel Name" 
  did -a CMP 8 %CMPchan4 }
  if ($did == 17) { 
    set %CMPchan5 $$?="Enter Channel Name" 
  did -a CMP 9 %CMPchan5 }
  if ($did == 18) { 
    set %CMPchan6 $$?="Enter Channel Name" 
  did -a CMP 10 %CMPchan6 }
  if ($did == 19) { 
    set %CMPchan7 $$?="Enter Channel Name" 
  did -a CMP 11 %CMPchan7 }
  if ($did == 20) { 
    set %CMPchan8 $$?="Enter Channel Name" 
  did -a CMP 12 %CMPchan8 }
  if ($did == 21) { 
    unset %CMPchan1 
  did -r CMP 5 %CMPchan1 }
  if ($did == 22) { 
    unset %CMPchan2 
  did -r CMP 6 %CMPchan2 }
  if ($did == 23) { 
    unset %CMPchan3 
  did -r CMP 7 %CMPchan3 }
  if ($did == 24) { 
    unset %CMPchan4 
  did -r CMP 8 %CMPchan4 }
  if ($did == 25) { 
    unset %CMPchan5 
  did -r CMP 9 %CMPchan5 }
  if ($did == 26) { 
    unset %CMPchan6 
  did -r CMP 10 %CMPchan6 }
  if ($did == 27) { 
    unset %CMPchan7 
  did -r CMP 11 %CMPchan7 }
  if ($did == 28) { 
    unset %CMPchan8 
  did -r CMP 12 %CMPchan8 }
  if ($did == 48) { set %CMP Enable }
  if ($did == 49) { set %CMP Disable }
  if ($did == 30) { if (%topicprotect = $null) set %topicprotect off | elseif (%topicprotect = off) { set %topicprotect on | halt } | else set %topicprotect on } 
  if ($did == 31) { if (%mod = $null) set %mod off | elseif (%mod = off) { set %mod on | halt } | else set %mod on }
  if ($did == 32) { if (%n = $null) set %n off | elseif (%n = off) { set %n on | halt } | else set %n on }
  if ($did == 33) { if (%col = $null) set %col off | elseif (%col = off) { set %col on | halt } | else set %col off }
  if ($did == 34) { if (%priv = $null) set %priv off | elseif (%priv = off) { set %priv on | halt } | else set %priv on }
  if ($did == 35) { if (%inv = $null) set %inv off | elseif (%inv = off) { set %inv on | halt } | else set %inv on }
  if ($did == 36) { if (%sec = $null) set %sec off | elseif (%sec = off) { set %sec on | halt } | else set %sec on }
  if ($did == 37) { if (%ops = $null) set %ops off | elseif (%ops = off) { set %ops on | halt } | else set %ops on }
  if ($did == 38) { if (%voice = $null) set %voice off | elseif (%voice = off) { set %voice on | halt } | else set %voice on }
  if ($did == 50) { if (%sp = $null) set %sp off | elseif (%sp = off) { set %sp on | halt } | else set %sp on }
}

on *:dialog:CMP:init:*: {
  did -a CMP 5 %CMPchan1
  did -a CMP 6 %CMPchan2
  did -a CMP 7 %CMPchan3
  did -a CMP 8 %CMPchan4
  did -a CMP 9 %CMPchan5
  did -a CMP 10 %CMPchan6
  did -a CMP 11 %CMPchan7
  did -a CMP 12 %CMPchan8 
}
on *:dialog:CMP:init:*: {
  if (%topicprotect = on) did -a modes 30 | if (%mod = on) did -a modes 31 | if (%n = on) did -a modes 32 | if (%col = on) did -a modes 33 | if (%priv = on) did -a modes 34 | if (%inv = on) did -a modes 35 | if (%sec = on) did -a modes 36 | if (%ops = on) did -a modes 37 | if (%voice = on) did -a modes 38 | if (%sp = on) did -a modes 50 
}

on *:dialog:CMP:init:*: { 
  did -a CMP 30 %topicprotect
  did -a CMP 31 %mod
  did -a CMP 32 %n
  did -a CMP 33 %col
  did -a CMP 34 %priv
  did -a CMP 35 %inv
  did -a CMP 36 %sec
  did -a CMP 37 %ops
  did -a CMP 38 %voice
}

On !*:rawmode:#:{
  if ( %CMP = enable ) {
    if (%topicprotect = on ) || if (%mod = on) || if (%n = on) || if (%col = on) || if (%priv = on) || if (%inv = on) || if (%sec = on) || if (%ops = on) || (if %voice = on) {
      if ($chan == %CMPChan1) || ($chan == %CMPChan2) || ($chan == %CMPChan3) || ($chan == %CMPChan4) || ($chan == %CMPChan5) || ($chan == %CMPChan6) || ($chan == %CMPChan7) || ($chan == %CMPChan8) {
        if !$istok(L Q Chanserv,$nick,32) && ($nick != $me) {
          if ($1- == $null) { .halt }
          elseif ($1- != $null) { .mode $chan $replacex($1-,+,-,-,+) | .kick # $nick $nick $+ , Modes Protected }
        }  
      }
    }
  }
}

Comments

Sign in to comment.
Lindrian   -  May 21, 2007

also, saw in ur code that u use did -a id several times, u can use them once and do:
eg:
did -a CMP 1-10 HI
or
did -a CMP 1,2,3,4,5,6,7,8,9,10 hi

 Respond  
Lindrian   -  May 21, 2007

Your welcome :)

 Respond  
|MELIORITE|   -  May 21, 2007

Great idea ... i\'ll revamp the whole system in version 2 and certainly look at that idea... because I am interested in making this sytem completely better than originally written. Thanx for those ideas.

 Respond  
Lindrian   -  May 21, 2007

Heh, the loop thing was a lil messy, however:

alias mode_load {
  var %a = 30, %b = 38
  while %a <= %b {
    did $iif($did(%a) isin $chan($active).mode,-c,-u) $dname %a
    inc %a
  }
} 

Sorry, did it in class you know ;)

 Respond  
Lindrian   -  May 21, 2007

Sounds great. Also thought of, what about removing the radio\'s, and make the check boxes select/unselect depending on the modes?

alias load_mode {
var %x = $chan($active).mode
if (MODE isincs %x) { actions }
if (MODE2 isincs %x) { actions }
}

or

alias load_mode {
var %a = 1, %b = $chan($active).mode, %c = 30
while %a <= %b {
did -a CMP $iif($gettok(CMP,%c),1,32) isincs %b,-c,-u) <id>
inc %b
}
inc %c
}

Im not sure if the alias with the loop is correct, i assumed that the first check is used from 30. (The id for the topic lock)

When the .state is 0, it returns the mode -, elseif the state is 1, it returns +.

When you press ok, the selected modes will be set.

Much better then nusing radios for add/remove ;).

 Respond  
|MELIORITE|   -  May 21, 2007

I tried it out before I posted the version, but I guess I\'ll have to check it out again... the boxes all seemed right. Thanks for pointing out the glitch in the channel entries, I was not aware it was doing that so I\'ll fix that too. The modes also has a glitch, that when the system is reopened there\'s no way for it to recall the selected modes for protection o na channel because i have not made a way to isolate a particular channel, so no modes appear to be selected... although the protections still work. I will have another look at all these areas.... for version 2 I will place in the checks and also will write to a file to record the chan selections so that the system can read these when a channel is isolated. The overlapping on chan boxes obviously needs work :) and I will look at the radio button.

 Respond  
Lindrian   -  May 21, 2007

Also, sorry for a second post, but when you add a channel, you can overwrite the old one, it doesn\'t really, it just adds it on top. Is that how its supposed to be?
Or isn\'t the add button supposed to be disabled while the variable contains a channel, when u press remove, the remove button gets disabled and the add button enabled?

 Respond  
Lindrian   -  May 21, 2007

I tried it, i saw that the \"disable\" radio goes over the box...
Also, for some reason, the second box in the channel thing didnt work.. Never added the channel.

Also, a few checks in the channel things would be ok:

did -a CMP <id> $+($iif($left($did(cmp,ID),1) != $chr(35),$v2),%VARIABLE)

Also, the modes thingy didnt quite work for me, but i probably used it incorrectly. otherwhize nice work.

 Respond  
|MELIORITE|   -  May 21, 2007

Updated some of the code based on some of the valuable feedback received to date.

 Respond  
|MELIORITE|   -  Apr 24, 2007

Good thought... I\'ll try that out before i edit... or i wonder also if a general:

On 1:dialog:CMP:sclick:*:{
  if $did = 13 { set %CMPchan1 $$?=\"Enter Channel Name\"

etc ... which takes out the need for the \"elseif\" conditions? I will try that out soon too.
This was entered as my second real piece of code, and while I have improved a little since then I am grateful for all the improvement pointers.

 Respond  
Lindrian   -  Apr 24, 2007

You should try settings ur dialog up like:

on *:dialog:CMP:*:*: {
if ($devent == sclick) {
if ($did == 13) {
  set %CMPchan1 $$?=\"Enter Channel Name\"
  did -a CMP 5 %CMPchan1
}
elseif ($did == 14) {
  set %CMPchan2 $$?=\"Enter Channel Name\"
  did -a CMP 6 %CMPchan2
}
elseif ($did == 15) {
  set %CMPchan3 $$?=\"Enter Channel Name\"
  did -a CMP 7 %CMPchan3
}
}
 Respond  
|MELIORITE|   -  Apr 23, 2007

Hmmm.... yes, very true. Originally settings for the bot can be made, but you\'re right, cannot be adjusted without going into the bot. I actually use it on myself normally and have a copy on one of my bots with settings made for certain channels which I have not altered since loading it. So, yes, you are entirely correct... perhaps I\'ll just amend my earlier statement \"its best application is for bots\" and instead say, \"its best application is for live users\". :D Thanks for the feedback.

 Respond  
RusselB   -  Apr 23, 2007

Using a dialog on a bot is next to useless, since a dialog requires human interaction, and a bot can\'t do that.

 Respond  
|MELIORITE|   -  Apr 11, 2007

Thanks! I agree, its best application is for bots. I will look at the ech on load.... I\'ve been away from my pc too long! (I\'m sneaking this time online in at work heehee... anything for an online junkie). Just moved house etc so when I can look at my files again in the next week or so will check out the idea :)

 Respond  
MightyKiller   -  Mar 28, 2007

Good Work =) , But I Think This Is Best For Bots & Second Thing You Add Echo On Load This Script.

 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.