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.

massmode not working proper

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

massmode not working proper

Post by simo »

any reason why the second if statement wont trigger if criteria is met in this?

the if {![info exists nickz]} {

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]]
	foreach user $nickz {


		if {![info exists nickz]} {
			pushmode $chan $modex
		} else {
			pushmode $chan $modex $user
		}
	}
	flushmode $chan
}

for example this works fine +v nick nick nick nick nick nick nick nick

this on the other hand doesnt

+m
or +M or any other single param mode setting
Last edited by simo on Mon Jul 13, 2020 5:03 pm, edited 1 time in total.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Re: massmode not working proper

Post by willyw »

This:

Code: Select all

    set nickz [join [lrange [split $text] 1 end]] 
*IS* setting nickz, isn't it? It's set, there's just nothing in it.

Thus, this:

Code: Select all

if {![info exists nickz]}
doesn't trigger.

That's what I'm thinking, based on what you've said.

How about if instead you used ?:

Code: Select all

if {![llength $nickz]}
By the way, look at this part too:

Code: Select all

set nickz [join [lrange [split $text] 1 end]]
   foreach user $nickz {
The foreach command wants a list, and as it is $nickz is a string.
Why join it? Why not leave it as the string returned by the lrange command?
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks for your reply willyw i tried like this same effect it doesnt trigger single mode setting

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 [lrange [split $text] 1 end]
   foreach user $nickz {

     if {![llength $nickz]} {
         pushmode $chan $modex
      } else {
         pushmode $chan $modex $user
      }
   }
   flushmode $chan
}
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Play with this. See what you think.

I tried to make minimal changes.

There is no checking to see if bot is even op'd, or if nick to set mode on is even on #channel. You can decide if you want to add such things in it. :)



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 {![llength [split $nickz]]} {
                pushmode $chan $modex
                return 0
        }



        foreach user [split $nickz] {
                pushmode $chan $modex $user
        }

        flushmode $chan
}
###

For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanx for the reply willyw i tried your last posted code it gave me the same result this works fine:

+v nick nick nick nick nick nick nick nick nick nick

however this doesnt :

+M
+m
+i
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

simo wrote:thanx for the reply willyw i tried your last posted code it gave me the same result this works fine:

+v nick nick nick nick nick nick nick nick nick nick

however this doesnt :

+M
+m
+i
I don't know why. I tried a few times, both with nicks and without. It worked fine for me.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

some times im gettin this error :

Tcl error [parsemode]: can't read "modechar": no such variable
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thx willyw it works fine now
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

simo wrote:thx willyw it works fine now

Good to hear. :)


What was the solution though?
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Oh sorry didn't see the last question only now i did the issue was with the access check i removed the !() and added! At each check
Post Reply