Channel modes Dialog

By slub77 on Jan 30, 2010

I made this out of a dialog i am making at the moment, but this in it self is pretty good so i though i would put it on here for any one wanting it :).

Features
.Dialog form
.Multiple buttons for channel modes including: limet, moderation, secret, private, invite, password,external messages
.Check boxes that will be ticked if the channel mode is set to on
.Disables buttons if you are not op on the channel

NOTE
To choose the channel you must first have that channel open and have clicked in it to make it the active window

menu channel {
Channel Modes:/dialog -ma test test
}
alias dioc {
  if (n isincs $chan($1).mode) { did -fc test 50 }
  if (k isincs $chan($1).mode) { did -fc test 48 }
  if (s isincs $chan($1).mode) { did -fc test 46 }
  if (l isincs $chan($1).mode) { did -fc test 44 }
  if (p isincs $chan($1).mode) { did -fc test 42 }
  if (i isincs $chan($1).mode) { did -fc test 40 }
  if (m isincs $chan($1).mode) { did -fc test 38 }
}

dialog test {

  title Channel Modes

  size -1 -1 208 112

  option dbu

  button Moderation, 37, 4 21 190 12, ok disable
  check        , 38, 194 21 9 10, left  disable

  button Invite only , 39, 4 33 190 12, ok tab 5 disable
  check        , 40, 194 33 9 10, left disable

  button Private, 41, 4 45 190 12, ok tab 5 disable
  check        , 42, 194 45 9 10, left  disable

  button Limet, 43, 4 57 190 12, ok tab 5 disable
  check        , 44, 194 57 9 10, left  disable

  button Secret, 45, 4 69 190 12, ok tab 5 disable
  check        , 46, 194 72 9 10, left  disable

  button Password, 47, 4 81 190 12, ok tab 5 disable
  check        , 48, 194 82 9 10, left  disable

  button External Message, 49, 4 93 190 12, ok tab 5 disable
  check        , 50, 194 93 9 10, left disable

}

on *:dialog:test:init:*:{ 
  set %channel $active | $dioc(%channel)
  if $me isop %channel { did -e test 37,39,41,43,45,47,49 | $dioc(%channel) } 
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

on 1:DIALOG:test:sclick:37:{
  if (m isincs $chan(%channel).mode) { mode %channel -m | did -fu test 38 }
  if (m !isincs $chan(%channel).mode) { mode %channel +m | did -fc test 38 }
}
on 1:DIALOG:test:sclick:39:{
  if $me isop %channel {
    if (i isincs $chan(%channel).mode) { mode %channel -i | did -fu test 40 }
    if (i !isincs $chan(%channel).mode) { mode %channel +i | did -fc test 40 }
  }
}
on 1:DIALOG:test:sclick:41:{
  if $me isop %channel {
    if (p isincs $chan(%channel).mode) { mode %channel -p | did -fu test 42  }
    if (p !isincs $chan(%channel).mode) { mode %channel +p | did -fc test 42 }
  }
}
on 1:DIALOG:test:sclick:43:{
  if $me isop %channel {
    if (l isincs $chan(%channel).mode) { mode %channel -l | did -fu test 44  }
    if (l !isincs $chan(%channel).mode) { 
      $$?"To how many users?" 

      if $! isnum 0-100 { mode %channel + l $! | did -fc test 44 }
      elseif $! isalnum { echo Pleae enter Only a number }
    }
  }
}
on 1:DIALOG:test:sclick:45:{
  if $me isop %channel { 
    if (s isincs $chan(%channel).mode) { mode %channel -s | did -fu test 46 }
    if (s !isincs $chan(%channel).mode) { mode %channel +s | did -fc test 46 }
  }
}

on 1:DIALOG:test:sclick:47:{
  if (k isincs $chan(%channel).mode) { mode %channel -k $chan(%channel).key | did -fu test 48  }
  if (k !isincs $chan(%channel).mode) { mode %channel +k $$?"Password" | did -fc test 48 }
}

on 1:DIALOG:test:sclick:49:{
  if (n isincs $chan(%channel).mode) { mode %channel -n | did -fu test 50  }
  if (n !isincs $chan(%channel).mode) { mode %channel +n | did -fc test 50 }
}

Comments

Sign in to comment.
slub77   -  Feb 01, 2010

@silo yea i have got something set as %tab

@gooshie oh thanks dude

 Respond  
gooshie   -  Jan 31, 2010

When checking channel modes its best to do as follows or if channel key is set it can give bad results.

$gettok($chan(%channel).mode,1,32)
 Respond  
Silo   -  Jan 31, 2010

Out of curiousity, is there a need to set a %tab variable, since each tab has its'own id?

Rated and clicked :)

 Respond  
slub77   -  Jan 31, 2010

no what i have done is:

it will only work if the dialogs open, if the click refresh it will close the dialog, then reopen it, and then go to the tab that you were last on, because in another part i have it so when you click a tab, it's set's %tab as that tab's ID

Edit:
Please rate the snippet :)
Also look at http://www.hawkee.com/snippet/7236/ for a newer dialog just made :)

 Respond  
Silo   -  Jan 31, 2010

your did -fu $dname is missing a dialog id number

When you use the -x flag you only need to name the dialog once, and in fact, the way you have that at the moment you can just use did -x $dname

The dialog -ma test test is fine, except what if the dialog is already open? You'll get an (ugly imo) error message.Check to see if the dialog is open using an $iif

alias _test dialog $iif($dialog(test),-x,-ma test) test

 Respond  
slub77   -  Jan 31, 2010

no i have a big dialog, that is a combing of most of the dialogs i post here, these are dialogs that can work with out the rest of the scripts, i am using now for a dialog button action:

on 1:DIALOG:TEST:Sclick:10:{
  dialog -x test test
  dialog -ma test test
  did -fu $dname %tab

}
 Respond  
Silo   -  Jan 31, 2010

You shouldn't really have a need for one since the info re the state of the check box is being recognised on init. To refresh while the dialog is open just use

On ^*:MODE:#:if ($dialog(test)) $dioc(%channel)
 Respond  
slub77   -  Jan 31, 2010

yea i am reading it lol, atm trying to make it refresh lol, may just make a button

 Respond  
Silo   -  Jan 31, 2010

You could play around with these $iifs too if you felt like it.

did $iif(m isincs $chan(%channel).mode,-c,-u) test 38

mode $chan $iif(m isincs $chan(%channel).mode,+m,-m)

if ($active !ischan) return

I know there is noting suckier than someone telling you to read the help file, but the dialog part of the help file covers alot of good stuff.

 Respond  
slub77   -  Jan 31, 2010

yea, i don't know why i keep making it focus, i think i just did it the one time, and i have been doing it since

 Respond  
Silo   -  Jan 31, 2010

There's no need for the f flag either as -c will check the box
I used to use:

alias _load.modes {
  if ($active !ischan) return
  var %mc = $chan($active).mode
  if (m isincs %mc) did -c _options 52 
  if (N isincs %mc) did -c _options 78
  if (I isincs %mc) did -c _options 43 
  if (R isincs %mc) did -c _options 44 
  if (L isincs %mc) did -c _options 45 
  if (f isincs %mc) did -c _options 46 
  if (G isincs %mc) did -c _options 76 
  if (C isincs %mc) did -c _options 77 
  if (n isincs %mc) did -c _options 71 
  if (t isincs %mc) did -c _options 70 
  if (Q isincs %mc) did -c _options 81
  if (c isincs %mc) did -c _options 73 
  if (M isincs %mc) did -c _options 82
  if (T isincs %mc) did -c _options 79
  if (j isincs %mc) did -c _options 60 
  if (w isincs %mc) did -c _options 61 
  if (p isincs %mc) did -c _options 80
  if (l isincs %mc) did -i _options 84 1 * $gettok(%mc,-1,32)
  if (K isincs %mc) did -c  _options 72 
  if (R isincs %mc) did -c _options 74 
}

but even then I don't like it, it's too long and messy for such basic code. $iif would work just as well to clean it up as well.

 Respond  
Jethro   -  Jan 30, 2010

You don't have to make an extra if statement to check if a mode exists or not, but to use an else condition as shown below. You do the same for the rest.

if (m isincs $chan(%channel).mode) { mode %channel -m | did -fu test 38 }
else { mode %channel +m | did -fu test 38 }
}
 Respond  
slub77   -  Jan 30, 2010

There, i have no idea why they were there 0-0

 Respond  
gooshie   -  Jan 30, 2010
on 1:DIALOG:test:sclick:49:{
  if (n isincs $chan(%channel).mode)} { mode %channel -n | did -fu test 50  }
  if (n !isincs $chan(%channel).mode)} { mode %channel +n | did -fc test 50 }
}

nothing, but what's wrong with that :/

You have a whole pile of bracket mismatch issues and you could use else in about seven places to shorten it.

 Respond  
Ghost-writer   -  Jan 30, 2010

Eh, i dont see the point of it. But good job.

 Respond  
slub77   -  Jan 30, 2010

nothing, but what's wrong with that :/

 Respond  
gooshie   -  Jan 30, 2010

What's wrong with: /channel #RoomName

 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.