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

	<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-02-17T15:26:13-04:00</updated>

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

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-17T15:26:13-04:00</updated>

		<published>2003-02-17T15:26:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16719#p16719</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16719#p16719"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16719#p16719"><![CDATA[
Problem fixed:<br><div class="codebox"><p>Code: </p><pre><code>set badfile "badword.txt" bind pubm - * pubm:badword proc pubm:badword {nick uhost hand channel args } {global badfile if {![file exists $badfile]} {   putlog "Error: Le $badfile de dossier n'existent pas."   return } set file [open "$badfile" r] while {![eof $file]} {   set line [gets $file]   foreach word [split $args] {     if {![string equal "$word" $line]} { continue }     set found 1     break   } } catch {close $file} if {![info exists found]} { return 0 } putserv "PRIVMSG $channel :yes" }</code></pre></div>Thank you. Now is working, a bit slow but is working.. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 17, 2003 3:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-17T15:12:12-04:00</updated>

		<published>2003-02-17T15:12:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16714#p16714</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16714#p16714"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16714#p16714"><![CDATA[
Listen, I tried, but I don't seem to get anywhere.<br><br>There was no need to move the "foreach" out of the while loop. It is slower when outside the while loop, as it has to open, close, open, close, open, close (one open and close per word in IRC), rather the open and close once.<br><br>Second, I noticed that you are not even closing the file. SO for each word, you open a file, but don't close it (only when the word matches).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Feb 17, 2003 3:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-17T15:06:51-04:00</updated>

		<published>2003-02-17T15:06:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16710#p16710</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16710#p16710"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16710#p16710"><![CDATA[
Oh. Here is the code that seems to be working fine (no more freeze):<br><div class="codebox"><p>Code: </p><pre><code>set badfile "badword.txt" bind pubm - * pubm:badword proc pubm:badword {nick uhost hand channel text} {   global badfile   if {![file exists $badfile]} {     putlog "Error: Le $badfile de dossier n'existent pas."   return }   foreach word $text {     set file [open "$badfile" r]     while {![eof $file]} {       set line [gets $file]       if {![string equal "$word" $line]} { continue }       putserv "PRIVMSG $channel :yes"       catch {close $fid}     return }   break }   putserv "PRIVMSG $channel :nope" }</code></pre></div>But now the problems is that he dosen't try to match all words typed in channel. The 'badword.txt' has in it 'foo' and when I type 'foo' I get an yes (as it's working), but when I try a something foo is not working, I get an nope. Also I've tryed with the string match and again same result: nope.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 17, 2003 3:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-17T14:02:27-04:00</updated>

		<published>2003-02-17T14:02:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16704#p16704</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16704#p16704"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16704#p16704"><![CDATA[
Then you still havn't moved the "gets" command to the correct place.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Feb 17, 2003 2:02 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-17T13:30:14-04:00</updated>

		<published>2003-02-17T13:30:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16702#p16702</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16702#p16702"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16702#p16702"><![CDATA[
I was looking for a direct match. I've removed all '[split]' and changed that line with 'if {![string equal "$word" $line]} { continue } ' and I still get the same result. It eats about 98% CPU and mem.. and freezes.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 17, 2003 1:30 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-17T10:57:17-04:00</updated>

		<published>2003-02-17T10:57:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16699#p16699</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16699#p16699"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16699#p16699"><![CDATA[
I have gone over and over the code, and it hit me on the, 1000 ish attempt.<br><div class="codebox"><p>Code: </p><pre><code>{![string match "$word" [split $line]]} </code></pre></div>Are you trying to do a direct match, or using wildcards?<br><br>If wildcards, this this is the right way to do it, however, you will need to remove the "split" command, and possibly use the -nocase option (otherwise the match can be missed with mixed case)<br><br>If a direct match, you may want to use the "string equal" command. Again, you will need to remove the "split" command, and possible use the -nocase option.,<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Feb 17, 2003 10:57 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2003-02-17T10:33:44-04:00</updated>

		<published>2003-02-17T10:33:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16698#p16698</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16698#p16698"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16698#p16698"><![CDATA[
nvm.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Mon Feb 17, 2003 10:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-17T08:32:42-04:00</updated>

		<published>2003-02-17T08:32:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16697#p16697</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16697#p16697"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16697#p16697"><![CDATA[
I've replaced 'args' with 'text' and same thing, no difference at all.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 17, 2003 8:32 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-17T08:28:49-04:00</updated>

		<published>2003-02-17T08:28:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16696#p16696</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16696#p16696"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16696#p16696"><![CDATA[
then do not use $args.<br><br>The foreach loop should be a matter of changing the variable name.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Feb 17, 2003 8:28 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-17T08:24:23-04:00</updated>

		<published>2003-02-17T08:24:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16695#p16695</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16695#p16695"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16695#p16695"><![CDATA[
In 'badword.txt' are some words placed like this:<br><div class="codebox"><p>Code: </p><pre><code>first_wordsecond_word.. etc.</code></pre></div>and I've wanted it to do the foreach and compare all the words from the line said in channel with all the words in the file.<br><br>Oh, and also, tryed the code you have previously posted and same problem as my first code: freeze..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 17, 2003 8:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-17T07:54:37-04:00</updated>

		<published>2003-02-17T07:54:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16694#p16694</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16694#p16694"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16694#p16694"><![CDATA[
1: You code is very bunched up.<br><br>You do an IF, open a brace and then goto a new line. However, when you close the brace, you place it at the end of a line, rathet than a on a new one.<br><br>While this isn't wrong, and is perfectly valid, it makes for hard to read code.<br><br>2: Indenting.<br><br>Along with doing braces, you should indent your code. It makes for far simpler reading again. You can tell what code, bellongs in which brace.<br><br>If you start doing a mass of if, while, foreach and for loops, you can find you get lost on howmany braces you have open. Indenting from the off, will allow you too know how many braces need closing, and making for simple backtracking.<br><br>Your code (first post) can be represented as follows.<div class="codebox"><p>Code: </p><pre><code>set badfile "badword.txt" bind pubm - * pubm:badword proc pubm:badword {nick uhost hand channel args } {   global badfile   if {![file exists $badfile]} {     putlog "Error: Le $badfile de dossier n'existent pas."     return  }   set file [open "$badfile" r]   set line [gets $file]   while {![eof $file]} {     foreach word [split $args] {       if {![string match "$word" [split $line]]} { continue }       set found 1       break    }   }   catch {close $file}   if {![info exists found]} { return 0 }   putlog "found" }</code></pre></div>See how you can tell where in the code you are. I do not state you have to take this approach, but it's far simpler to read.<br><br>Now back to the issues.<br><br>Scrap the code from the second post, it's more flawed than the first.<br><br>In the code above (in this post), you need to move the "gets" command. Unless it's in the loop, EOF will never be called.<br><br>What exactly are you trying to match in the foreach loop:<br>The whole line of IRC input?<br>Each word of IRC input?<br><br>If it's the whole line, then you don't even need the foreach loop, or $args.<br><br>It's it's each word, then you shouldn't be using $args (it is currently causing you to match against the whole line).<br><br>Otherwise, there isn't enything else wrong.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Feb 17, 2003 7:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-17T07:31:05-04:00</updated>

		<published>2003-02-17T07:31:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16693#p16693</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16693#p16693"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16693#p16693"><![CDATA[
First, I haven't understood what you ment to say.. second, I have fixed it a bit and looks like this:<br><div class="codebox"><p>Code: </p><pre><code>set badfile "badword.txt"bind pubm - * pubm:badwordproc pubm:badword {nick uhost hand channel text} {global badfileif {![file exists $badfile]} {putlog "Error: Le $badfile de dossier n'existent pas."return }foreach word [split $text] {set file [open "$badfile" r]while {![eof $file]} {set line [gets $file]if {![string match "$word" $line]} { continue }putserv "PRIVMSG $channel :yes"catch {close $fid}return }break }putserv "PRIVMSG $channel :nope"}</code></pre></div>And what you wanted to tell me about the $args? But, now the problem is that he dosen't do the foreach thing corectly..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 17, 2003 7:31 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-02-17T06:11:24-04:00</updated>

		<published>2003-02-17T06:11:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16692#p16692</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16692#p16692"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16692#p16692"><![CDATA[
First off, I sugesta programmers file editor is used. Your code allways seems so hard to read, with close braces placed pretty much where you want.<br><br>Second, you may find it handy to post the error message. This usualy tells you the error without too muhc issue.<br><br>Third, your use of $args.<br><br>Forth, you only ever call the "gets" command once. This is causing it to loop forever, as it checks the one line over and over, never reaching EOF.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Feb 17, 2003 6:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2003-02-17T05:31:56-04:00</updated>

		<published>2003-02-17T05:31:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=16691#p16691</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=16691#p16691"/>
		<title type="html"><![CDATA[problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=16691#p16691"><![CDATA[
Using this code:<br><div class="codebox"><p>Code: </p><pre><code>set badfile "badword.txt"bind pubm - * pubm:badwordproc pubm:badword {nick uhost hand channel args } {global badfileif {![file exists $badfile]} {putlog "Error: Le $badfile de dossier n'existent pas."return }set file [open "$badfile" r]set line [gets $file]while {![eof $file]} {foreach word [split $args] { if {![string match "$word" [split $line]]} { continue } set found 1break }}catch {close $file}if {![info exists found]} { return 0 }putlog "found"}</code></pre></div>my eggdrop dies. Where have I made a mistake? I know I've made one but I can find it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Mon Feb 17, 2003 5:31 am</p><hr />
]]></content>
	</entry>
	</feed>
