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

	<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-02-03T12:38:47-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-02-03T12:38:47-04:00</updated>

		<published>2009-02-03T12:38:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87222#p87222</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87222#p87222"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87222#p87222"><![CDATA[
That performance-issue would be restricted to Tcl 8.0, and would still be flawed with the byte vs char issue...<br>In any case, I fail to see how that is related to the topic.<br><br>@tmyoungjr:<br>I believe <span style="text-decoration:underline">user</span> posted a very flexible throttling-mechanism that could easily be adopted to your script.<br>Check this post: <a href="http://forum.egghelp.org/viewtopic.php?p=75097#75097" class="postlink">http://forum.egghelp.org/viewtopic.php?p=75097#75097</a><br><br><span style="text-decoration:underline">arfer's</span> approach is interresting, yet may cause the script to stop responding should any I/O-errors occur during the reading. Would probably be a good idea to move the utimer to the top of the proc.<br>Also worth mentioning, is that this will keep resetting the bind-counter every time it triggers.<br><br>A third option would be to simply use timestamps, removing the need for any timers or cleanup. Example posted below:<br><div class="codebox"><p>Code: </p><pre><code>proc throttle {id time} { if {[info exists ::throttle($id)] &amp;&amp; $::throttle($id) &gt; [clock seconds]} {  return 0 } set ::throttle($id) [expr [clock seconds] + $time] return 1}proc myproc {} { if {[throttle "theid" 60]} {  #we're ok, do the good stuff here } {  #still throttle'd, do nothing  return 0 }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Feb 03, 2009 12:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[TCL_no_TK]]></name></author>
		<updated>2009-02-03T08:58:41-04:00</updated>

		<published>2009-02-03T08:58:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87219#p87219</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87219#p87219"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87219#p87219"><![CDATA[
Performance <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_exclaim.gif" width="15" height="15" alt=":!:" title="Exclamation"> <br> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_arrow.gif" width="15" height="15" alt=":arrow:" title="Arrow"> <blockquote class="uncited"><div>... there is one trick that might be necessary. Determine the size of the file first, then 'read' that many bytes. This allows the channel code to optimize buffer handling (preallocation in the correct size). I don't know anymore who posted this first. But you only need this for Tcl 8.0. This is something for the Tcl Performance page as well.</div></blockquote> from <a href="http://wiki.tcl.tk/367" class="postlink">How do I read and write files in Tcl</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8130">TCL_no_TK</a> — Tue Feb 03, 2009 8:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-02-02T12:14:32-04:00</updated>

		<published>2009-02-02T12:14:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87209#p87209</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87209#p87209"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87209#p87209"><![CDATA[
TCL_no_TK:<br>What would the purpose of such a modification be?<br><br>Also, the extended syntax of <strong class="text-strong">read</strong> specifies the number of characters to read, while <strong class="text-strong">file size</strong> returns the number of bytes. Which certain charsets, such as UTF-8, one character may consist of several bytes. You will get away with this, as <strong class="text-strong">read</strong>, for normal files, reads as much as "<em class="text-italics">numChars</em>" charaters, or up until EOF, which ever comes first. Should the <em class="text-italics">channelId</em> however have been a serial port, the read command would block until the specific amount of characters have been recieved (of course, <strong class="text-strong">file siz</strong>e would not be useful on a serial port in the first place).<br><br>The point being, there is no good reason for specifying the number of characters to read, should you desire to read the whole file.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Feb 02, 2009 12:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[TCL_no_TK]]></name></author>
		<updated>2009-02-02T07:25:32-04:00</updated>

		<published>2009-02-02T07:25:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87205#p87205</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87205#p87205"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87205#p87205"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>  set fl [open fact.txt]   set data [read $fl]</code></pre></div>Replace with<div class="codebox"><p>Code: </p><pre><code>  set fs [file size "fact.txt"]  set fl [open fact.txt]   set data [read $fl $fs]</code></pre></div>  <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=8130">TCL_no_TK</a> — Mon Feb 02, 2009 7:25 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-01-30T21:23:09-04:00</updated>

		<published>2009-01-30T21:23:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87168#p87168</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87168#p87168"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87168#p87168"><![CDATA[
I know you said the above worked but recent coding I have done on something unrelated has caused me to rethink the solution I provided, as a generic means of preventing flood. I found the solution below to be more reliable.<br><div class="codebox"><p>Code: </p><pre><code>bind pub - !fact pub_fact proc pub_fact {n u h c t} {   unbind pub - !fact pub_fact  set fl [open fact.txt]   set data [read $fl]   close $fl   set lines [split $data \n]   set randline [lindex $lines [rand [llength $lines]]]   putserv "privmsg $c :$randline"   utimer 60 [list bind pub - !fact pub_fact]  return 0 }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Fri Jan 30, 2009 9:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tmyoungjr]]></name></author>
		<updated>2009-01-28T17:28:08-04:00</updated>

		<published>2009-01-28T17:28:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87137#p87137</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87137#p87137"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87137#p87137"><![CDATA[
thank you - this works wonderfully<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9254">tmyoungjr</a> — Wed Jan 28, 2009 5:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-01-07T14:53:15-04:00</updated>

		<published>2009-01-07T14:53:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86776#p86776</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86776#p86776"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86776#p86776"><![CDATA[
bind pub - !fact pub_fact <br><br>proc pub_fact {n u h c t} { <br>  global varTimer<br>  if {![info exists varTimer]} {<br>    set varTimer 1<br>    utimer 60 [unset varTimer]<br>    set fl [open fact.txt] <br>    set data [read $fl] <br>    close $fl <br>    set lines [split $data \n] <br>    set randline [lindex $lines [rand [llength $lines]]] <br>    putserv "privmsg $c :$randline"<br>  }<br>  return 0<br>}<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Wed Jan 07, 2009 2:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tmyoungjr]]></name></author>
		<updated>2009-01-07T11:22:02-04:00</updated>

		<published>2009-01-07T11:22:02-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86774#p86774</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86774#p86774"/>
		<title type="html"><![CDATA[flood check]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86774#p86774"><![CDATA[
I have a real simple script that i found here in the forums :<br><div class="codebox"><p>Code: </p><pre><code>bind pub - !fact pub_factproc pub_fact {n u h c t} {  set fl [open fact.txt]   set data [read $fl]  close $fl  set lines [split $data \n]  set randline [lindex $lines [rand [llength $lines]]]  putserv "privmsg $c $randline"}</code></pre></div>i'll modify it a bit for my needs.  what i'm looking for tho is flood control.  i want to limit the # of times this script will return anything (something like say 1 request every minute or some such).  i've found many scripts with flood control built in, but they all seem excessively complicated for my needs.  any assistance would be great.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9254">tmyoungjr</a> — Wed Jan 07, 2009 11:22 am</p><hr />
]]></content>
	</entry>
	</feed>
