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

	<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-03-02T03:54:13-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Fill]]></name></author>
		<updated>2009-03-02T03:54:13-04:00</updated>

		<published>2009-03-02T03:54:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87654#p87654</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87654#p87654"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87654#p87654"><![CDATA[
Done the anti-flood system (based on some other scripts I had here  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"> )<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10430">Fill</a> — Mon Mar 02, 2009 3:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Fill]]></name></author>
		<updated>2009-03-01T14:27:10-04:00</updated>

		<published>2009-03-01T14:27:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87647#p87647</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87647#p87647"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87647#p87647"><![CDATA[
thanks. worked <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Now I'd like to add an anti-flood system.<br><br>This works with a command (!duck), and I want the bot to set a 5 minutes ignore if a certain host (*!*@host) sends more than 1 !duck in 10 seconds. How can I make this?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10430">Fill</a> — Sun Mar 01, 2009 2:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-03-01T08:08:56-04:00</updated>

		<published>2009-03-01T08:08:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87640#p87640</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87640#p87640"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87640#p87640"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>global duck(list) </code></pre></div>You cannot global only one element of the array, you must global the entire array.<div class="codebox"><p>Code: </p><pre><code>global duck</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sun Mar 01, 2009 8:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Fill]]></name></author>
		<updated>2009-03-01T06:12:07-04:00</updated>

		<published>2009-03-01T06:12:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87637#p87637</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87637#p87637"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87637#p87637"><![CDATA[
got an error message with the created list:<br><br>[Sun-10:13:01am] « RoBotX » [10:13] Tcl error [testing]: bad variable name "duck(list)": upvar won't create a scalar variable that looks like an array element<br><br>It is now like this:<br><div class="codebox"><p>Code: </p><pre><code>set duck(list) [list \"Message 1" \"Message 2" \"Message 3" \"Message 4" \"Message 5" \"Message 6" \"Message 7" \"Message 8" \"Message 9" \"Message 10" \"Message 11" \]proc testing { nick uhost hand chan args } {global duck(list)set message [lindex $duck(list) [rand [llength $duck(list)]]]puthelp "PRIVMSG $chan :\001ACTION $message"}</code></pre></div>But I get that message in dcc session :/<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10430">Fill</a> — Sun Mar 01, 2009 6:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Fill]]></name></author>
		<updated>2009-03-01T05:26:31-04:00</updated>

		<published>2009-03-01T05:26:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87636#p87636</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87636#p87636"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87636#p87636"><![CDATA[
ahmm I see, so my list is a pseudo-list  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_lol.gif" width="15" height="15" alt=":lol:" title="Laughing">  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_lol.gif" width="15" height="15" alt=":lol:" title="Laughing"> <br><br>A normal and correct list would be something like nml375 posted? Thanks for the tips. I guess I'll try to make a REAL list, I didn't know my list was incorrect  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"> <br><br>Once again, I appreciate a lot your help nml375 and speechles<br><br>See ya <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=10430">Fill</a> — Sun Mar 01, 2009 5:26 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-02-28T18:41:51-04:00</updated>

		<published>2009-02-28T18:41:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87621#p87621</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87621#p87621"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87621#p87621"><![CDATA[
Another workaround would be to define the list properly, in which case you would'nt get any empty elements (yet perhaps a bit uglier code)<br><div class="codebox"><p>Code: </p><pre><code>set duck(list) [list \"Message 1" \"Message 2" \"Message 3" \"Message 4" \"Message 5" \"Message 6" \"Message 7" \"Message 8" \"Message 9" \"Message 10" \"Message 11" \]set message [lindex $duck(list) [rand [llength $duck(list)]]]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Feb 28, 2009 6:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-02-28T18:30:27-04:00</updated>

		<published>2009-02-28T18:30:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87620#p87620</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87620#p87620"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87620#p87620"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>while {![string length [set message [lindex $duck(list) [rand [llength $duck(list)]]]]]} { }</code></pre></div>That would do it. The main reason to use the while and checking for string length is because the first and last entries in your pseudo list are going to be empty strings (nulls) and obviously we want to avoid those. This is why I'm nesting an empty field after the while, because we are using the set command to set the message within the while statement, so the loop which runs really doesn't need to do anything (it's why its { }) except run the while check over and over until we have a string with length to it.<br><br>Conversely, you can use expr to remove the first and last elements from the length of your pseudo list (-2) and then run rand over that and add one (+1) to the outcome which will work exactly as the while loop does above, skipping the first and last empty entries.<div class="codebox"><p>Code: </p><pre><code>set message [lindex $duck(list) [expr {[rand [llength $duck(list) - 2]] + 1}]]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sat Feb 28, 2009 6:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Fill]]></name></author>
		<updated>2009-02-28T18:15:10-04:00</updated>

		<published>2009-02-28T18:15:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87619#p87619</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87619#p87619"/>
		<title type="html"><![CDATA[Select a random part of the variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87619#p87619"><![CDATA[
Hey guys, here I am asking for your help --&gt; *again* ^^<br><br>I have a variable like this:<br><div class="codebox"><p>Code: </p><pre><code>set duck(list) {"Message 1""Message 2""Message 3""Message 4""Message 5""Message 6""Message 7""Message 8""Message 9""Message 10""Message 11"etc etc...}</code></pre></div>How can I make the bot read RANDOMLY one of the messages in variable $duck(list)?<br>Oh, and no, I can't have the messages in a *.txt file, because those messages have other variables in their content, so if they were saved in a file, the variables wouldn't be read and something like this would happen:<br><div class="codebox"><p>Code: </p><pre><code>[Sat-10:10:42pm] « @RoBotX » You should have gone here: $bgl</code></pre></div>Once again, thanks in advance for the help.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10430">Fill</a> — Sat Feb 28, 2009 6:15 pm</p><hr />
]]></content>
	</entry>
	</feed>
