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

	<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>2011-04-24T06:18:24-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2011-04-24T06:17:10-04:00</updated>

		<published>2011-04-24T06:17:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96734#p96734</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96734#p96734"/>
		<title type="html"><![CDATA[5 Lines MSG]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96734#p96734"><![CDATA[
Thanks for your comment, speechless.<br><br>You pointed out some flaws in my script, but it isn't as bad as you understood it. <br><br>My script only answers, if someone writes 5 lines in a row, without being interrupted by another person (I think thats what OP wanted.).<br>Notice, that my array is fivelines(nick|$chan), not fivelines($nick|$chan), so it wont create an entry for every user in the channel, nor would it require every user of the channel to be in it. (So it wont error on rehash/etc)<br><br>Still my array wasn't optimal, and I used an info exists line in exchange.<br><br><br>And thanks for the rand function! I didn't know it before.<br><br><br>New script:<br><div class="codebox"><p>Code: </p><pre><code>####5lines.tcl### Settings## The channels the script should be active in, seperated by spaces# (leave empty for all channels)set fivelines(channels) ""## How many lines to write, to get an answerset fivelines(count) 5### A list with things the bot can answer## (possible "variables" are %c (channel) %n (nick) %b (botnick))#set fivelines(answers) {"%n Thank You!!! You're chatting so good. ;)""Hello %n, could you stop spamming now? :&gt;""Hurr durr, I am %b the mighty ruler of %c"}####End of settings####bind pubm - * pubm_fivelines_counterset fivelines(channels) [split $fivelines(channels)]proc pubm_fivelines_counter {nick host hand chan text} {global fivelinesif {[lsearch $fivelines(channels) $chan] != -1} {if {[info exists fivelines(nick|$chan)]} {if {$fivelines(nick|$chan) == $nick} {incr fivelines(counter|$chan)if {$fivelines(counter|$chan) &gt;= $fivelines(count)} {set answer [lindex $fivelines(answers) [rand [llength $fivelines(answers)]]]regsub -all "%c" $answer $chan answerregsub -all "%n" $answer $nick answerregsub -all "%b" $answer $::botnick answerputserv "PRIVMSG $chan :$answer"set fivelines(counter|$chan) 0}} else {set fivelines(counter|$chan) 1set fivelines(nick|$chan) $nick}} else {set fivelines(counter|$chan) 1set fiveliens(nick|$chan) $nick}}[}</code></pre></div>edit: added missing last close brace<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Sun Apr 24, 2011 6:17 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-04-23T23:55:46-04:00</updated>

		<published>2011-04-23T23:55:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96730#p96730</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96730#p96730"/>
		<title type="html"><![CDATA[5 Lines MSG]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96730#p96730"><![CDATA[
<blockquote class="uncited"><div>*snipped long code*</div></blockquote>Nimos, when new users join the channel, after any rehash/restart/etc .. (ones that were not previously in that channel before the rehash) rejoins your channel that script will cause errors for those nicknames.<br><div class="codebox"><p>Code: </p><pre><code>foreach chan $fivelines(channels) {set fivelines(counter|$chan) 0set fivelines(nick|$chan) ""}</code></pre></div>You use this code to intialize a huge array in global space for some reason. Rather than, using [info exists] command and using this to tell an initialized (aka, empty) array.<br><br>You then make this call to your procedure:<div class="codebox"><p>Code: </p><pre><code>if {$fivelines(nick|$chan) == $nick} {</code></pre></div>This will cause an error for any nickname that wasn't present when you previously initialized the array. It should be based around [info exists] imo. Using a series of sets does not work dynamically how you have done it. Just words of advice. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>As people chat, you add them to the array, only then do they eat memory. Until then we use [info exist] to tell if each nick is, or is not, already added to our array. If it's not then "set fivelines($nick|$chan) 1". If it is, then [incr] it ever after based on that until we hit the magic number 5.<br><br>Also...<br><div class="codebox"><p>Code: </p><pre><code>[expr round(rand() * ([llength $fivelines(answers)] - 1))]]</code></pre></div>Might want to brace that [expr {}] to speed it up 1000% and to keep any issues with $fivelines variable from containing any exploits or substitution errors... and just do...<div class="codebox"><p>Code: </p><pre><code>[rand [llength $fivelines(answers)]]</code></pre></div>which is same thing as your long code above in proper form without that nasty expr and needless round required because of that -1 you do to llength. Otherwise your code would never use the last element in the $fiveline(answers) list, which it will do rarely, not evenly like your rand suggest it would. In your list of three you can test this yourself, and do 3 queries. Multiple  times. So 3 queries 20x. So 60x total. In those, the most ever the last element can appear as the result of those 60. Is 10 times. One sixth. 1/6.  Half of what true random would be for 3 items, and making 60 queries. It should be 1/3rd, or 20/60th's. This is because of reasons having to do with your code versus mine and as I said only affects the last element in the list. My code above works correctly showing each of the 3 items 20 times if 60 requests were made and the list was only 3 lines long.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sat Apr 23, 2011 11:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2011-04-24T06:18:24-04:00</updated>

		<published>2011-04-23T20:13:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96728#p96728</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96728#p96728"/>
		<title type="html"><![CDATA[5 Lines MSG]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96728#p96728"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>####5lines.tcl#### OUTDATED VERSION, USE THE SCRIPT BELOW!#### Settings## The channels the script should be active in, seperated by spaces# (leave empty for all channels)set fivelines(channels) ""## How many lines to write, to get an answerset fivelines(count) 5### A list with things the bot can answer## (possible "variables" are %c (channel) %n (nick) %b (botnick))#set fivelines(answers) {"%n Thank You!!! You're chatting so good. ;)""Hello %n, could you stop spamming now? :&gt;""Hurr durr, I am %b the mighty ruler of %c"}####End of settings####bind pubm - * pubm_fivelines_counterset fivelines(channels) [split $fivelines(channels)]set fivelines(counter) 0foreach chan $fivelines(channels) {set fivelines(counter|$chan) 0set fivelines(nick|$chan) ""}putlog [join [array get fivelines] \n]proc pubm_fivelines_counter {nick host hand chan text} {global fivelinesif {[lsearch $fivelines(channels) $chan] != -1} {if {$fivelines(nick|$chan) == $nick} {incr fivelines(counter|$chan)if {$fivelines(counter|$chan) &gt;= $fivelines(count)} {set answer [lindex $fivelines(answers) [expr round(rand() * ([llength $fivelines(answers)] - 1))]]regsub -all "%c" $answer $chan answerregsub -all "%n" $answer $nick answerregsub -all "%b" $answer $::botnick answerputserv "PRIVMSG $chan :$answer"set fivelines(counter|$chan) 0}} else {set fivelines(counter|$chan) 1set fivelines(nick|$chan) $nick}}}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Sat Apr 23, 2011 8:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Regex]]></name></author>
		<updated>2011-04-11T15:43:08-04:00</updated>

		<published>2011-04-11T15:43:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96647#p96647</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96647#p96647"/>
		<title type="html"><![CDATA[5 Lines MSG]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96647#p96647"><![CDATA[
Hi Dear Coders..<br><br>I need your help..<br><br>How can we do 5 lines tcl..<br><br>when person says 5 lines in my channels, my eggdrop bot will send a message to person.<br><br>Example:<br><br>&lt;Jackie&gt; Hi<br>&lt;Jackie&gt; How are u ?<br>&lt;Jackie&gt; I'm so good.<br>&lt;Jackie&gt; Imm..<br>&lt;Jackie&gt; Where are u from ?<br>&lt;Eggdrop&gt; Jackie Thank You!!! You're chatting so good. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br>&lt;Jackie&gt; Imm<br>&lt;Jackie&gt; My Pleasure<br>&lt;Jackie&gt; Im so happy now <br>&lt;Jackie&gt; <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br>&lt;Jackie&gt; ..<br>&lt;Eggdrop&gt; Jackie Thank You!! You're chatting so good. <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=11617">Regex</a> — Mon Apr 11, 2011 3:43 pm</p><hr />
]]></content>
	</entry>
	</feed>
