<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/20827" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2020-07-29T20:48:34-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/20827</id>

		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-29T20:48:34-04:00</updated>

		<published>2020-07-29T20:48:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108821#p108821</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108821#p108821"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108821#p108821"><![CDATA[
good point caesar thank you<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Jul 29, 2020 8:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2020-07-29T14:17:22-04:00</updated>

		<published>2020-07-29T14:17:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108820#p108820</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108820#p108820"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108820#p108820"><![CDATA[
@simo btw, since you added the <em class="text-italics">max</em> as 4th argument and got it set with a default value as 4 in this:<div class="codebox"><p>Code: </p><pre><code>proc stackKicks {chan kicklist reason {max 4}} {</code></pre></div>there's no need to call the function like:<div class="codebox"><p>Code: </p><pre><code>stackKicks $chan $users $reason 4</code></pre></div>if it's 4 as well. Or you plan to have a different value?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Jul 29, 2020 2:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2020-07-29T11:51:41-04:00</updated>

		<published>2020-07-29T11:51:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108819#p108819</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108819#p108819"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108819#p108819"><![CDATA[
<blockquote class="uncited"><div>...<br>Sorry, I badly said the thing...<br>stackKicks may work, but the way the list was sent seems strange to me:<div class="codebox"><p>Code: </p><pre><code>stackKicks $chan [join $users] $reason 4</code></pre></div></div></blockquote>Fair enough, was afraid I had overlooked something in there.<br><br>Sorry about not noticing the addition of string trim in your sample-code, or I would had cited it in my previous reply.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jul 29, 2020 11:51 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-29T10:59:11-04:00</updated>

		<published>2020-07-29T10:59:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108818#p108818</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108818#p108818"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108818#p108818"><![CDATA[
excellent CrazyCat that fixed it much apreciated so far all working well thnx CrazyCat and nml375<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Jul 29, 2020 10:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2020-07-29T10:50:03-04:00</updated>

		<published>2020-07-29T10:50:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108817#p108817</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108817#p108817"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108817#p108817"><![CDATA[
<blockquote class="uncited"><div>The problem is that the trailing space in the enumeration of nicks becomes an empty element when you split the substring.<br>I think you'd be able to use something like <em class="text-italics">string trim</em> to remove the space(s) once you've separated the reason from the nicks...</div></blockquote>simo, see my previous code (my test in <a href="http://forum.egghelp.org/viewtopic.php?p=108811#108811" class="postlink">http://forum.egghelp.org/viewtopic.php?p=108811#108811</a> ):<div class="codebox"><p>Code: </p><pre><code>foreach user [split [string trim $text]] {</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Wed Jul 29, 2020 10:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2020-07-29T11:53:59-04:00</updated>

		<published>2020-07-29T10:47:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108816#p108816</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108816#p108816"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108816#p108816"><![CDATA[
On my mobile right now, so I'll be brief...<br>The problem is that the trailing space in the enumeration of nicks becomes an empty element when you split the substring.<br>I think you'd be able to use something like <em class="text-italics">string trim</em> to remove the space(s) once you've separated the reason from the nicks...<br><br>Edit: See code by CrazyCat in a previous post for a good example how to implement this.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jul 29, 2020 10:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2020-07-29T10:46:47-04:00</updated>

		<published>2020-07-29T10:46:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108815#p108815</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108815#p108815"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108815#p108815"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div>...<br>So, the trouble is just in stackKicks where the list is badly managed</div></blockquote>I'm sorry I don't quite follow you there...</div></blockquote>Sorry, I badly said the thing...<br>stackKicks may work, but the way the list was sent seems strange to me:<div class="codebox"><p>Code: </p><pre><code>stackKicks $chan [join $users] $reason 4</code></pre></div>So, $users is a list, and it's joined when sending to stackKicks ? Bad idea imho:<div class="codebox"><p>Code: </p><pre><code>% set text "\[Guru\] Galaad CrazyCat {test0r}"[Guru] Galaad CrazyCat {test0r}% set users [list]% foreach user [split $text] { lappend users $user }% puts $users{[Guru]} Galaad CrazyCat {{test0r}}% puts [join $users][Guru] Galaad CrazyCat {test0r}</code></pre></div>It's not anymore a list<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Wed Jul 29, 2020 10:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-29T10:37:54-04:00</updated>

		<published>2020-07-29T10:37:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108814#p108814</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108814#p108814"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108814#p108814"><![CDATA[
tnx for the explanation nml375<br><br>ive come another issue with the custom kick reason  added<br><br>when i do:<br><blockquote class="uncited"><div> .k nick {nick} </div></blockquote>it kicks  fine with the default kick reason but when i do like:<br><blockquote class="uncited"><div>  .k nick {nick} .some custom reason </div></blockquote>it complains with :<br><blockquote class="uncited"><div>  is not on channel  </div></blockquote>but it kicks both tho so that part works except the custom reason part<br><br>i suspect it sees the kick reason as a nick to kick as well<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Jul 29, 2020 10:37 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2020-07-29T10:03:06-04:00</updated>

		<published>2020-07-29T10:03:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108813#p108813</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108813#p108813"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108813#p108813"><![CDATA[
<blockquote class="uncited"><div>...<br>So, the trouble is just in stackKicks where the list is badly managed</div></blockquote>I'm sorry I don't quite follow you there...<br><br>stackKicks expects a list of nicks, and properly handles that list as a list as far as I can tell. For me, it would only break if you pass something other than a list to it (such as squashing the list with that join in the end). Would you mind elaborate how it is badly managed?<br><blockquote class="uncited"><div>...<br>and about the stackicks proc could you show me how to use the lreplace in it as im kinda confused how to integrate it<br><br>i assume you meant the :<br><br>set users [join [lrange $kicklist 0 [expr {$max - 1}]] ","]</div></blockquote>No, that part is perfectly fine. It's the second line, where you remove the first elements:<div class="codebox"><p>Code: </p><pre><code>set kicklist [lrange $kicklist $max end]</code></pre></div>However, iterating over that code yet another time, I realize I messed up on that one; lreplace expects a list as input, not a varName - thus we'd still have to use <em class="text-italics">set</em> to update the variable. Must've had lappend in my mind (which obviously does the complete opposite to what we are trying to achieve here).<br>However, for reference this is how you'd use lreplace in your scenario:<div class="codebox"><p>Code: </p><pre><code>set kicklist [lreplace $kicklist 0 [expr {$max -1}]]</code></pre></div>Not sure if this actually ended up more readable... (would make more sense if you'd have to change or remove items in the middle of the list).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jul 29, 2020 10:03 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-29T09:46:55-04:00</updated>

		<published>2020-07-29T09:46:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108812#p108812</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108812#p108812"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108812#p108812"><![CDATA[
thank you CrazyCat apreciated<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Jul 29, 2020 9:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2020-07-29T09:44:11-04:00</updated>

		<published>2020-07-29T09:44:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108811#p108811</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108811#p108811"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108811#p108811"><![CDATA[
You wrote your post as I was testing.<br><br>I was thinking the trouble was in the $user, but it is when appending the list $users. Adding a string which contains special chars adds {} to protect it.<br><br>Small test:<div class="codebox"><p>Code: </p><pre><code>bind pub - .k pub:kickerproc pub:kicker {nick uhost handle chan text} {set text  [lindex [split $text "."] 0]set users [list]foreach user [split [string trim $text]] {#putlog "looking for *$user*"if {![onchan $user $chan]} {putlog "Can't find *$user*"} else {putlog "Will kill *$user*"lappend users $user}}putlog "List is //$users//"foreach user2 $users {putlog "And now *$user2*"}}</code></pre></div>IRC: .k [Guru] Galaad CrazyCat {test0r} .my reason<div class="codebox"><p>Code: </p><pre><code>[15:19] Will kill *[Guru]*[15:19] Will kill *Galaad*[15:19] Will kill *CrazyCat*[15:19] Will kill *{test0r}*[15:19] list is //{[Guru]} Galaad CrazyCat {{test0r}}//[15:19] And now *[Guru]*[15:19] And now *Galaad*[15:19] And now *CrazyCat*[15:19] And now *{test0r}*</code></pre></div>So, the trouble is just in stackKicks where the list is badly managed<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Wed Jul 29, 2020 9:44 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-29T09:45:36-04:00</updated>

		<published>2020-07-29T09:40:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108810#p108810</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108810#p108810"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108810#p108810"><![CDATA[
excellent tnx nml375 that fixed it<br>and about the stackicks proc could you show me how to use the lreplace in it as im kinda confused how to integrate it<br><br>i assume you meant the :<br><br> set users [join [lrange $kicklist 0 [expr {$max - 1}]] ","]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Jul 29, 2020 9:40 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2020-07-29T10:05:03-04:00</updated>

		<published>2020-07-29T09:09:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108808#p108808</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108808#p108808"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108808#p108808"><![CDATA[
Figured I'd butt my head in here...<br>There is indeed issues with mixing list- and string-types in this script:<br><br>Starting from the initial script:<div class="codebox"><p>Code: </p><pre><code>   set users [list]   set reason [join [lrange [split $text "."] 1 end] "."]   set text [lindex [split $text "."] 0]</code></pre></div><em class="text-italics">users</em> is an (empty) list<br><em class="text-italics">reason</em> is a (sub)string of everything past the first "." on the "commandline"<br><em class="text-italics">text</em> is a (sub)string of everything before the first "." on the "commandline"<br><br>Moving on...<div class="codebox"><p>Code: </p><pre><code>   foreach user [split $text] {</code></pre></div>We want to build a list of users; <em class="text-italics">text</em> is a string presumably with an enumeration of nicks separated with space. Thus, we use <em class="text-italics">split</em> to get a list of strings (nicknames).<br><div class="codebox"><p>Code: </p><pre><code>      set user [join $user]</code></pre></div>This is just wrong; <em class="text-italics">foreach</em> iterates through each list-member - which in this instance is a string. Don't try to <em class="text-italics">join</em> it here, or you'll try to parse {} as list delimiters (and they'll disappear, or the code breaks due to a malformed list).<br><br>Next...<div class="codebox"><p>Code: </p><pre><code>      if {![onchan $user $chan]} {         putserv "NOTICE $nick $user is not on channel $chan"      } else {         lappend users $user      }</code></pre></div>Unless you are using some arcane IRC-server that I havn't kept up to date with, the text-argument for a NOTICE-command needs to be prefixed with : if it contains spaces<div class="codebox"><p>Code: </p><pre><code>putserv "NOTICE $nick :$user is not on channel $chan"</code></pre></div>lappend appends the (string) <em class="text-italics">user</em> to the list <em class="text-italics">users</em>. That is legit.<br><br>Finally...<div class="codebox"><p>Code: </p><pre><code>   stackKicks $chan [join $users] $reason 4</code></pre></div>Here we take our list of nicks to be kicked, and squash it into a string; which is not so good given that stackKicks actually expects a list of nicknames, not a string...<br>Drop the <em class="text-italics">join</em>.<br><br>Now, for stackKicks:<div class="codebox"><p>Code: </p><pre><code>proc stackKicks {chan kicklist reason {max 4}} {   set count [llength $kicklist]   while {$count &gt; 0} {</code></pre></div>So we expect kicklist to be a list of nicks, and we iterate over it using a while-loop.<br><div class="codebox"><p>Code: </p><pre><code>      if {$count &gt; $max} {         set users [join [lrange $kicklist 0 [expr {$max - 1}]] ","]         set kicklist [lrange $kicklist $max end]         incr count -$max</code></pre></div>If there's more than <em class="text-italics">max</em> entities remaining in the list, grab the first <em class="text-italics">max</em> items, and squash then down to a string with "," as separator.<br>Then trim the first <em class="text-italics">max</em> entities off the kicklist.<br><br>Edit: disregard this part, as it's not really valid:<br><span style="color:yellow">You could probably gain some readability and performance by using <em class="text-italics">lreplace</em> instead of <em class="text-italics">set ... [lrange ...]</em>, but it's still fully functional. </span><br><br>Finally decrement <em class="text-italics">count</em> so we don't get stuck in an infinite loop. Good!<br><br><div class="codebox"><p>Code: </p><pre><code>      } else {         set users [join $kicklist ","]         set count 0      }</code></pre></div>Otherwise, we just grab the whole (remaining) list, and squash it.<br><div class="codebox"><p>Code: </p><pre><code>      putnow "KICK $chan $users $reason"</code></pre></div>Finally, we send a KICK-command to the server; once again, if the last argument contains spaces, it should be prefixed with :<br><br><br>Sorry if I got a bit lengthy...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jul 29, 2020 9:09 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-29T09:24:16-04:00</updated>

		<published>2020-07-29T08:48:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108807#p108807</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108807#p108807"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108807#p108807"><![CDATA[
tnx CrazyCat i tried that one and gave me same result it stripped the {} and returns:  Aron is not on channel<br>while the nick is actually {Aron}<br><br><br>also doesnt the :  <br><br>lappend users $user <br><br>already store the nicks ? instead of using another :<br><br>set user [join $user]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Wed Jul 29, 2020 8:48 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2020-07-29T02:18:57-04:00</updated>

		<published>2020-07-29T02:18:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108806#p108806</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108806#p108806"/>
		<title type="html"><![CDATA[wont kick nicks with chars like {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108806#p108806"><![CDATA[
<blockquote class="uncited"><div>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</div></blockquote>I don't understand what you mean...<br>I said you to do:<div class="codebox"><p>Code: </p><pre><code>bind pub n .k pub:kickerproc 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] {      set user [join $user]      if {![onchan $user $chan]} {         putserv "NOTICE $nick $user is not on channel $chan"      } else {         lappend users $user      }   }   stackKicks $chan [join $users] $reason 4}</code></pre></div>Just add a line after the foreach.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Wed Jul 29, 2020 2:18 am</p><hr />
]]></content>
	</entry>
	</feed>
