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

	<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>2018-10-21T07:48:22-04:00</updated>

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

		<entry>
		<author><name><![CDATA[juggle]]></name></author>
		<updated>2018-10-21T07:48:22-04:00</updated>

		<published>2018-10-21T07:48:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=107120#p107120</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=107120#p107120"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=107120#p107120"><![CDATA[
I have been looking this kinda script!! i googled so many times an i couldn't fine one.. thanks spike<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12758">juggle</a> — Sun Oct 21, 2018 7:48 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2013-02-03T17:54:53-04:00</updated>

		<published>2013-02-03T17:54:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100897#p100897</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100897#p100897"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100897#p100897"><![CDATA[
See if this variation of the above script will do the job for you...<br><a href="http://forum.egghelp.org/viewtopic.php?p=100363#100363" class="postlink">http://forum.egghelp.org/viewtopic.php?p=100363#100363</a><br><br>You can turn off the timed part of that script with...<div class="codebox"><p>Code: </p><pre><code># Set number of minutes between each timed public read line # # Set this to "0" to disable all timed public read lines # Note: file errors will be sent to the first channel in eTxFile(tchan) set eTxFile(timed) "0"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Sun Feb 03, 2013 5:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[fyre]]></name></author>
		<updated>2013-02-03T17:17:59-04:00</updated>

		<published>2013-02-03T17:17:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100896#p100896</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100896#p100896"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100896#p100896"><![CDATA[
that's nice, could you add more 2 commands to it.. example<br><br>!delline (to delete a specific line)<br>&amp;<br>!list (to see the entire list via notice)<br><br>thanks in advance  <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=7846">fyre</a> — Sun Feb 03, 2013 5:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[janii]]></name></author>
		<updated>2012-11-28T16:47:21-04:00</updated>

		<published>2012-11-28T16:47:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100293#p100293</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100293#p100293"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100293#p100293"><![CDATA[
Now that is sumthing <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br>THank You very very much Spike <br>ur code is working perfectly i dun ve words to thank you thts 2nd problem in a row which u solved <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> Luv yaaaa<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11746">janii</a> — Wed Nov 28, 2012 4:47 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-11-28T17:59:28-04:00</updated>

		<published>2012-11-28T16:02:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100292#p100292</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100292#p100292"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100292#p100292"><![CDATA[
Try this script with all the above instructions. This one has both the commands...<br>EDIT: and a read command to check if it's the line you are looking for before editing:)<br><div class="codebox"><p>Code: </p><pre><code># EditTextFile Version 0.3 ## author:  SpiKe^^ ## e-mail:  spike&lt;at&gt;mytclscripts&lt;dot&gt;com ## webpage: http://mytclscripts.com/ ## This file is Copyrighted under the GNU Public License. ## http://www.gnu.org/copyleft/gpl.html ############  Begin Settings ############ set the full route &amp; file name of the file to edit #set eTxFile(file) {/usr/home/spike/eggdrop/scripts/filename.txt}# set the channel for this script to run in #set eTxFile(chan) {#yourchannel}# set the public trigger for the add line command #set eTxFile(add) {!addline}# set the public trigger for the read line command #set eTxFile(read) {!readline}# set the public trigger for the edit line command #set eTxFile(edit) {!editline}# set the access flags to use the above public commands #set eTxFile(flags) {o|o}############  End Settings ############bind pub $eTxFile(flags) $eTxFile(add) etfProcAddbind pub $eTxFile(flags) $eTxFile(read) etfProcReadbind pub $eTxFile(flags) $eTxFile(edit) etfProcEditproc etfProcAdd {nk uh hn ch tx} {  if {[string tolower $ch] ne [string tolower $::eTxFile(chan)]} { return }  set tf $::eTxFile(file)  if {![file exists $tf]} {    puthelp "PRIVMSG $ch :Text file does not exist: $tf"    return  }  set tx [string trim $tx]  if {$tx eq ""} {    puthelp "PRIVMSG $ch :Correct syntax is: $::eTxFile(add) text to add to the end of the file."    return  }  puthelp "PRIVMSG $ch :Adding: $tx :to file: [file tail $tf]"  set id [open $tf a]  puts $id $tx  close $id  return}proc etfProcRead {nk uh hn ch tx} {  if {[string tolower $ch] ne [string tolower $::eTxFile(chan)]} { return }  set tf $::eTxFile(file)  if {![file exists $tf]} {    puthelp "PRIVMSG $ch :Text file does not exist: $tf"    return  }  set tx [string trim $tx]  if {![string is digit -strict $tx]} {    puthelp "PRIVMSG $ch :Correct syntax is: $::eTxFile(read) line#"    return  }  set tid [open $tf]  set lnum 0  while {![eof $tid]} {    set line [gets $tid]    if {$line ne ""} {  incr lnum      if {$lnum==$tx} {        puthelp "PRIVMSG $ch :Existing line $lnum text: $line"        break      }    }  }  close $tid  if {$tx&gt;$lnum} {    puthelp "PRIVMSG $ch :File line $tx doesn't exist ($lnum lines in the file)"  }  return}proc etfProcEdit {nk uh hn ch tx} {  if {[string tolower $ch] ne [string tolower $::eTxFile(chan)]} { return }  set tf $::eTxFile(file)  if {![file exists $tf]} {    puthelp "PRIVMSG $ch :Text file does not exist: $tf"    return  }  set tx [split [string trim $tx]]  if {[llength $tx]&lt;"2" || ![string is digit -strict [lindex $tx 0]]} {    puthelp "PRIVMSG $ch :Correct syntax is: $::eTxFile(edit) line# text to replace original line."    return  }  set find [lindex $tx 0]  set tx [string trim [join [lrange $tx 1 end]]]  set new [file dirname $tf]/newfile.tmp  set nid [open $new w]  set tid [open $tf]  set lnum 0  while {![eof $tid]} {    set line [gets $tid]    if {$line ne ""} {  incr lnum      if {$lnum==$find} {        puthelp "PRIVMSG $ch :Replacing existing line $lnum text: $line"        puthelp "PRIVMSG $ch :with the new text line: $tx"        puts $nid $tx      } else {  puts $nid $line  }    }  }  close $nid  ;  close $tid  if {$find&gt;$lnum} {    puthelp "PRIVMSG $ch :File line $find doesn't exist ($lnum lines in the file)"    file delete $new  } else {  file rename -force $new $tf  }  return}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Wed Nov 28, 2012 4:02 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-11-26T23:15:08-04:00</updated>

		<published>2012-11-26T23:15:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100282#p100282</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100282#p100282"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100282#p100282"><![CDATA[
Let's try this first.<br>Put the code below in a text file, and name it EditTextFile.tcl<br><div class="codebox"><p>Code: </p><pre><code># EditTextFile Version 0.1 ## author:  SpiKe^^ ## e-mail:  spike&lt;at&gt;mytclscripts&lt;dot&gt;com ## webpage: http://mytclscripts.com/ ## This file is Copyrighted under the GNU Public License. ## http://www.gnu.org/copyleft/gpl.html ############  Begin Settings ############ set the full route &amp; file name of the file to edit #set eTxFile(file) {/usr/home/spike/eggdrop/scripts/filename.txt}# set the channel for this scrip to run in #set eTxFile(chan) {#yourchannel}# change the flags and/or public trigger for the add command here #bind pub o|o !addline etfProcAdd############  End Settings ############proc etfProcAdd {nk uh hn ch tx} {  if {[string tolower $ch] ne [string tolower $::eTxFile(chan)]} { return }  set tf $::eTxFile(file)  if {![file exists $tf]} {    puthelp "PRIVMSG $ch :Text file does not exist: $tf"    return  }  puthelp "PRIVMSG $ch :Adding: $tx :to file: [file tail $tf]"  set id [open $tf a]  puts $id $tx  close $id  return}</code></pre></div>Edit the file and channel settings.<br>Upload the new file to your shell's scripts directory.<br>Add a load line to the bottom of your egg conf file: <div class="codebox"><p>Code: </p><pre><code>source scripts/EditTextFile.tcl</code></pre></div>Upload the edited conf file and .rehash the bot.<br><br>My guess is that the trivia game needs to be stopped before you do any file editing with this script.<br>Try to use the !addline command in the channel you set:<blockquote class="uncited"><div>!addline egghelp.org|what is ur fav website ?</div></blockquote>You may have to rehash or restart the bot to get it to see the new file line, hard for me to say either way:)<br>None of this has been tested, so let me know how the script is coming along.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Mon Nov 26, 2012 11:15 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[janii]]></name></author>
		<updated>2012-11-26T20:31:01-04:00</updated>

		<published>2012-11-26T20:31:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100280#p100280</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100280#p100280"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100280#p100280"><![CDATA[
ok No Worries spike i ll be waiting .. and thank u very much for replyin on the topic<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11746">janii</a> — Mon Nov 26, 2012 8:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-11-26T02:11:32-04:00</updated>

		<published>2012-11-26T02:11:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100261#p100261</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100261#p100261"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100261#p100261"><![CDATA[
That makes the concept more possible, but still not a simple few line script. I will think some on the subject and maybe try some on it tomorrow.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Mon Nov 26, 2012 2:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[janii]]></name></author>
		<updated>2012-11-26T01:07:23-04:00</updated>

		<published>2012-11-26T01:07:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100260#p100260</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100260#p100260"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100260#p100260"><![CDATA[
yes you are right abt it spike but what if we forget abt deleting a question and stick to adding it which is easy part <br>and editing the question number so if we ve errors in our question file it can be modify frm irc ???<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11746">janii</a> — Mon Nov 26, 2012 1:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-11-26T00:59:30-04:00</updated>

		<published>2012-11-26T00:59:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100259#p100259</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100259#p100259"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100259#p100259"><![CDATA[
That's far from a simple script....<br><br>The delete function causes some real issues.  Let's say you have a 5 line file:<blockquote class="uncited"><div>line1<br>line2<br>line3<br>line4<br>line5</div></blockquote>You want to delete line2 and fix line4.  So you delete line2 &amp; that renumbers all lines 3-5 down one number.  Then your next command, edit line 4, would try to edit the wrong question line, and the bad question would remain as it was.  In actual usage, with let's say 20,000+ lines in the file, and a list of 10 or 12 deletes &amp; edits, the numbering system becomes way crazy.<br><br>Also, all the commands would have to make sure the game was stopped before doing anything to the database. Then I believe the eggdrop would have to be rehashed, or maybe even restarted, and the game restarted.<br><br>I'm sure there are other problems with the concept that I haven't thought of yet:)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Mon Nov 26, 2012 12:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[janii]]></name></author>
		<updated>2012-11-25T23:39:04-04:00</updated>

		<published>2012-11-25T23:39:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100258#p100258</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100258#p100258"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100258#p100258"><![CDATA[
thanx 4 the quick reply spike <br>actually the script i posted ws just to give an idea what i want bcoz it does add delete edit but therez a problem tht its just for database and one i want is for trivia file<br>like i mentioned tht i want to add a question in txt file<br>and it shld add a new line whn i do<br> and thn if i want to !delete a question number it does delete tht particular question number<br> and thn to edit it shld modify the said question number<br><br> but the script i posted for an example doesnt do such things ur a famous trivia tcl maker so u shld ve known now wht exactly i want <br>thanx<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11746">janii</a> — Sun Nov 25, 2012 11:39 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2012-11-25T23:13:18-04:00</updated>

		<published>2012-11-25T23:13:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100257#p100257</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100257#p100257"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100257#p100257"><![CDATA[
So, what's wrong with the script you posted??<br><br>It already does add, delete, and edit of a text database file.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Sun Nov 25, 2012 11:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[janii]]></name></author>
		<updated>2012-11-25T22:42:29-04:00</updated>

		<published>2012-11-25T22:42:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100256#p100256</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100256#p100256"/>
		<title type="html"><![CDATA[Simple !add !delete !edit  Script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100256#p100256"><![CDATA[
hello i want a tcl which does the following<br>This is the out put text file<br><br>17|how old are you?<br>7th nov|what is date today?<br>egghelp.org|what is ur fav website ?<br><br>Now i want to add delete and edit in above text file<br><br>!add guides|what is ur nick ? {and it shld add a new line i.e line#4}<br><br>17|how old are you?<br>7th nov|what is date today?<br>egghelp.org|what is ur fav website ?<br>guides|what is ur nick ?<br><br>!delete 4        {it shld delete line #4<br><br>!edit 4 janii| wat  ur nick ? {it shld replace line#4 guides with janii}<br><br><br>17|how old are you?<br>7th nov|what is date today?<br>egghelp.org|what is ur fav website ?<br>janii|what is ur nick ?<br><br>the below code is similar to what i want but not exactly wht i want if some one can modify it to my needs <br>and ya only few nicks can do !add !edit !delete commands<br>thanx<br><div class="codebox"><p>Code: </p><pre><code># *************************************************************************************************************************************** ## ********** INSTALLATION *************************************************************************************************************** ## 1 configure database.tcl in a suitable text editor# 2 create the subdirectory scripts/database if it doesn't already exist# 3 put the configured database.tcl into the bot's scripts/database subdirectory# 4 add a line to the end of the bot's .conf file 'source scripts/database/database.tcl'# 5 restart the bot (not rehash)# 6 requires '.chanset #channelname +database' in the partyline to function in #channelname# *************************************************************************************************************************************** ## ********** CONFIGURATION ************************************************************************************************************** ## ***** configuration is not essential as some thought has been given to the optimal default settings below ***** ## set here the single character command trigger# ensure that it is set such that it does not interfere with similar commands on this or other bots in the same channel(s)# allowed values are as follows# , = comma# . = period# ! = exclamation mark# $ = dollar sign# &amp; = ampersand# - = hyphen# ? = question mark# ~ = tilde# ; = semi-colon# : = colon# ' = apostrophe# % = percent# ^ = caret# * = asteriskset vDatabaseTrigger !# set here the text colours used in the bot's responses# settings are only valid where channel mode permits colour, otherwise all text is default colour# allowed values are as follows# 00  = white# 01  = black# 02  = blue# 03  = green# 04  = light red# 05  = brown# 06  = purple# 07  = orange# 08  = yellow# 09  = light green# 10 = cyan# 11 = light cyan# 12 = light blue# 13 = pink# 14 = grey# 15 = light greyset vDatabaseColor(arrow) 03set vDatabaseColor(compliance) 10set vDatabaseColor(dimmed) 14set vDatabaseColor(emphasis) 12set vDatabaseColor(errors) 04set vDatabaseColor(output) 05set vDatabaseColor(typo) 06# set here the bot user flag required to add, modify or delete database records# allowed values are as follows# o = global operator# m = global master# n = global ownerset vDatabaseFlag m# *************************************************************************************************************************************** ## ********** CODE *********************************************************************************************************************** ## *********************************** ## *** DO NOT EDIT BELOW THIS LINE *** ## *********************************** ## ---------- INITIALISE ------------------------------------------- #set vDatabaseVersion 10.04.29.15.48setudef flag databaseset vDatabaseCommands {add copy delete help keywords modify replace search show}proc pDatabaseTrigger {} {    global vDatabaseTrigger    return $vDatabaseTrigger}# ---------- BINDS ------------------------------------------------ #bind EVNT - init-server pDatabaseReadbind EVNT - rehash pDatabaseReadbind PUB - [pDatabaseTrigger]help pDatabaseHelpbind PUB - [pDatabaseTrigger]keywords pDatabaseKeywordsbind PUB - [pDatabaseTrigger]search pDatabaseSearchbind PUB - [pDatabaseTrigger]show pDatabaseShowbind PUB - [pDatabaseTrigger]add pDatabaseAddbind PUB - [pDatabaseTrigger]copy pDatabaseCopybind PUB - [pDatabaseTrigger]delete pDatabaseDeletebind PUB - [pDatabaseTrigger]modify pDatabaseModifybind PUB - [pDatabaseTrigger]replace pDatabaseReplacebind PUBM - "#% [pDatabaseTrigger]*" pDatabaseCheck# ---------- PROCS ------------------------------------------------ #proc pDatabaseAdd {nick uhost hand chan text} {    global vDatabaseData vDatabaseFlag    if {[channel get $chan database]} {        if {[matchattr $hand $vDatabaseFlag]} {            set txt [string trim $text]            set cmd add            if {[llength [split $txt]] &gt; 1} {                set keyword [stripcodes bcruag [string tolower [lindex [split $txt] 0]]]                set body [join [lrange [split $txt] 1 end]]                switch -- [array size vDatabaseData] {                    0 {                        set vDatabaseData($keyword) $body                        pDatabaseWrite                        pDatabaseCompliance 001 0 $nick $chan $keyword 0                    }                    default {                        if {![info exists vDatabaseData($keyword)]} {                            set vDatabaseData($keyword) $body                            pDatabaseWrite                            pDatabaseCompliance 001 0 $nick $chan $keyword 0                        } else {pDatabaseError 003 0 $nick $chan $keyword 0}                    }                }            } else {pDatabaseError 001 $cmd $nick $chan 0 0}        } else {pDatabaseError 010 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseCheck {nick uhost hand chan text} {    global vDatabaseCommands    if {![isbotnick $nick]} {        set command [string trimleft [lindex [split $text] 0] [pDatabaseTrigger]]        if {[lsearch -exact $vDatabaseCommands $command] == -1} {            foreach item $vDatabaseCommands {                switch -- [expr {[string length $command] - [string length $item]}] {                    -1 {                        for {set loop 0} {$loop &lt; [string length $item]} {incr loop} {                            set pattern [string replace $item $loop $loop]                            if {[string equal $pattern $command]} {                                pDatabaseTypo 001 0 $nick $chan $item 0                                return 0                            }                        }                    }                    0 {                        for {set loop 0} {$loop &lt; [string length $item]} {incr loop} {                            set pattern [string replace $command $loop $loop \?]                            if {[string match $pattern $item]} {                                pDatabaseTypo 001 0 $nick $chan $item 0                                return 0                            }                        }                    }                    1 {                        for {set loop 0} {$loop &lt;= [string length $item]} {incr loop} {                            switch -- $loop {                                0 {set pattern \?$item}                                [string length $item] {set pattern $item\?}                                default {set pattern [string range $item 0 [expr {$loop - 1}]]\?[string range $item $loop end]}                            }                            if {[string match $pattern $command]} {                                pDatabaseTypo 001 0 $nick $chan $item 0                                return 0                            }                        }                    }                    default {continue}                }            }        }    }    return 0}proc pDatabaseColor {chan type number} {    global vDatabaseColor    if {[regexp -- {^\+[^\-]*c} [getchanmode $chan]]} {        return ""    } else {        switch -- $number {            1 {                switch -- $type {                    0 {return "\003$vDatabaseColor(errors)"}                    1 {return "\003$vDatabaseColor(compliance)"}                    2 {return "\003$vDatabaseColor(output)"}                    3 {return "\003$vDatabaseColor(typo)"}                    default {}                }            }            3 {return "\003$vDatabaseColor(dimmed)"}            5 {return "\003$vDatabaseColor(arrow)"}            7 {return "\003$vDatabaseColor(emphasis)"}            2 - 4 - 6 - 8 {return "\003"}            default {}        }    }}proc pDatabaseCompliance {number cmd nick chan t1 t2} {    for {set loop 1} {$loop &lt;= 8} {incr loop} {        set col($loop) [pDatabaseColor $chan 1 $loop]    }    set output1 "$col(1)Compliance$col(2) ($col(3)$nick$col(4)) $col(5)--&gt;$col(6)"    switch -- $number {        001 {set output2 "$col(7)$t1$col(8) and associated text has been added"}        002 {set output2 "$col(7)$t1$col(8) has been deleted"}        003 {set output2 "text associated with $col(7)$t1$col(8) has been modified"}        004 {set output2 "found matching keywords $col(7)$t1$col(8)"}        005 {set output2 "keyword $col(7)$t1$col(8) replaced by $col(7)$t2$col(8) but retaining same text"}        006 {set output2 "keyword $col(7)$t1$col(8) copied to $col(7)$t2$col(8) with same text"}        default {}    }    putserv "PRIVMSG $chan :$output1 $output2"    return 0}proc pDatabaseCopy {nick uhost hand chan text} {    global vDatabaseData vDatabaseFlag    if {[channel get $chan database]} {        if {[matchattr $hand $vDatabaseFlag]} {            set txt [string trim $text]            set cmd copy            if {[llength [split $txt]] == 2} {                set old [stripcodes bcruag [string tolower [lindex [split $txt] 0]]]                set new [stripcodes bcruag [string tolower [lindex [split $txt] 1]]]                switch -- [array size vDatabaseData] {                    0 {pDatabaseError 002 0 $nick $chan 0 0}                    default {                        if {[info exists vDatabaseData($old)]} {                            if {![info exists vDatabaseData($new)]} {                                set vDatabaseData($new) $vDatabaseData($old)                                pDatabaseWrite                                pDatabaseCompliance 006 0 $nick $chan $old $new                            } else {pDatabaseError 003 0 $nick $chan $new 0}                        } else {pDatabaseError 004 0 $nick $chan $old 0}                    }                }            } else {pDatabaseError 001 $cmd $nick $chan 0 0}        } else {pDatabaseError 010 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseDelete {nick uhost hand chan text} {    global vDatabaseData vDatabaseFlag    if {[channel get $chan database]} {        if {[matchattr $hand $vDatabaseFlag]} {            set keyword [stripcodes bcruag [string tolower [string trim $text]]]            set cmd delete            if {[llength [split $keyword]] == 1} {                switch -- [array size vDatabaseData] {                    0 {pDatabaseError 002 0 $nick $chan 0 0}                    default {                        if {[info exists vDatabaseData($keyword)]} {                            unset vDatabaseData($keyword)                            pDatabaseWrite                            pDatabaseCompliance 002 0 $nick $chan $keyword 0                        } else {pDatabaseError 004 0 $nick $chan $keyword 0}                    }                }            } else {pDatabaseError 001 $cmd $nick $chan 0 0}        } else {pDatabaseError 010 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseError {number cmd nick chan t1 t2} {    for {set loop 1} {$loop &lt;= 8} {incr loop} {        set col($loop) [pDatabaseColor $chan 0 $loop]    }    set output1 "$col(1)Error$col(2) ($col(3)$nick$col(4)) $col(5)--&gt;$col(6)"    switch -- $number {        001 {            switch -- [pDatabaseSyntax $cmd] {                "" {set output2 "correct syntax is $col(7)[pDatabaseTrigger]$cmd$col(8) without additional arguments"}                default {set output2 "correct syntax is $col(7)[pDatabaseTrigger]$cmd [pDatabaseSyntax $cmd]$col(8)"}            }        }        002 {set output2 "keyword database is empty"}        003 {set output2 "keyword $col(7)$t1$col(8) already exists"}        004 {set output2 "keyword $col(7)$t1$col(8) does not exist"}        005 {set output2 "the text you entered for keyword $col(7)$t1$col(8) is the same as already exists"}        006 {set output2 "the &lt;part-keyword&gt; search text must be at least 3 characters in length"}        007 {set output2 "nothing found for &lt;part-keyword&gt; $col(7)$t1$col(8)"}        008 {set output2 "the character $col(7)\xA5$col(8) cannot be used anywhere in the keyword or associated text"}        009 {set output2 "unrecognised command $col(7)$t1$col(8)"}        010 {set output2 "you do not have access to the command $col(7)$cmd$col(8)"}        011 {set output2 "$col(7)[pDatabaseTrigger]$cmd$col(8) optional argument(s) must be a single letter"}        012 {set output2 "no keywords found matching $col(7)$t1$col(8)"}        013 {set output2 "no keywords found matching $col(7)$t1$col(8) through $col(7)$t2$col(8)"}        014 {set output2 "second $col(7)[pDatabaseTrigger]$cmd$col(8) optional argument must be lexicographically greater than the first"}        default {}    }    putserv "PRIVMSG $chan :$output1 $output2"    return 0}proc pDatabaseHelp {nick uhost hand chan text} {    global vDatabaseCommands    if {[channel get $chan database]} {        set txt [string tolower [string trim $text]]        set cmd help        switch -- [llength [split $txt]] {            0 {                foreach item $vDatabaseCommands {                    pDatabaseOutput 003 0 0 $chan $item 0                }            }            1 {                if {[lsearch -exact $vDatabaseCommands $txt] != -1} {                    pDatabaseOutput 003 0 0 $chan $txt 0                } else {pDatabaseError 009 0 $nick $chan $txt 0}            }            default {pDatabaseError 001 $cmd $nick $chan 0 0}        }    }    return 0}proc pDatabaseKeywords {nick uhost hand chan text} {    global vDatabaseData    if {[channel get $chan database]} {        set txt [string tolower [string trim $text]]        set cmd keywords        if {([llength [split $txt]] &gt;= 0) &amp;&amp; ([llength [split $txt]] &lt;= 2)} {            switch -- [array size vDatabaseData] {                0 {pDatabaseError 002 0 $nick $chan 0 0}                default {                    switch -- [llength [split $txt]] {                        0 {set data [lsort -dictionary [array names vDatabaseData]]}                        1 {                            if {[regexp -- {^[a-z]$} $txt]} {                                set data [lsort -dictionary [array names vDatabaseData ${txt}*]]                                if {[llength $data] == 0} {                                    pDatabaseError 012 0 $nick $chan ${txt}* 0                                    return 0                                }                            } else {                                pDatabaseError 011 $cmd $nick $chan 0 0                                return 0                            }                        }                        2 {                            set arg1 [lindex [split $txt] 0]                            set arg2 [lindex [split $txt] 1]                            if {[regexp -- {^[a-z]$} $arg1] &amp;&amp; [regexp -- {^[a-z]$} $arg2]} {                                if {$arg2 &gt; $arg1} {                                    set data [lsort -dictionary [array names vDatabaseData -regexp [subst -nocommands {^[$arg1-$arg2]}]]]                                    if {[llength $data] == 0} {                                        pDatabaseError 013 0 $nick $chan ${arg1}* ${arg2}*                                        return 0                                    }                                } else {                                    pDatabaseError 014 $cmd $nick $chan 0 0                                    return 0                                }                            } else {                                pDatabaseError 011 $cmd $nick $chan 0 0                                return 0                            }                        }                        default {}                    }                    while {[llength $data] &gt; 0} {                        pDatabaseOutput 002 0 0 $chan [lrange $data 0 24] 0                        set data [lrange $data 25 end]                    }                }            }        } else {pDatabaseError 001 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseModify {nick uhost hand chan text} {    global vDatabaseData vDatabaseFlag    if {[channel get $chan database]} {        if {[matchattr $hand $vDatabaseFlag]} {            set txt [string trim $text]            set cmd modify            if {[llength [split $txt]] &gt; 1} {                switch -- [array size vDatabaseData] {                    0 {pDatabaseError 002 0 $nick $chan 0 0}                    default {                        set keyword [stripcodes bcruag [string tolower [lindex [split $txt] 0]]]                        set body [join [lrange [split $txt] 1 end]]                        if {[info exists vDatabaseData($keyword)]} {                            if {![string equal $body $vDatabaseData($keyword)]} {                                set vDatabaseData($keyword) $body                                pDatabaseWrite                                pDatabaseCompliance 003 0 $nick $chan $keyword 0                            } else {pDatabaseError 005 0 $nick $chan $keyword 0}                        } else {pDatabaseError 004 0 $nick $chan $keyword 0}                    }                }            } else {pDatabaseError 001 $cmd $nick $chan 0 0}        } else {pDatabaseError 010 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseOutput {number cmd nick chan t1 t2} {    for {set loop 1} {$loop &lt;= 8} {incr loop} {        set col($loop) [pDatabaseColor $chan 2 $loop]    }    switch -- $number {        001 {set output "$col(1)$t1$col(2) $col(5)--&gt;$col(6) $t2"}        002 {set output "$col(1)$t1$col(2)"}        003 {            switch -- [pDatabaseSyntax $t1] {                "" {set output "$col(1)[pDatabaseTrigger]$t1$col(2) $col(5)--&gt;$col(6) [pDatabaseText $t1]"}                default {set output "$col(1)[pDatabaseTrigger]$t1 [pDatabaseSyntax $t1]$col(2) $col(5)--&gt;$col(6) [pDatabaseText $t1]"}            }        }        default {}    }    putserv "PRIVMSG $chan :$output"}proc pDatabaseRead {type} {    global vDatabaseData    if {[file exists database.txt]} {        set id [open database.txt r]        set data [split [read -nonewline $id] \n]        foreach line $data {            set keyword [lindex [split $line \xA5] 0]            set body [lindex [split $line \xA5] 1]            set vDatabaseData($keyword) $body        }        close $id    }    return 0}proc pDatabaseReplace {nick uhost hand chan text} {    global vDatabaseData vDatabaseFlag    if {[channel get $chan database]} {        if {[matchattr $hand $vDatabaseFlag]} {            set txt [string trim $text]            set cmd replace            if {[llength [split $txt]] == 2} {                set old [stripcodes bcruag [string tolower [lindex [split $txt] 0]]]                set new [stripcodes bcruag [string tolower [lindex [split $txt] 1]]]                switch -- [array size vDatabaseData] {                    0 {pDatabaseError 002 0 $nick $chan 0 0}                    default {                        if {[info exists vDatabaseData($old)]} {                            if {![info exists vDatabaseData($new)]} {                                set vDatabaseData($new) $vDatabaseData($old)                                unset vDatabaseData($old)                                pDatabaseWrite                                pDatabaseCompliance 005 0 $nick $chan $old $new                            } else {pDatabaseError 003 0 $nick $chan $new 0}                        } else {pDatabaseError 004 0 $nick $chan $old 0}                    }                }            } else {pDatabaseError 001 $cmd $nick $chan 0 0}        } else {pDatabaseError 010 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseSearch {nick uhost hand chan text} {    global vDatabaseData    if {[channel get $chan database]} {        set keyword [stripcodes bcruag [string tolower [string trim $text]]]        set cmd search        if {[llength [split $keyword]] == 1} {            if {[string length $keyword] &gt;= 3} {                foreach name [array names vDatabaseData] {                    if {[string match *${keyword}* $name]} {                        lappend result $name                    }                }                if {[info exists result]} {                    pDatabaseCompliance 004 0 $nick $chan [join $result] 0                } else {pDatabaseError 007 0 $nick $chan $keyword 0}            } else {pDatabaseError 006 0 $nick $chan 0 0}        } else {pDatabaseError 001 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseShow {nick uhost hand chan text} {    global vDatabaseData    if {[channel get $chan database]} {        set keyword [stripcodes bcruag [string tolower [string trim $text]]]        set cmd show        if {[llength [split $keyword]] == 1} {            switch -- [array size vDatabaseData] {                0 {pDatabaseError 002 0 $nick $chan 0 0}                default {                    if {[info exists vDatabaseData($keyword)]} {                        set output [join [lindex [array get vDatabaseData $keyword] 1]]                        pDatabaseOutput 001 0 0 $chan $keyword $output                    } else {pDatabaseError 004 0 $nick $chan $keyword 0}                }            }        } else {pDatabaseError 001 $cmd $nick $chan 0 0}    }    return 0}proc pDatabaseSyntax {command} {    switch -- $command {        add {set txt "&lt;keyword&gt; &lt;text&gt;"}        copy {set txt "&lt;old-keyword&gt; &lt;new-keyword&gt;"}        delete {set txt "&lt;keyword&gt;"}        help {set txt "?command?"}        keywords {set txt "?letter? ?letter?"}        modify {set txt "&lt;keyword&gt; &lt;text&gt;"}        replace {set txt "&lt;old-keyword&gt; &lt;new-keyword&gt;"}        search {set txt "&lt;part-keyword&gt;"}        show {set txt "&lt;keyword&gt;"}        default {}    }    return $txt}proc pDatabaseText {command} {    switch -- $command {        add {set txt "add a keyword and associated text"}        copy {set txt "copy old-keyword to new-keyword with same text"}        delete {set txt "delete a keyword and associated text"}        help {set txt "output help for all commands or specified command"}        keywords {set txt "show existing keywords, using optional argument(s) to restrict output"}        modify {set txt "modify the text associated with a keyword"}        replace {set txt "replace old-keyword with new-keyword but retain text"}        search {set txt "search keywords for incidences of part-keyword"}        show {set txt "show keyword and associated text"}        default {}    }    return $txt}proc pDatabaseTypo {number cmd nick chan t1 t2} {    for {set loop 1} {$loop &lt;= 8} {incr loop} {        set col($loop) [pDatabaseColor $chan 3 $loop]    }    set output1 "$col(1)Typo$col(2) ($col(3)$nick$col(4)) $col(5)--&gt;$col(6)"    switch -- $number {        001 {set output2 "perhaps you meant to type the command $col(7)[pDatabaseTrigger]$t1$col(8)"}        default {}    }    putserv "PRIVMSG $chan :$output1 $output2"    return 0}proc pDatabaseWrite {} {    global vDatabaseData    set id [open database.txt w]    if {[array size vDatabaseData] != 0} {        foreach {keyword body} [array get vDatabaseData] {            puts $id "$keyword\xA5$body"        }    }    close $id    return 0}# ---------- ACKNOWLEDGEMENT -------------------------------------- #putlog "database.tcl version $vDatabaseVersion loaded"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11746">janii</a> — Sun Nov 25, 2012 10:42 pm</p><hr />
]]></content>
	</entry>
	</feed>
