egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

wont kick nicks with chars like {}
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 27, 2020 4:59 pm    Post subject: wont kick nicks with chars like {} Reply with quote

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

like: {[nick]} [nick]


using this atm:

Code:

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
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jul 27, 2020 6:39 pm    Post subject: Reply with quote

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.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 27, 2020 8:32 pm    Post subject: Reply with quote

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:
Quote:
.k nick nick nick nick .some custom reason here


it worked fine untill i was trying to kick nicks with weird chars in them
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 27, 2020 8:39 pm    Post subject: Reply with quote

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:


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
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Mon Jul 27, 2020 9:35 pm    Post subject: Reply with quote

simo:

Your code is a bit ugly, but try this instead...
Code:
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
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Jul 27, 2020 10:43 pm    Post subject: Reply with quote

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^^
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Jul 28, 2020 7:47 am    Post subject: Reply with quote

i tried adding in the foreach u posted Spike^^

Code:

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
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Tue Jul 28, 2020 9:50 am    Post subject: Reply with quote

Quote:

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:

foreach user [split $text] {


try something like this:
Code:

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


and then
Code:

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 !
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Jul 28, 2020 10:25 am    Post subject: Reply with quote

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]}}
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Jul 28, 2020 11:33 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Tue Jul 28, 2020 12:53 pm    Post subject: Reply with quote

Something's not right.

Earlier, you'd said:
Quote:

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 !
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Jul 28, 2020 1:32 pm    Post subject: Reply with quote

yes the last code i posted doesnt show the actuall nick in the notice of nick not online
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Jul 28, 2020 3:51 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Jul 28, 2020 6:04 pm    Post subject: Reply with quote

You have to join the splitted value:
Code:
foreach user [split $text] {
   set user [join $user]
   ....

https://www.tcl.tk/man/tcl8.4/TclCmd/join.htm
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Jul 28, 2020 6:30 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber