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.

doesnt set certain modes

Help for those learning Tcl or writing their own scripts.
Post Reply
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

doesnt set certain modes

Post by simo »

i was wondering why this sets like:

+k jhjhas
and like +o nick nick nick

but wont set like:

+l 22
+J 10

Code: Select all

bind pubm - "#% +?*" pub:massmodez316
bind pubm - "#% -?*" pub:massmodez316

proc pub:massmodez316 {nick host hand chan text} {
       if {![matchattr [nick2hand $nick] o|o $chan] && ![isop $nick $chan] && ![ishalfop $nick $chan]} { return 0  }
        set modex [lindex [split $text] 0]
        set nickz [join [lrange [split $text] 1 end]]
        set nickz [string trim $nickz]
        if {[onchan [string trimleft [split $modex 0] "+-"] $chan]} { return 0 }
        if {![llength [split $nickz]]} {
                pushmode $chan $modex
                return 0
        }   else { foreach user [split $nickz] {
		   pushmode $chan $modex $user 
        }
}
       flushmode $chan
}
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Well, peharps do you play too much with list/string conversions...
And you call pushmode2, what is this procedure ?
finally, what is exactly doing

Code: Select all

if {[onchan [string trimleft [split $modex 0] "+-"] $chan]} { return 0 }
Here is how I think your proc must be:

Code: Select all

bind pubm - "#% +?*" pub:massmodez316
bind pubm - "#% -?*" pub:massmodez316

proc pub:massmodez316 {nick host hand chan text} {
	if {![matchattr [nick2hand $nick] o|o $chan] && ![isop $nick $chan] && ![ishalfop $nick $chan]} { return 0  }
	set modex [join [lindex [split $text] 0]]
	if { [llength [split $text]]==1 } {
		pushmode $chan $modex
	} else {
		foreach user [lrange [split $text] 1 end] {
			pushmode $chan $modex $user
		}
	}
    flushmode $chan
}
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx for your reply crazycat
the : if {[onchan [string trimleft [split $modex 0] "+-"] $chan]} { return 0 }
is to check if the first parameter doesnt contain a nick wich is on channel
and the pushmode2 was a typo should be pushmode

i tried your code it works for +l 22 but not for like +J 10
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, I was guessing something like that...
But $modex is just the mode, so don't complicate things:

Code: Select all

if { [onchan [string map {+ "" - ""} $modex] $chan] } { return 0 }
simo wrote:i tried your code it works for +l 22 but not for like +J 10
Does pushmode only accept RFC modes ? I'll have a look on that
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

yes thommey told me pushmode only excepts RFC modes
but even using the custom pushmode thommey wrote for me doesnt seem to take it so it must be something else
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I'm to lazzy to search, can you paste the custom pushmode you have plz ?
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

would there be a way to use without the pushmode to evade all these issues with RFC

like using user's massmode code:

Code: Select all

proc massmode {chan mode arg} {
  scan $mode {%[-+]%[bov]} p m
  set j [llength $arg]
  set k [expr {${::modes-per-line}-1}]
  set out "";
for {set i 0} {$i<$j} {incr i} {
  set args [lrange $arg $i [incr i $k]]
  append out "MODE $chan $p[string repeat $m [llength $args]] [join 
  $args]\n"
 }
   putnow $out
 }
 

http://forum.egghelp.org/viewtopic.php? ... t=massmode
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Why do you bother with [matchattr [nick2hand $nick] o|o $chan] when:

1. you already got the user's account in the hand variable;
2. you should change the bind to bind pubm o|o directly and drop this part.

What issues you got with massmode? Apart it not seeing other flags apart than bov obviously? :)
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

oh euhm yea true didnt see that part thnx caesar heh

also the thing is if we use bind pubm o|o
it wont recognize like chanops and chanhalfops

as some may not have the flag set on them and there is no need to if they are chanops halfops

what would be the proper way to check if flag o is set on a nick to give it access to this command while also allowing regular chanops halfops access as well
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

would there be any other method to have this set any channel mode instead of being restricted ?

these are the available channel modes on the ircd :
IXbegwkBEFHJLQWdfjlxACDGKMNOPRSTUVcimnprstuz
User avatar
CrazyCat
Revered One
Posts: 1215
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Read what caesar said and your proc:

Code: Select all

proc massmode {chan mode arg} {
  scan $mode {%[-+]%[bov]} p m
  set j [llength $arg]
  set k [expr {${::modes-per-line}-1}]
  set out "";
  for {set i 0} {$i<$j} {incr i} {
    set args [lrange $arg $i [incr i $k]]
    append out "MODE $chan $p[string repeat $m [llength $args]] [join $args]\n"
   }
   putnow $out
 }
It appears that "bov" are in the first line, so try correcting it using:

Code: Select all

scan $mode {%[-+]%[IXbegwkBEFHJLQWdfjlxACDGKMNOPRSTUVcimnprstuz]} p m
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx crazycat i already figured that part but not sure how to use it with the code i posted
Post Reply