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

	<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>2008-05-25T17:19:31-04:00</updated>

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

		<entry>
		<author><name><![CDATA[metroid]]></name></author>
		<updated>2008-05-25T17:19:31-04:00</updated>

		<published>2008-05-25T17:19:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83212#p83212</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83212#p83212"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83212#p83212"><![CDATA[
I didn't read nml375's wall of text but you seem to be missing the handle var which is required for pubm binds.<br><br>I'd be suprised if your script worked as expected.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5078">metroid</a> — Sun May 25, 2008 5:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-05-24T18:30:20-04:00</updated>

		<published>2008-05-24T18:30:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83168#p83168</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83168#p83168"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83168#p83168"><![CDATA[
thanks for your explanations!<br><br>everything works fine now!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Sat May 24, 2008 6:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-24T16:48:41-04:00</updated>

		<published>2008-05-24T16:48:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83166#p83166</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83166#p83166"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83166#p83166"><![CDATA[
The thing here, is that lrange returns a list, not a string.<div class="codebox"><p>Code: </p><pre><code>set com [lrange [split $text " " ] 3 end]</code></pre></div>Here <em class="text-italics">com</em> is set to be a list, consisting of the 4th to last "words" in <em class="text-italics">text</em>.<div class="codebox"><p>Code: </p><pre><code>set targ [lrange [split $com " "] 1 end]</code></pre></div>Here you assume <em class="text-italics">com</em> to be a string (which it is not, it's a list!), and try to split it into a new list. You then extract the 2nd to the last list item, and store it as a list in <em class="text-italics">targ</em>.<div class="codebox"><p>Code: </p><pre><code>...            if {$com == "kick $targ"} {</code></pre></div>Now you compare the list in <em class="text-italics">com</em> to a string consisting of the word "kick" followed by the list in <em class="text-italics">targ</em> (which basically becomes a very awkward string with psuedo-list properties).<br><br>First off, you really, really need to understand the difference between a string and a list. A list has a very delicate structure, whereas a string has pretty much none. Trying to manipulate a list as if it was a string (like "kick $targ") will most likely break the structure of the list. Assuming a string to have list-like structure is just as bad. Also, treating a list as if it was a string (such as [split $com " "]) will produce extra characters such as {} whenever there are non-simple list elements within the list. If you need to convert a list into a string, use the join-command as I illustrated in an earlier post.<br><br>All that said, what you wish to accomplish could be done <strong class="text-strong">alot</strong> simpler;<br><br>1st, convert <em class="text-italics">text</em> to a list, and store it in a new variable (I'll use <em class="text-italics">tlist</em> in this example). Use <strong class="text-strong">split</strong> for this<br><br>2nd, extract the 4th list element from <em class="text-italics">tlist</em>, and store it in a new variable (such as <em class="text-italics">cmd</em>). Since we're only interested in one single list element, we'll use <strong class="text-strong">lindex</strong> rather than <strong class="text-strong">lrange</strong>. Lindex returns the contents of the list-item, rather than a sublist, meaning we do not have to use join here.<br><br>3rd, extract teh 5th list element from<em class="text-italics">tlist</em>, and store it in a new variable (such as <em class="text-italics">target</em>). Do this in the exact same manner as with <em class="text-italics">cmd</em>.<br><br>4th, test the string in <em class="text-italics">cmd</em> against "kick", to see if we should kick or not. I'd suggest using <strong class="text-strong">string equal</strong> for this, as it allows non-case sensitive matching.<br><br>5th, if the above test matches, do the kick using putkick using <em class="text-italics">target</em> as the kick-target.[/code]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat May 24, 2008 4:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-05-24T15:55:01-04:00</updated>

		<published>2008-05-24T15:55:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83165#p83165</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83165#p83165"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83165#p83165"><![CDATA[
ok<br><div class="codebox"><p>Code: </p><pre><code>pind pubm Q "*&lt;/002Nimos/002&gt; bot *" servercmdproc servercmd {nick host chan text} {set com [lrange [split $text " " ] 3 end]set targ [lrange [split $com " "] 1 end]# I know I can set $com better with "3 4" instead of "3 end" now, but when i wrote the script I just used the code u gave me in reply 4 of this thread...if {$chan == "#mychan"} {            if {$com == "kick $targ"} {                     putkick $chan $targ "Requested by Nimos"                     puthelp "privmsg $chan :!say $targ was kicked from IRC!"            } elseif {            #Followed by a couple of other cmd's.....</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Sat May 24, 2008 3:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-24T14:38:25-04:00</updated>

		<published>2008-05-24T14:38:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83164#p83164</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83164#p83164"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83164#p83164"><![CDATA[
Could you post the code?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat May 24, 2008 2:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-05-24T12:45:19-04:00</updated>

		<published>2008-05-24T12:45:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83161#p83161</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83161#p83161"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83161#p83161"><![CDATA[
but whats the difference between this one, and the example above?<br><br>the only one I see is "2 3" instead of "2 end"...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Sat May 24, 2008 12:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-24T08:24:26-04:00</updated>

		<published>2008-05-24T08:24:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83155#p83155</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83155#p83155"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83155#p83155"><![CDATA[
Because you are using it on a string, you should only use it on lists - ever!<br><br>lrange expects the first argument to be a valid tcl list-structure. These may look similar to strings at a first glance, however, they are not. Especially in the case where there's characters such as {[]} (among others), special formatting is done to preserve the structure of the list. If you attempt to use a malformatted list, you'll end up with garbled data and unexpected results.<br><br>If you need to use lrange to extract a substring from a string, you must use it like this (I'll explain why after the example):<div class="codebox"><p>Code: </p><pre><code>#Lets first store our string in a variable, not necessary, but helps keep the example easy-readableset mystring "This is an example string containing odd characters such as {}"#Now store a substring in newvarset newvar [join [lrange [split $mystring " "] 2 3] " "]</code></pre></div>So, what did we do here?<br>First, we stored the string in <em class="text-italics">mystring</em>, so we have something to work with. Next, using <strong class="text-strong">split</strong>, we converted it into a list having space as the separator.<br>Once we have a list, it is safe to pass it to lrange, where we use index 2 and 3 as start- and end-values. This will, however, return a new list, which is not what we really wanted.<br>In order to get a string, we thus use <strong class="text-strong">join</strong> to convert the new list back into a string, once again using a space as the separator; and store it in <em class="text-italics">newvar</em>.<br><br>If <em class="text-italics">mystring</em> would have contained a proper list from the beginning, we should not have <strong class="text-strong">split</strong>'d it in the first place. In the same manner, if we intended to use the result with a command expecting a list (such as <strong class="text-strong">foreach</strong>), we would not <strong class="text-strong">join</strong> it into a string.<br><br>The bottom line is, always keep track of whether the data you are processing is a string or a list; and use the proper commands for it (converting between them when necessary). A good rule of thumb, if the data is coming from a human, consider it a string.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat May 24, 2008 8:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-05-24T07:59:48-04:00</updated>

		<published>2008-05-24T07:59:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83154#p83154</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83154#p83154"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83154#p83154"><![CDATA[
yes, i used lrange in the wildcard bind...<br><br>but why does it work with people without [ ] in their names?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Sat May 24, 2008 7:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-23T16:46:44-04:00</updated>

		<published>2008-05-23T16:46:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83133#p83133</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83133#p83133"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83133#p83133"><![CDATA[
1. Most likely you screwed up somewhere in the code. Without seing the code I could only make fairly educated guesses as to the error. My first guess would be that you use lindex or lrange on a string, which is a huge nono. Second guess would be that you use utimers improperly.<br><br>2. Yup:<div class="codebox"><p>Code: </p><pre><code>set myvar [chanlist &lt;channel&gt;] #store a list of channel-members for &lt;channel&gt;</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri May 23, 2008 4:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-05-23T16:15:35-04:00</updated>

		<published>2008-05-23T16:15:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83131#p83131</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83131#p83131"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83131#p83131"><![CDATA[
works! thanks you!<br><br>now i need 2 more:<br><br>1. I have an !kick bind, but it is not working at ppl with [ ] in the name....how to fix it?<br><br>2. is there a way to put all users in a specified channel into a variable?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Fri May 23, 2008 4:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-22T15:56:41-04:00</updated>

		<published>2008-05-22T15:56:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83108#p83108</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83108#p83108"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83108#p83108"><![CDATA[
If you need wildcards, you indeed need the pubm binding.<br><em class="text-italics">string range &lt;string&gt; &lt;start&gt; &lt;end&gt;</em> selects a substring of &lt;string&gt; defined by the ranges &lt;start&gt; and &lt;end&gt;.<br>Provided that the trigger is fixed-length, you could do something like this:<div class="codebox"><p>Code: </p><pre><code>bind pubm - "% myword *" myprocproc myproc {nick host hand chan text} { set t [string range $text 6 end]}</code></pre></div>This specific case could, however, easily be replaced with a pub-binding.<br><br>If, however, you've got something a bit more complex, you'll most likely end up with using split, lrange, and join:<div class="codebox"><p>Code: </p><pre><code>bind pubm - "% %word *" myprocproc myproc {nick host hand chan text} { set t [join [lrange [split $text " "] 1 end] " "]}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu May 22, 2008 3:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-05-22T15:32:51-04:00</updated>

		<published>2008-05-22T15:32:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83105#p83105</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83105#p83105"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83105#p83105"><![CDATA[
thanks for your answer<br><br>i need a pubm binding because of a wildcard...imho pub binds dont support wildcards, right?<br><br>can you explain 1. more, if possible by giving an example?<br>im not really expierienced in tcl...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Thu May 22, 2008 3:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-22T15:23:05-04:00</updated>

		<published>2008-05-22T15:23:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83104#p83104</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83104#p83104"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83104#p83104"><![CDATA[
1. First off, do you really need pubm binding? At first it almost sounds like a simple pub binding would do.<br>If you do go with pubm, you'll have to use various string manipulation techniques to accomplish what you ask for. One of the simplest, assuming you've got a fixed length trigger, is using "string range". Other options might be converting the string to a list (using split), and then use commands such as lindex or lrange and join to select the desired part.<br><br>2. global <em class="text-italics">varname</em><br>Links the local variable named <em class="text-italics">varname</em> to the globalspace one with the same name.<br><br>3. The difference is in which queue the command is placed within.<br>puthelp has the lowest priority, and will only be sent when the other queues are empty. This is the preferred queue for anything not essential for protecting your channel, as it won't block kicks, modes, etc with non-critical commands.<br>putserv has higher priority than puthelp, but lower than putquick. This queue should be used for important things, such as opping members.<br>putquick has the highest priority, and should only be used for critical commands, such as kicking/banning people trying to take control of your channel, etc.<br><br>A common misconception is that putquick/putserv is faster than puthelp. This is not the case. They all use the same punishment calculator and throttling. puthelp will only be delayed if there is important stuff in the putserv and putquick queues.<br><ul><li>If you are writing a script that outputs some kind of text to the channel, you should always strife to use puthelp - no public chatter is more important than keeping your channel safe. And using puthelp won't hurt performance if your eggie is not used for channel security.</li><li>If you are interacting with nickser/chanserv/etc, or pushing modes with your script, considder using the putserv command, as these would most likely be more important than simple chatter.</li><li>If your script is protecting your channel from floodnets or spammers, use putserv or putquick depending on the urgency of the action. Kicking TO-botnets would probably be more important than removing a spammer, but removing a virus-spreading spammer may be more important than removing a single floodbot.</li></ul><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu May 22, 2008 3:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-05-22T15:03:03-04:00</updated>

		<published>2008-05-22T15:03:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83102#p83102</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83102#p83102"/>
		<title type="html"><![CDATA[A few more Questions:]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83102#p83102"><![CDATA[
1. On a "PUBM" bind, the last var is the whole message. How can I get only     the word after the trigger?<br><br>2. How to use the "Global" variable set comman?<br><br>3. Whats the difference between putserv, puthelp &amp; putquick? and which is best to use?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Thu May 22, 2008 3:03 pm</p><hr />
]]></content>
	</entry>
	</feed>
