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

	<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>2003-06-11T10:45:28-04:00</updated>

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

		<entry>
		<author><name><![CDATA[eiSi]]></name></author>
		<updated>2003-06-11T10:45:28-04:00</updated>

		<published>2003-06-11T10:45:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21669#p21669</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21669#p21669"/>
		<title type="html"><![CDATA[how to optimize that proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21669#p21669"><![CDATA[
wow!<br><br>that's really great <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>I'll try it later on, but I think it's exactly what I meant! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Thanks again!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=939">eiSi</a> — Wed Jun 11, 2003 10:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-06-11T09:55:37-04:00</updated>

		<published>2003-06-11T09:55:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21664#p21664</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21664#p21664"/>
		<title type="html"><![CDATA[how to optimize that proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21664#p21664"><![CDATA[
Here's another idea that might speed things up further when you have alot of answers:<div class="codebox"><p>Code: </p><pre><code># outside the proc:# array of masks/answersarray set fishA {  "question" "answer"   "blah*" "$nick is verbose!"   "* bleh *" "no."   "bluh" "i hate $chan" }# array containing lists of masks starting with a certain chararray unset fishMforeach e [array names fishA] {  lappend fishM([string index $e 0]) $e}# and a sorted list of the charsset fishC [lsort -dict [array names fishM]]proc fishbot {nick uhost handle chan text} {  # converting $text to lowercase and making sure all your masks also are   # in lowercase might be a good idea to avoid multiple case conversions  global fishA fishM fishC  # first we make a list of masks that might match $text  # (based on the first char)  set masks {}  foreach e $fishC {    if {[string match $e* $text]} {      set masks [concat $masks $fishM($e)]    }  }  # then we do the actual matching  foreach m $masks {    if {[string match $m $text]} {      putserv "PRIVMSG $chan :[subst $fishA($m)]"      break    }  }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Wed Jun 11, 2003 9:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[eiSi]]></name></author>
		<updated>2003-06-11T08:52:51-04:00</updated>

		<published>2003-06-11T08:52:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21660#p21660</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21660#p21660"/>
		<title type="html"><![CDATA[how to optimize that proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21660#p21660"><![CDATA[
all right!<br><br>thanks for your help!<br><br>I'll try it!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=939">eiSi</a> — Wed Jun 11, 2003 8:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2003-06-11T08:59:58-04:00</updated>

		<published>2003-06-10T17:33:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21613#p21613</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21613#p21613"/>
		<title type="html"><![CDATA[how to optimize that proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21613#p21613"><![CDATA[
A list and a foreach loop would speed it up some i recon...<div class="codebox"><p>Code: </p><pre><code>set crap {"question" "answer""blah*" "$nick is verbose!""* bleh *" "no.""bluh" "i hate $chan"}foreach {m a} $crap {  if {[string match $m $text]} {    # the 'subst' takes care of variable/command/backslash substitution    # in the string contained in 'a'.    putserv "PRIVMSG $chan :[subst $a]"    # then we 'break' to avoid answering more than once to each line    # of text and also cut down on the cpu usage    break  }}</code></pre></div>You could of course store the mask/reply pairs in an array and loop through 'array names' or 'array get' instead.<br><br>Also make sure you put the most commonly matched masks first.<br><br>If you plan to have thousands of elements the best thing would probably be to sort them some way and use a binary search approach to decrease the number of mask having to be matched.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Tue Jun 10, 2003 5:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[eiSi]]></name></author>
		<updated>2003-06-10T06:50:39-04:00</updated>

		<published>2003-06-10T06:50:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21558#p21558</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21558#p21558"/>
		<title type="html"><![CDATA[how to optimize that proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21558#p21558"><![CDATA[
hi there!<br><br>some of you know the fishbot on quakenet.. he just gives silly answers to people saying a certain sentence.<br><br>I coded that in tcl, but how to optimize:<br><br>setudef flag fish<br>bind pubm -|- * fishbot<br><div class="codebox"><p>Code: </p><pre><code>proc fishbot {nick uhost handle chan text} {  if {![string match "*+fish*" [channel info $chan]]} { return 0 }    set fish1 "you can't just pick people at random!"    set fish2 "wertle"    if {[string match "$fish1" $text]} { putserv "PRIVMSG $chan : I can do anything I like, $nick, I'm eccentric! Rrarrrrrgh! Go!" }  if {[string match "$fish2" $text]} { putserv "PRIVMSG $chan : moo" }}</code></pre></div>the list goes on that way.. fish3, fish4... and the responses do aswell.<br><br>what's the best way to solve this? with 2 arrays? (questions &lt;--&gt; answers)<br><br>thanks for any suggestions!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=939">eiSi</a> — Tue Jun 10, 2003 6:50 am</p><hr />
]]></content>
	</entry>
	</feed>
