This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

output results in alpabetical order

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

output results in alpabetical order

Post by simo »

i was wondering if the output could be in alphabetical order as it doesnt seem to be as is:

Code: Select all


bind pub n|n .mcheck check_all

set excnickX2 {
	"chanserv"
}




proc check_all {nick host handle chan text} {
	global excnickX2

	# grab the channel members list and exclude the bot from it
	set userList [chanlist $chan]
	set pos [lsearch -nocase $userList $::botnick]
	set userList [lreplace $userList $pos $pos]

	# set kick reason
	set reasonX55 [join [lrange [split $text ] 0 end]]
	if {$reasonX55 eq ""} { set reasonX55 Requested }

	# build the list with only people that arent on chan access list
	foreach user [split $userList] {
		if {![isvoice $user $chan] && ![isop $user $chan] && ![ishalfop $user $chan] && ![matchattr [nick2hand $user] fnmo|fnmo $chan] && [lsearch -nocase $excnickX2 $user] == -1} {  lappend voiceList $user }
	}

	set max 4

	if {[info exists voiceList]} {
		set len [llength $voiceList]
		while {$len > 0} {
			if {$len > $max} {
				set mode [string repeat "v" $max]
				set users [join [lrange $voiceList 0 [expr {$max - 1}]]]
				set voiceList [lrange $voiceList $max end]
				incr len -$max
			} else {
				set users [join $voiceList]
				set len 0
			}
			putserv "NOTICE $nick [join $users ","]"
		}
		puthelp "NOTICE $nick :ALL non Voiced/opped/halfopped users on $chan."
	} else {
		puthelp "NOTICE $nick :No Voiced/opped/halfopped on $chan."
	}
}
so output meaning the putserv "NOTICE $nick [join $users ","]"

thnx in advance
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Use the lsort command to sort lists in tcl.
http://www.tcl.tk/man/tcl8.5/TclCmd/lsort.htm

Try sorting the list after your check if it does exist...

Code: Select all

   if {[info exists voiceList]} { 
      set voiceList [lsort -dictionary $voiceList]

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks spike^^ that seems to do it
Post Reply