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

	<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>2006-10-13T06:29:41-04:00</updated>

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

		<entry>
		<author><name><![CDATA[monie089]]></name></author>
		<updated>2006-10-13T06:29:41-04:00</updated>

		<published>2006-10-13T06:29:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67111#p67111</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67111#p67111"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67111#p67111"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>set nxg(char) @set nxg(gamefile) "nxg/game.txt"proc NintendoXG:find {nick uhost hand chan arg} {global nxg   set name [lindex [split $arg] 0]   set game [lindex [split $arg] 1]   if {![string length $name] || ![string length $game]} {      putserv "PRIVMSG $nick :\002SYNTAX:\002 $::lastbind &lt;nick&gt; &lt;game&gt;"; return   }   set list [split [read [set fd [open $::nxg(gamefile) r]]] \n]; close $fd  if {![llength [set matches [lsearch -all -inline -glob $list [md5 [string tolower $name]]*]]]} {      putserv "PRIVMSG $nick :The user: $name couldn't be found in the NintendoXG Database."; return   }  foreach match $matches {     foreach {x gm code} $match {         if {[string equal -nocase $gm $game]} {             putserv "PRIVMSG $nick :--- $name's Friendcodes ---"             putserv "PRIVMSG $nick :Game: $gm -- Code: $code"         }     }  }  }proc NintendoXG:code {nick uhost hand chan arg} {global nxg   foreach {game code} [split $arg] {break}  if {![string length $game] || ![string length $code]} {      putserv "PRIVMSG $nick :\002SYNTAX:\002 [string trim $nxg(char)]Code &lt;game&gt; &lt;code&gt;"; return   } set list [split [read [set fd [open $::nxg(gamefile) r]]] \n]; close $fd  if {![llength [lindex $list end]]} {      set list [lreplace $list end end]   }   lappend list [list [md5 [string tolower $nick]] $game $code]   puts -nonewline [set fd [open $::nxg(gamefile) w]] [join $list \n]; close $fd   putserv "PRIVMSG $nick :Your code has been added to the NintendoXG Database."}bind pub - [string trim $nxg(char)]Find NintendoXG:findbind pub - [string trim $nxg(char)]Code NintendoXG:code</code></pre></div>Updated the friendcodes script so now you can do<br>@Find &lt;nick&gt; &lt;game&gt;<br>and to add your codes<br>use @Code &lt;game&gt; &lt;code&gt;<br><br>Just set the file location and rehash your bot and your done<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8036">monie089</a> — Fri Oct 13, 2006 6:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-10-11T17:09:25-04:00</updated>

		<published>2006-10-11T17:09:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67083#p67083</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67083#p67083"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67083#p67083"><![CDATA[
The loop problem is indeed fixed in this new version.<br><br>I have some suggestions for you, to reduce the number of duplicate functions.<br><br>Instead of this for each filename:<div class="codebox"><p>Code: </p><pre><code>set mphtfile "/tmp/mphtcodes.txt" if {![file exists $mphtfile]} {   catch {close [open $mphtfile w]} } </code></pre></div>Try something like:<div class="codebox"><p>Code: </p><pre><code>set filepath "/home/mybot/datafiles/"set codefiles [list mpht mkds lsmg stfx]foreach name $codefiles {     if {![file exists $filepath$name]} {           catch {close [open $filepath$name\codes.txt w]}      }}</code></pre></div>If you made $filepath a global variable, then people can change that one line and set the path to whatever they want more simply.<br><br>Actually, it's probably not even necessary to initialize the files in such a way, you can create them when needed in the procs that go to write them. But anyway..<br><br>You could also use lsearch to reduce the redundant sections in other proc's, for example:<div class="codebox"><p>Code: </p><pre><code>set command [lindex [split $arg] 0] global filepath codefiles# This assumes that $command is the same as the name of the codefile# so, if you had a command called !add mpht, it'll match the filenamesif {[set myarg [lsearch $codefiles $command]] != -1} {     set gamer [string tolower $nick]     set code [lindex [split $arg] 1]     # $nick would never be "" if this is run from a public command    if {$code != ""} {            set fd [open $path$myarg\codes.txt r]            set list [split [read $fd] \n]           catch {close $fd}           # you should do an lsearch here for the nick, to prevent duplicates            set linecount -1            foreach line $list {                 incr linecount                 set nickf [lindex [split $line :] 0]                 set codef [lindex [split $line :] 1]                 if {$nickf == $gamer} {                      # this is a matching line.. lreplace the data                       set list [lreplace $list $linecount $linecount "$gamer:$code"]                 } else {                       set list [linsert $list end "$gamer:code"]                 }            }            set fd [open $path$myarg\codes.txt w]            foreach line $list {                 if {$line != ""}                      puts $fd $line                  }            }            catch {close $fd}            putquick "NOTICE $nick :^C$noticecolor Your code for ^B$acwwini^B has been added."    } else {           putquick "NOTICE $nick :^C$noticecolor Type '^B!add $acwwini &lt;code&gt;^B'"     } } </code></pre></div>That will also format your lines in such a way as to make it easier to parse them in other procs. The find:code proc would be very similar to the above, except it's only reading and comparing the lines, not writing to the file.<br><br>As far as the info: proc's, they could all be combined into 1 generic help proc, then just parse the arg for the option:<div class="codebox"><p>Code: </p><pre><code>bind pub - !gamehelp gamehelpproc gamehelp {$nick uhost hand chan text} {        if {$text == "about"} {              puthelp "PRIVMSG $nick :About the script.."         } elseif {$text == "fcmenu"} {              puthelp "PRIVMSG $nick :so forth and so on"         } else {               puthelp "PRIVMSG $nick :I didn't understand that command, here's a summary of options:"               puthelp "PRIVMSG $nick :so forth and so on..."         }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Wed Oct 11, 2006 5:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Justdabomb2]]></name></author>
		<updated>2006-10-10T21:57:48-04:00</updated>

		<published>2006-10-10T21:57:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67078#p67078</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67078#p67078"/>
		<title type="html"><![CDATA[It's on]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67078#p67078"><![CDATA[
Hey, the new script is on the archive now, tell me what you think of this one okay. Thanks! <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=8244">Justdabomb2</a> — Tue Oct 10, 2006 9:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Justdabomb2]]></name></author>
		<updated>2006-10-08T19:14:59-04:00</updated>

		<published>2006-10-08T19:14:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67021#p67021</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67021#p67021"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67021#p67021"><![CDATA[
remember my thread about trying to make a proc to delete a line with the specified nick from the file?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8244">Justdabomb2</a> — Sun Oct 08, 2006 7:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-10-08T19:10:49-04:00</updated>

		<published>2006-10-08T19:10:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67019#p67019</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67019#p67019"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67019#p67019"><![CDATA[
What delete thing?  Show us what you mean and your code.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Sun Oct 08, 2006 7:10 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Justdabomb2]]></name></author>
		<updated>2006-10-08T18:28:03-04:00</updated>

		<published>2006-10-08T18:28:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67016#p67016</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67016#p67016"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67016#p67016"><![CDATA[
It should be on soon, and I made it so that the script user can easily change the name/initials for the games too if the script users don't like the ones I use. and it is not case sensitive at all now. I wish I could just figure out the stupiod delete thing though. I am still wokring on it. Sorry about putting a very poorly written script in the archive, my newer one should look much more neat.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8244">Justdabomb2</a> — Sun Oct 08, 2006 6:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-10-08T18:23:29-04:00</updated>

		<published>2006-10-08T18:23:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67015#p67015</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67015#p67015"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67015#p67015"><![CDATA[
Basically when I put the script into the bot, and did a rehash or a restart, the result showing on the console was every command repeated 3x. I'll test the new version when it's up on the tcl archive and let you know if the problem is still present. I did not debug and test the script beyond loading it, and running the commands. <br><br>I'm running on a linux platform, dunno if that makes a diff.<br><br>And I apologize for being mean.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Sun Oct 08, 2006 6:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Justdabomb2]]></name></author>
		<updated>2006-10-08T03:30:54-04:00</updated>

		<published>2006-10-08T03:30:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=67011#p67011</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=67011#p67011"/>
		<title type="html"><![CDATA[...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=67011#p67011"><![CDATA[
Do you have proof it looped, my friend tested this script and it worked fine for him after he deleted the "codes/". Also I submitted an updated script, with one proc for adding and one for finding... Also it isn't case sensitive anymore. And no, I didn't have someone else write/help me with that. You don't need to be so mean, it was my frist script okay.. I do agree that I should have looked over my script more before submitting it to the archive. Sorry.  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8244">Justdabomb2</a> — Sun Oct 08, 2006 3:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-10-06T23:08:56-04:00</updated>

		<published>2006-10-06T23:08:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=66994#p66994</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=66994#p66994"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=66994#p66994"><![CDATA[
That was *not* the problem I posted about, the problem is this script making the bot LOOP and rehash three times when I issue ONE .rehash command, or restart, etc.<br><br>As far as the pathnames, why not just use a variable like <br>set filepath "/home/whatever/path/"   and use that as a global var throughought the proc's<br><br>Actually, ALL of the redundant code and procs could be consolidated and use just ONE proc with variables to cover each game name.. etc.<br><br>I suggest before submitting another poorly written script to the tcl archive, you post it here and ask for testers and peer review.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Fri Oct 06, 2006 11:08 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Justdabomb2]]></name></author>
		<updated>2006-10-06T17:59:20-04:00</updated>

		<published>2006-10-06T17:59:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=66991#p66991</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=66991#p66991"/>
		<title type="html"><![CDATA[/codes/]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=66991#p66991"><![CDATA[
Yeah, for the mpht file, I forgot to change it from looking in the code folder. Becuase that is what I use no my computer. I store the codes in "scripts/code/filename.txt". Just take out codes/ and it will work just fine. very sorry. I shouldn't have overlooked it <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8244">Justdabomb2</a> — Fri Oct 06, 2006 5:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Alchera]]></name></author>
		<updated>2006-10-05T20:14:37-04:00</updated>

		<published>2006-10-05T20:14:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=66954#p66954</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=66954#p66954"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=66954#p66954"><![CDATA[
The top piece is certainly <em class="text-italics">different</em> but the procedure name is unique i.e. info:find (regarded by eggdrop as one word) and should (<em class="text-italics">in theory</em>) not be a problem.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3646">Alchera</a> — Thu Oct 05, 2006 8:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[rosc2112]]></name></author>
		<updated>2006-10-05T19:07:46-04:00</updated>

		<published>2006-10-05T19:07:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=66953#p66953</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=66953#p66953"/>
		<title type="html"><![CDATA[friendcodes script from justdabomb2]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=66953#p66953"><![CDATA[
Uhm...  What is wrong with this script that it causes my bot to LOOP and rehash 3 times when I load this script?  I had to KILL my bot and restart it, as simply unloading the script and doing a restart did not solve the problem.<br><br>I suspect this bit of weirdness might have something to do with the problem:<div class="codebox"><p>Code: </p><pre><code>set mphtfile "scripts/codes/mphtcodes.txt" if {![file exists $mphtfile]} {   catch {close [open $mphtfile w]} } </code></pre></div>or maybe this weirdness:<div class="codebox"><p>Code: </p><pre><code>proc add:mpht {nick uhost hand chan arg} {   global noticecolor  set gamer $nick   set code [lindex [split $arg] 0]   if {$gamer != "" &amp;&amp; $code != ""} {     set fd [open $::mphtfile r+]     while {![eof $fd]} {       lappend list [gets $fd]     }     if {[lindex $list end] == ""} {       set list [lreplace $list end end]     }     lappend list "\[$nick\] &lt;$gamer&gt; &lt;$code&gt;"     seek $fd 0     puts -nonewline $fd [join $list \n]     close $fd     putquick "NOTICE $nick :^C$noticecolor Your code for ^BMPHT^B has been added."     } else {     putquick "NOTICE $nick :^C$noticecolor Type ^B!addmpht &lt;code&gt;^B"   } } </code></pre></div>or maybe using proc names that are actually tcl's commands??<div class="codebox"><p>Code: </p><pre><code>proc info:find {nick uhost hand rest txt} {</code></pre></div>Gawd... &lt;shakes her head sadly&gt;<br><br>I have asked that this script be removed from the tcl archive until the author actually fixes this, as it is a serious problem.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7395">rosc2112</a> — Thu Oct 05, 2006 7:07 pm</p><hr />
]]></content>
	</entry>
	</feed>
