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.

wont kick nicks with chars like {}

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

wont kick nicks with chars like {}

Post by simo »

i wonder why this wont kick nicks with chars like {} in it

like: {[nick]} [nick]


using this atm:

Code: Select all

bind pub n .k pub:kicker
proc pub:kicker {nick host hand chan text} {
  global botnick

	if {![botisop $chan]} {
		puthelp "NOTICE $nick :I'm not oped on $chan."
		return
	}
	set users [list]
                set reason [join [lrange [split $text "."] 1 end] "."]
	set text  [lindex [split $text "."] 0]
	if {$reason eq ""} { set reason Requested  }
	foreach user $text {

		if {![onchan $user $chan]} {
			putserv "NOTICE $nick $user is not on channel $chan"
		} else {

          lappend users $user

			}
	}
   stackKicks $chan [join $users] $reason 4
}



proc stackKicks {chan kicklist reason {max 4}} {
		set count [llength $kicklist]
		while {$count > 0} {
			if {$count > $max} {
				set users [join [lrange $kicklist 0 [expr {$max - 1}]] ","]
				set kicklist [lrange $kicklist $max end]
				incr count -$max
			} else {
				set users [join $kicklist ","]
				set count 0
			}
			putnow "KICK $chan $users $reason"
		}
	}
it keeps returning nick isnt on channel while he is
Last edited by simo on Wed Jul 29, 2020 11:16 am, edited 2 times in total.
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, so your script is to answer to ".k aaa bbb ccc.reason of kick" ? (with "aaa", "bbb" and "ccc" as nicks of victims)

Quite strange as syntax, but nevermind...
You do: set text [lindex [split $text "."] 0] and after: foreach user $text {... $text is not a list but an element of list, so it can rarely match an user.
foreach user [split [join $text] " "] might be better imho.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thank your for the reply crazycat and yes i use this to have the option of multiple nicks in a kick command and a custom kick reason so to determine the diffence between a nick and the custom kick reason the . comes in place or that was the idea at least

like:
.k nick nick nick nick .some custom reason here
it worked fine untill i was trying to kick nicks with weird chars in them
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried using your suggestion using the foreach user [split [join $text] " "]

but the result is the same it doesnt kick nicks with weird chars in them

Code: Select all


bind pub n .k pub:kicker
proc pub:kicker {nick host hand chan text} {
  global botnick

   if {![botisop $chan]} {
      puthelp "NOTICE $nick :I'm not oped on $chan."
      return
   }
   set users [list]
                set reason [join [lrange [split $text "."] 1 end] "."]
   set text  [lindex [split $text "."] 0]
   if {$reason eq ""} { set reason Requested  }
    foreach user [split [join $text] " "] {
      if {![onchan $user $chan]} {
         putserv "NOTICE $nick $user is not on channel $chan"
      } else {

          lappend users $user

         }
   }
   stackKicks $chan [join $users] $reason 4
}

with chars like {}[] in nick it returned with : {{Tessie}} is not on channel #test
Last edited by simo on Tue Jul 28, 2020 7:48 am, edited 1 time in total.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

simo:

Your code is a bit ugly, but try this instead...

Code: Select all

foreach user [split $text] { 
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: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Thanks for the reply Spike^^ i would like to see the more proper way of writing this as this is what i have been using so far if this is not proper please show me how its done so i can use that as reference for others i use tnx spike^^
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried adding in the foreach u posted Spike^^

Code: Select all

bind pub n .k pub:kicker
proc pub:kicker {nick host hand chan text} {
  global botnick

   if {![botisop $chan]} {
      puthelp "NOTICE $nick :I'm not oped on $chan."
      return
   }
       set users [list]
       set reason [join [lrange [split $text "."] 1 end] "."]
      set text  [lindex [split $text "."] 0]
   if {$reason eq ""} { set reason Requested  }
		foreach user [split $text] {
           if {![onchan $user $chan]} {
         putserv "NOTICE $nick $user is not on channel $chan"
      } else {
          lappend users $user
         }
   }
   stackKicks $chan [join $users] $reason 4
}
it keeps returning this without showing the nick : is not on channel #test
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

it keeps returning this without showing the nick : is not on channel #test
Find out exactly what is in $text.

Immediately before this line:

Code: Select all

foreach user [split $text] { 
try something like this:

Code: Select all

putserv "privmsg $chan :text is:    $text "
and then

Code: Select all

putserv "privmsg $chan :split text is:     [split $text] "

Now you're going to see exactly what that foreach command is about to operate on. Perhaps that will hold a clue.
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: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanx willyw i tried that and output is :


the nick is: {[test]}

using .k {[test]}

the putserv "privmsg $chan :text is: $text "
returns : text is: {[test]}

and the putserv "privmsg $chan :split text is: [split $text] "

returns: split text is: {{[test]}}
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

still cant get the nicks with {} in them not sure why it stores them stripped from the {} so when it tries to kick it obviously says not on channel so it must be the storing part that goes wrong im not sure how to store nicks proper with all their chars intact so it can proceed to kick
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Something's not right.

Earlier, you'd said:
it keeps returning this without showing the nick : is not on channel #test
I saw that nothing was there, for the value in $user , and posted. The idea was to find out what was in $text, exactly - and hopefully be able to figure out why $user was empty.

That's not happening now.
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: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

yes the last code i posted doesnt show the actuall nick in the notice of nick not online
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

im stuck cant figure a way to fix this issue i saw im not the first with this issue i saw this old post : http://forum.egghelp.org/viewtopic.php?t=11001
altho this doesnt stack nicks wich is what i was looking for
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

You have to join the splitted value:

Code: Select all

foreach user [split $text] {
   set user [join $user]
   ....
https://www.tcl.tk/man/tcl8.4/TclCmd/join.htm
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Thanx crazycat except the thing is i already used split in the set im not sure its a good idea to have duplicate split text
Post Reply