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

	<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>2009-06-26T18:59:46-04:00</updated>

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

		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-06-26T18:59:46-04:00</updated>

		<published>2009-06-26T18:59:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89356#p89356</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89356#p89356"/>
		<title type="html"><![CDATA[Help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89356#p89356"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc cmd:tempakill {nick uhost hand args} {  set args [join $args]  set username [lindex $args 0]  set reason [lrange $args 1 end]  putserv "GLINE $username :$reason"  putserv "PRIVMSG #CWStats Temporary GLINE added to $username (Reason) $reason"}</code></pre></div>This entire code is incorrect, everything except the first putserv, the second is incorrect and will never message the channel intended. It is missing the seperating (space)colon after target nick/channel in the PRIVMSG, it simply has the (space)...<br><div class="codebox"><p>Code: </p><pre><code>proc cmd:tempakill {nick uhost hand arg} {  set username [lindex [split $arg] 0]  set reason [join [lrange [split $arg] 1 end]]  putserv "GLINE $username :$reason"  putserv "PRIVMSG #CWStats :Temporary GLINE ($reason -&gt; $username) by $nick."}</code></pre></div>Now let me explain the subtle differences here....<br><br>Notice first off, I've removed your line 2.. and my code is 6 lines versus your 7. Now let's move onto bigger things...<br><br># The proc header, aka, the first line of code<br>You never want to make the mistake of using "args" within your procedure header unless it is invoked by several binds/procedures using differing amounts of arguments. If you don't understand what that means then use "text" or "arg" or literally anything else instead. The reason for this you don't need to understand, but "args" is a reserved word when used within a procedure header. It allows for a variable number of arguments to be passed through the procedure without declaring each argument individually. These arguments are then passed to the procedure as a list. A procedure that is bound to PUB or MSG input will always have a static number of arguments passed making your use of $args in this case very inappropriate. You are having to use more code to return the list $args give you back into a string, and work around this issue than it would be to correctly build your procedure header.<br><br># The lindex, aka line 2...<br>The problem here isn't quite as obvious. Since you have used $args to catch the text of the user you were given a list. But you then used [join $args] to return this to a string. Then you attempt to lindex this string before turning it into a list...But since we need to solve the problem of line 1 first, it is better to [split $arg] and then lindex properly on a list. Never use list commands on strings. Golden rule #1 - section 1<br><br># The lrange, aka line 3...<br>The problem here has the same qualities as number 2. But.. There is a big difference here. Lrange will return a list, not a string like lindex will. Because of this you will need to [join] your lrange back into a string, or risk curly bracings appearing when displaying any contents containing special characters. Doing it correctly special tcl characters never effect your script. Golden rule #1 - section 2<br><br># The solution, aka advice for life...<br> follow all the steps above and this time listen. Follow the <a href="http://www.peterre.info/characters.html" class="postlink"><strong class="text-strong">golden rules</strong></a> (all your issues are discussed here: lindex, lrange, and args). Treat these golden rules as "tcl law" and correct your flawed use of $args and pretend that it is equivalent to typing <strong class="text-strong">.die</strong> in your bot. Just forget it exists unless you want to kill your eggdrop.. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Fri Jun 26, 2009 6:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[username]]></name></author>
		<updated>2009-06-26T17:18:18-04:00</updated>

		<published>2009-06-26T17:18:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89354#p89354</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89354#p89354"/>
		<title type="html"><![CDATA[Help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89354#p89354"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc cmd:tempshun {nick uhost hand arg} {  set victim [lindex [split $arg] 0]  set reason [lrange [split $arg] 1 end]  putserv "TEMPSHUN $nick :$reason"  putserv "PRIVMSG #CWStats :Tempshun Added To $victim by $nick (Reason) $reason"  }</code></pre></div>This is wrong code: <div class="codebox"><p>Code: </p><pre><code>set args [join $args]set username [lindex $args 0] </code></pre></div>You cant use <strong class="text-strong">lindex</strong> in string. <strong class="text-strong">Lindex</strong> for lists only.<br>And you neednt use <strong class="text-strong">join</strong> with $args, because $args already a string.<br><div class="codebox"><p>Code: </p><pre><code>proc cmd:tempakill {nick uhost hand args} {  set victim [lindex [split $args] 0]  set reason [lrange [split $args] 1 end]  putserv "GLINE $victim :$reason"  putserv "PRIVMSG #CWStats :Temporary GLINE added to $victim by $nick (Reason) $reason"}</code></pre></div>And dont forget about <strong class="text-strong">:</strong> in putserv. It looks like this: <em class="text-italics">putserv "Type Destination :Text"</em> <br>Where <em class="text-italics">Type</em> can be PRIVMSG or NOTICE<br><em class="text-italics">Destination</em> can be Nick or Chan and <br><em class="text-italics">Text</em> is text to send to.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6813">username</a> — Fri Jun 26, 2009 5:18 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[LB_1981]]></name></author>
		<updated>2009-06-26T15:04:21-04:00</updated>

		<published>2009-06-26T15:04:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89353#p89353</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89353#p89353"/>
		<title type="html"><![CDATA[Help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89353#p89353"><![CDATA[
Hi can someone help me with this<br> <div class="codebox"><p>Code: </p><pre><code>proc cmd:tempshun {nick uhost hand arg} {  set nick [lindex [split $arg] 0]   set reason [lrange [split $arg] 1 end]   putserv "TEMPSHUN $nick :$reason"  putserv "PRIVMSG #CWStats Tempshun Added To $nick (Reason) $reason"   }</code></pre></div> <br><br>Is what i need it to do is message #cwstats with Tempshun Added To $nick by $username (Reason) $reason. need another set option which is for $username but am not sure how to add the extra set the above code works fine just need that extra set<br><br>need a small change to this one also<br><div class="codebox"><p>Code: </p><pre><code>proc cmd:tempakill {nick uhost hand args} {  set args [join $args]  set username [lindex $args 0]  set reason [lrange $args 1 end]  putserv "GLINE $username :$reason"  putserv "PRIVMSG #CWStats Temporary GLINE added to $username (Reason) $reason" }</code></pre></div>is what im trying to get this to do is the same as above <br>Tempgline Added To $nick by $username (Reason) $reason and also set it so it glines for 4 hours this code also works just need to add the two extras<br><br>many thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10704">LB_1981</a> — Fri Jun 26, 2009 3:04 pm</p><hr />
]]></content>
	</entry>
	</feed>
