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

	<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>2001-10-18T09:41:00-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-18T09:41:00-04:00</updated>

		<published>2001-10-18T09:41:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=799#p799</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=799#p799"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=799#p799"><![CDATA[
yay, i finally got it working <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":smile:" title="Smile"><br><br>when adding the nick/uhost like this:<br><div class="codebox"><p>Code: </p><pre><code>puts $fp "$nick *[string trimleft [maskhost $uh] "*!"]"</code></pre></div> <br><br>it works beautifully <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":smile:" title="Smile">  thanks to all who helped me with this.<p>Statistics: Posted by Guest — Thu Oct 18, 2001 9:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-18T05:16:00-04:00</updated>

		<published>2001-10-18T05:16:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=797#p797</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=797#p797"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=797#p797"><![CDATA[
That didn't work (surprise). I added the putlog line. Output is now:<br><br>[09:22] testing line *!drow@*.upc-a.chello.nl against Errtu|TCL!~<a href="mailto:drow@b255089.upc-a.chello.nl">drow@b255089.upc-a.chello.nl</a><br><br>/me is getting frustrated.  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":sad:" title="Sad"><br><br>[edit] i added a few bogus nicks/uhosts and every time each line in the textfile is compared against  Errtu|TCL!~<a href="mailto:drow@b255089.upc-a.chello.nl">drow@b255089.upc-a.chello.nl</a><br><br>[edit2] just messing around with the register.txt file.  Normally it adds nick/uhost like this:<br><br>Errtu|TCL *!drow@*.upc-a.chello.nl<br><br>but when i manually edit the file and add this line:<br><br>Errtu|TCL *drow@*.upc-a.chello.nl  it suddenly works!! (rejoice!). Now, how can i let the script add the mask in that format?<br><br><br>&lt;font size=-1&gt;[ This Message was edited by: Errtu on 2001-10-18 03:27 ]&lt;/font&gt;<p>Statistics: Posted by Guest — Thu Oct 18, 2001 5:16 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2001-10-17T21:40:00-04:00</updated>

		<published>2001-10-17T21:40:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=780#p780</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=780#p780"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=780#p780"><![CDATA[
reverse the args to the string match function<br><br>_T is the maskhost you read in, so that should be the first arg to string match<br><br>if that doesn't work, then add some debugging statements (putlog) to see what is going wrong<br><br>i.e. where you set found add, putlog "setting found to 1"<br><br>right after you read the line, add, putlog "testing line $_T against $nick!$uhost"<br><br>etc<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Wed Oct 17, 2001 9:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-17T19:34:00-04:00</updated>

		<published>2001-10-17T19:34:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=776#p776</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=776#p776"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=776#p776"><![CDATA[
no go <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":sad:" title="Sad">   It seems like it still doesn't check if the $nick/$uhost is in the file because it simply appends ..<p>Statistics: Posted by Guest — Wed Oct 17, 2001 7:34 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2001-10-17T11:28:00-04:00</updated>

		<published>2001-10-17T11:28:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=763#p763</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=763#p763"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=763#p763"><![CDATA[
OOPS<br><br>change the line<br>seek $fp end<br><br>too<br>seek $fp 0 end<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Wed Oct 17, 2001 11:28 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-17T11:26:00-04:00</updated>

		<published>2001-10-17T11:26:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=762#p762</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=762#p762"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=762#p762"><![CDATA[
i got this error in console:<br><br>TCL Error [msg_regchat]: expected integer but got "end"<p>Statistics: Posted by Guest — Wed Oct 17, 2001 11:26 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2001-10-17T10:52:00-04:00</updated>

		<published>2001-10-17T10:52:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=754#p754</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=754#p754"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=754#p754"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>set regfile "register.txt"bind msg - chat-register msg_regchatproc msg_regchat {nick uh hand arg} {  global regfile  set fp [open $regfile r+]  set found 0  while {![eof $fp]} {    set _T [lindex [split [gets $fp]] 1]    if {[string match "${nick}!${uh}" $_T]} {      set found 1    }  }  if {$found} {    puthelp "NOTICE $nick :allready registered"  } else {    seek $fp end    puts $fp "$nick [maskhost "${nick}!${uh}"]"  }  close $fp}</code></pre></div>Try this.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Wed Oct 17, 2001 10:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-17T09:56:00-04:00</updated>

		<published>2001-10-17T09:56:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=751#p751</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=751#p751"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=751#p751"><![CDATA[
<blockquote class="uncited"><div>On 2001-10-17 07:06, stdragon wrote:<br>The 'found' variable should be initialized within your procedure, and should not be a global variable.</div></blockquote>ok moved the set found to be within the proc<br><blockquote class="uncited"><div>Look at your string match command.. you're comparing to the filename, not the line.</div></blockquote>this was all the info i could get about string match. How can i compare the string to all the lines within the filename?<br><blockquote class="uncited"><div>You shouldn't set found = 0 inside the loop.</div></blockquote>removed<br><blockquote class="uncited"><div>You should break after you set found = 1 (look at the help page for 'break' to see what it does).</div></blockquote>ok<br><blockquote class="uncited"><div>You should not close the file within the loop! hehe (you will only read the first line)</div></blockquote>argh yes..  moved the close $fs one line down so it's after the loop<br><blockquote class="uncited"><div>If you are getting *no reply* at all, that means the procedure either has an error (look on the dcc console and watch for an error) or it's not being called (do you have the 'bind' command?)</div></blockquote>no errors on the console, i have the bind command and it's working.<br><br>Thanks btw for the help so far, i really appreciate it.<br><p>Statistics: Posted by Guest — Wed Oct 17, 2001 9:56 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2001-10-17T09:06:00-04:00</updated>

		<published>2001-10-17T09:06:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=748#p748</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=748#p748"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=748#p748"><![CDATA[
The 'found' variable should be initialized within your procedure, and should not be a global variable.<br><br>Look at your string match command.. you're comparing to the filename, not the line.<br><br>You shouldn't set found = 0 inside the loop.<br><br>You should break after you set found = 1 (look at the help page for 'break' to see what it does).<br><br>You should not close the file within the loop! hehe (you will only read the first line)<br><br>If you are getting *no reply* at all, that means the procedure either has an error (look on the dcc console and watch for an error) or it's not being called (do you have the 'bind' command?)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Wed Oct 17, 2001 9:06 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-17T08:35:00-04:00</updated>

		<published>2001-10-17T08:35:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=743#p743</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=743#p743"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=743#p743"><![CDATA[
Okay, i've tried to do so .. but (obviously) i still make a mistake somewhere because now i get no reply back at all..<br><br>this is the modified part:<br><div class="codebox"><p>Code: </p><pre><code>set found 0proc msg_regchat {nick uhost hand args} {   global regfile found  set fs [open $regfile r]  while {![eof $fs]} {   set read [gets $fs]  if {[string match $nick $regfile]} {   set found 1  } else {  set found 0  }  close $fs  }  if {$found == "1"} {    putserv "NOTICE $nick :You have already registered."    } else {    putserv "NOTICE $nick :You have now registered."    set fs [open $regfile a+]    puts $fs "$nick"    close $fs      }}</code></pre></div><p>Statistics: Posted by Guest — Wed Oct 17, 2001 8:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2001-10-17T07:29:00-04:00</updated>

		<published>2001-10-17T07:29:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=735#p735</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=735#p735"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=735#p735"><![CDATA[
imagine you have a variable called "found"<br><br>you start off with found = 0, because it's not found<br><br>then you go through the file one line at a time<br><br>if the line matches the uhost, you set found to 1, and break from the loop<br><br>after the loop, you test the value of found<br><br>if it's 1, you send your error message, because they are already registered<br><br>if it's still 0, that means it wasn't found, and you reopen the file in 'a' mode and add the new entry<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Wed Oct 17, 2001 7:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-17T07:19:00-04:00</updated>

		<published>2001-10-17T07:19:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=733#p733</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=733#p733"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=733#p733"><![CDATA[
so how do i change it?  i can let it open in 'r' so it will read the entire file and should see the match then, but .. output outside the loop.. how do i do that?<p>Statistics: Posted by Guest — Wed Oct 17, 2001 7:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2001-10-17T07:12:00-04:00</updated>

		<published>2001-10-17T07:12:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=731#p731</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=731#p731"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=731#p731"><![CDATA[
First problem is you are opening the file in "a+" mode, which means "append plus read". Opening in append mode means you start at the end of the file. So that's why it's not finding the right entries.<br><br>The second problem is that you're doing your output within the loop. That means it's gonna do it for each line in the file, not just once over all.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Wed Oct 17, 2001 7:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2001-10-17T06:43:00-04:00</updated>

		<published>2001-10-17T06:43:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=730#p730</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=730#p730"/>
		<title type="html"><![CDATA[string lookup in file fails]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=730#p730"><![CDATA[
I'm really new to tcl, and i try to do something more than basic. What this script is suppose to do, is when somebody does /msg bot chat-register, the script should look inside a textfile if their hostname is there. If it is, you'll get a msg "already registered". If it isn't the $nick and $uhost should be written. Even after a very friendly guy in #eggdrop@Undernet helped me with a few basic things, i still can't get it to work. The bot doesn't seem to look in the file and just adds the $nick $uhost to the file. Can someone tell me what i've done wrong here?<br><div class="codebox"><p>Code: </p><pre><code>set regfile "registered.txt"bind msg - chat-register msg_regchatproc msg_regchat {nick uhost hand args} {   global regfile  set fs [open $regfile a+]  while {![eof $fs]} {   set read [gets $fs]  if {[string match $uhost $regfile]} {     putserv "NOTICE $nick :You have already registered."  } else {    putserv "NOTICE $nick :You have now registered for the chat."    puts $fs "$nick $uhost"  } } close $fs}</code></pre></div><p>Statistics: Posted by Guest — Wed Oct 17, 2001 6:43 am</p><hr />
]]></content>
	</entry>
	</feed>
