<?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/20829" />

	<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-30T20:44:13-04:00</updated>

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

		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-30T20:44:13-04:00</updated>

		<published>2020-07-30T20:44:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108830#p108830</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108830#p108830"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108830#p108830"><![CDATA[
thats even better thanx  CrazyCat<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Thu Jul 30, 2020 8:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2020-07-30T18:00:04-04:00</updated>

		<published>2020-07-30T18:00:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108829#p108829</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108829#p108829"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108829#p108829"><![CDATA[
I'll made a short critic about the script...<br><br>You set a "max" variable ("define the max amount of modes per line") and after various calculation and manipulation you use:<div class="codebox"><p>Code: </p><pre><code>putnow "MODE $chan +$mode $users"</code></pre></div>I think that if you use the good tcl commands (pushmode &amp; flushmode), you can really simplify your procedure:<div class="codebox"><p>Code: </p><pre><code>proc voice_all {nick host handle chan text} {global excnickif {![botisop $chan]} {puthelp "NOTICE $nick :I'm not oped on $chan."return 0}   # build the op list with only people that aren't op or any other channel access levelset voiced 0foreach user [chanlist $chan] {if {($user ne $::botnick) &amp;&amp; ![isvoice $user $chan] &amp;&amp; ![isop $user $chan] &amp;&amp; ![ishalfop $user $chan] &amp;&amp; ![matchattr [nick2hand $user] o|o $chan]  &amp;&amp; [lsearch -nocase $excnick $user] == -1} {incr voicedpushmode $chan +v $user}    }flushmode $chanif { $voiced == 0} {puthelp "NOTICE $nick :Nobody needed to be Voiced on $chan."} else {puthelp "NOTICE $nick :Voiced all users on $chan."}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Thu Jul 30, 2020 6:00 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2020-07-30T13:11:24-04:00</updated>

		<published>2020-07-30T13:11:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108828#p108828</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108828#p108828"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108828#p108828"><![CDATA[
You're welcome,<br>I tried to cover the most common mistakes I've seen over the years, though there certainly are other pitfalls. Understanding when and how substitutions and escaping occurs is really the name of the game here.<br><br>The <em class="text-italics">list</em> command does guarantee a valid list (will not break on <em class="text-italics">foreach</em>, <em class="text-italics">lindex</em>, etc), but you still need to make sure the input isn't mangled by the tcl interpreter before <em class="text-italics">list</em> gets it hands on it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Jul 30, 2020 1:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-30T13:06:07-04:00</updated>

		<published>2020-07-30T13:06:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108827#p108827</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108827#p108827"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108827#p108827"><![CDATA[
excellent thank you nml375 for the explanation and the provided examples much apreciated<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Thu Jul 30, 2020 1:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2020-07-30T12:49:39-04:00</updated>

		<published>2020-07-30T12:49:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108826#p108826</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108826#p108826"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108826#p108826"><![CDATA[
Certainly; though the man-page for list do have a few good examples: <a href="https://www.tcl.tk/man/tcl8.6/TclCmd/list.htm" class="postlink">https://www.tcl.tk/man/tcl8.6/TclCmd/list.htm</a><br><div class="codebox"><p>Code: </p><pre><code>#sampe 1set excnick [list chanserv somenick]#sample 2set excnick [list \  chanserv \  somenick \]#sample 3, adding the value of the global variable ::botnick to the list.set excnick [list "chanserv" \  somenick $::botnick]</code></pre></div>Be cautious though, as you still go through variable- and command-substitutions, as well as syntax checks in the tcl-interpreter:<div class="codebox"><p>Code: </p><pre><code>#this will not work well;set uxcnick [list badnick{ \badnick2 \}badnick3 ]#this one might surprise youset excnick [list "chanserv" \{somenick} \]#result is "chanserv somenick"#What you probably wanted:set excnick [list "chanserv" \"{somenick}" \"{othernick" \]#result is "chanserv {{somenick}} \{othernick"#"lindex $excnick 0" =&gt; "chanserv"#"lindex $excnick 1" =&gt; "{somenick}"#"lindex $excnick 2" =&gt; "{othernick"#Another one:set excnick [list "chanserv" \{$botnick} \]#result is "chanserv {$botnick}"#"lindex $excnick 1" =&gt; "$botnick"#note that there is no variable substitution done due to the use of braces</code></pre></div>Somewhat simplified, an atomic item on the command line may be a single word (no quotes or braces), a substitutable string (enclosed in quotes), or a plain string (enclosed in braces, or {}). That's why <em class="text-italics">list "chanserv" {somenick}</em> produced a list with the strings "chanserv" and "somenick", and <em class="text-italics">list "chanserv" {$botnick}</em> created a list containing the strings "chanserv" and "$botnick".<br><br>Finally, the backspaces are needed to escape the newline character into a whitespace character, as newline otherwize would terminate the commandline early (and there's alot of more trickery that can be done with escaping).<br><br>You'll also find a decent readup on the various substitutions done by the tcl interpreter here: <a href="https://www.tcl.tk/man/tcl8.6/TclCmd/Tcl.htm" class="postlink">https://www.tcl.tk/man/tcl8.6/TclCmd/Tcl.htm</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Jul 30, 2020 12:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-30T12:12:22-04:00</updated>

		<published>2020-07-30T12:12:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108825#p108825</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108825#p108825"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108825#p108825"><![CDATA[
excellent tnx for the explanation nml375<br><br>about the list i tried searching for it in the docs couldnt find it  would you have any example i can use as a template cause we might want to add nicks wich may contain list formatting chars as u mentioned we want to have it optional anyway <br><br>tnx once again nml375 much apreciated<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Thu Jul 30, 2020 12:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2020-07-30T11:55:25-04:00</updated>

		<published>2020-07-30T11:55:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108824#p108824</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108824#p108824"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108824#p108824"><![CDATA[
Hi Simo,<br>Going to try and not make a complete teardown of the script this time...<br><br>But...<br>Lets start here:<div class="codebox"><p>Code: </p><pre><code>set userList [chanlist $chan]set pos [lsearch -nocase $userList $::botnickset userList [lreplace $userList $pos $pos]</code></pre></div>Here, we treat <em class="text-italics">userList</em> as an actual list (which it is); so far so good.<br><br>But then, we get here:<div class="codebox"><p>Code: </p><pre><code>foreach user [split $userList] {</code></pre></div><em class="text-italics">split</em> is really only intended to be used on strings, not lists. Remove it, as <em class="text-italics">userList</em> already is a list.<br><br>Next;<div class="codebox"><p>Code: </p><pre><code> if {... &amp;&amp; [lsearch -nocase $excnick $user] ...</code></pre></div>Here, we treat <em class="text-italics">excnick</em> as a list, but to be honest it's merely a list-like string;<div class="codebox"><p>Code: </p><pre><code>set excnick {    "chanserv"    "somenick"}</code></pre></div>You'll get away with it for as long as your exclusion-nicks does not contain list-formatting characters such as {}... Consider creating a proper list using the <em class="text-italics">list</em> command instead.<br><br>In the end, you've got some code iterating through a list of nicks, trying to build optimal MODE commands (stack multiple mode changes in one command, not unlike the KICK-stacking in your previous thread). Technically nothing obviously wrong with the code; I just wanted to point out that this functionality is already implemented in eggdrop itself using the <em class="text-italics">pushmode</em> command (which will queue all mode changes until the binding returns, and then stack them properly).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Jul 30, 2020 11:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simo]]></name></author>
		<updated>2020-07-30T11:31:15-04:00</updated>

		<published>2020-07-30T11:31:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=108823#p108823</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=108823#p108823"/>
		<title type="html"><![CDATA[same issue with massvoice and nicks with {}]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=108823#p108823"><![CDATA[
simmilarly as the previous one i checked what it could be and i couldnt find any thing why it wouldnt set voice on nicks with {} in them like {somenick}<br><div class="codebox"><p>Code: </p><pre><code>bind pub n .mv voice_all set excnick {     "chanserv"     "somenick" }  proc voice_all {nick host handle chan text} {global excnickif {![botisop $chan]} {      puthelp "NOTICE $nick :I'm not oped on $chan."      return   }     # grab the channel members list and exclude the bot from it   set userList [chanlist $chan]   set pos [lsearch -nocase $userList $::botnick]   set userList [lreplace $userList $pos $pos]    # build the op list with only people that aren't op or any other channel access level   foreach user [split $userList] {    if {![isvoice $user $chan] &amp;&amp; ![isop $user $chan] &amp;&amp; ![ishalfop $user $chan] &amp;&amp; ![matchattr [nick2hand $user] o|o $chan]  &amp;&amp; [lsearch -nocase $excnick $user] == -1} {  lappend voiceList $user }    }    # define the max amount of modes per line   set max 15    # op all the members in the above built voice list   if {[info exists voiceList]} {      set len [llength $voiceList]      while {$len &gt; 0} {         if {$len &gt; $max} {         set mode [string repeat "v" $max]         set users [join [lrange $voiceList 0 [expr {$max - 1}]]]         set voiceList [lrange $voiceList $max end]         incr len -$max         } else {            set mode [string repeat "v" $len]            set users [join $voiceList]            set len 0         }      putnow "MODE $chan +$mode $users"       }      puthelp "NOTICE $nick :Voiced all users on $chan."   } else {      puthelp "NOTICE $nick :Nobody needed to be Voiced on $chan."   }}</code></pre></div>it adds {} to the nicks for example<br>a nick like {ykbeucwvi} would be seen as {{ykbeucwvi}}<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12505">simo</a> — Thu Jul 30, 2020 11:31 am</p><hr />
]]></content>
	</entry>
	</feed>
