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

	<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>2007-02-10T20:31:36-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2007-02-10T20:31:36-04:00</updated>

		<published>2007-02-10T20:31:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70378#p70378</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70378#p70378"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70378#p70378"><![CDATA[
It's not recommended to use list commands over strings. Before applying [lindex] over $text, make sure you first split $text:<div class="codebox"><p>Code: </p><pre><code>set ch [lindex [split $text] 1]</code></pre></div>(same goes for $word).<br><br>Read <a href="http://www.peterre.info/characters.html" class="postlink">How to write eggdrop scripts that won't choke on special characters</a> by Peterre.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sat Feb 10, 2007 8:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chadrt]]></name></author>
		<updated>2007-02-10T05:07:17-04:00</updated>

		<published>2007-02-10T05:07:17-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70365#p70365</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70365#p70365"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70365#p70365"><![CDATA[
Ok all done with that after I have succesfully answered a few of my questions this evening/morning here is what I did:<br><br>Added this:<div class="codebox"><p>Code: </p><pre><code>set ch [lindex $text 1]if {$ch == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(sendmtc) &lt;word&gt; &lt;channel&gt;"return 0}</code></pre></div>then changed #mychannel to $ch and voila it was working just as I wanted.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7522">chadrt</a> — Sat Feb 10, 2007 5:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chadrt]]></name></author>
		<updated>2007-02-10T04:42:12-04:00</updated>

		<published>2007-02-10T04:42:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70364#p70364</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70364#p70364"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70364#p70364"><![CDATA[
Ok this day has been a huge learning experience for me all together.  But here I am not needing to fix anothers code I need create another command (proc) that will send a definition to a specified channel via a command in an msg window.<br><br>Starting with:<div class="codebox"><p>Code: </p><pre><code>proc learn_sendmtc {nick host hand text} {global learnset word [string tolower [lindex $text 0]]if {$word == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(view) &lt;word&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :The word \"$word\" is unknown to me"return 0}set fx [open $learn(file) r]while {![eof $fx]} {set tmp [gets $fx]if {[string compare $word [lindex $tmp 0]] != 0} {continue}set i 1set defs [split [lrange $tmp 1 end] "¦"]set defi ""while {1} {set d [lindex $defs [expr $i-1]]if {$d == ""} {break}putserv "$learn(method-def) #myChannel :$word\002\[\002$i\002\]\002\037:\037 $d"incr i 1}}close $fx}</code></pre></div>At the moment it will accomplish this task but will only send the text to a specific channel listed in the putserv I want that to a varriable that I can set by adding #myChannel or #myChannel2 to end of the command.<br><br>Example (As it is now):<blockquote class="uncited"><div>?? word</div></blockquote>This would send the deffinition of the word to what is listed in the file!<br><br>Example (As I would like it to be!):<blockquote class="uncited"><div>?! word #myChannel</div></blockquote>Would send that to my channel or I could make it mychannel2 or what ever.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7522">chadrt</a> — Sat Feb 10, 2007 4:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2007-02-09T23:51:13-04:00</updated>

		<published>2007-02-09T23:51:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70359#p70359</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70359#p70359"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70359#p70359"><![CDATA[
Good to know that you've enjoyed the process of learning, keep it up <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=":wink:" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Fri Feb 09, 2007 11:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chadrt]]></name></author>
		<updated>2007-02-09T23:40:14-04:00</updated>

		<published>2007-02-09T23:40:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70356#p70356</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70356#p70356"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70356#p70356"><![CDATA[
Ok this post is getting longer, but hey I figured out the problems.  I added another proc in for each of the msg bindings and a letter m to the proc name to keep them all seperate.  Now every command works like a charm.  I will be very happy with this script now.  Thanks for your help and for not just giving me the answer I would not have learned anything that way.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7522">chadrt</a> — Fri Feb 09, 2007 11:40 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chadrt]]></name></author>
		<updated>2007-02-09T23:11:12-04:00</updated>

		<published>2007-02-09T23:11:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70354#p70354</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70354#p70354"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70354#p70354"><![CDATA[
So then I pulled the chan argument out and therefore dont even need the learn_flood?<br><div class="codebox"><p>Code: </p><pre><code>proc learn_learn { nick uhost hand args } { set args [lindex $args 0] set args [split $args " "] switch [lindex $args 0] {  "add" {   if {[lindex $args 2] == ""} {    puthelp "privmsg $nick :Try !learn add word defenition!"    } else {      learn_addEntry $nick [lindex $args 1] [lrange $args 2 end]      puthelp "privmsg $nick :Defenition added"      learn_flood "[lindex $args 1]"     }  }  "del" {   if {[lindex $args 2]!=""} {    learn_delEntry [lindex $args 1] [lindex $args 2]    puthelp "privmsg $nick :Defenition removed"    learn_flood "[lindex $args 1]" $chan   } else {      learn_delEntry [lindex $args 1]      puthelp "privmsg $nick :Defenition removed"</code></pre></div>This script works great now, I still like the other script but this was deffinately a bit of a learning experience for me.<br><br>EDIT:<br>Ok so the new script that I changed this post to, using what I have already learned then bind msg for learn_add should be a different proc because it needs to use a proc that doesnt rely on a set of arguments that includes "chan" and that would be why I get the TCL error in the log?  (correct me if I am wrong!)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7522">chadrt</a> — Fri Feb 09, 2007 11:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chadrt]]></name></author>
		<updated>2007-02-09T22:54:10-04:00</updated>

		<published>2007-02-09T22:54:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70352#p70352</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70352#p70352"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70352#p70352"><![CDATA[
<blockquote class="uncited"><div>From Tcl-commands.doc:<blockquote class="uncited"><div>(4)  PUB<br>bind pub &lt;flags&gt; &lt;command&gt; &lt;proc&gt;<br><strong class="text-strong">procname &lt;nick&gt; &lt;user@host&gt; &lt;handle&gt; &lt;channel&gt; &lt;text&gt;</strong><br><br>Description: used for commands given on a channel. The first word<br>becomes the command and everything else is the text argument.<br><br>(1)  MSG<br>bind msg &lt;flags&gt; &lt;command&gt; &lt;proc&gt;<br><strong class="text-strong">procname &lt;nick&gt; &lt;user@host&gt; &lt;handle&gt; &lt;text&gt;</strong><br><br>Description: used for /msg commands. The first word of the user's<br>msg is the command, and everything else becomes the text argument.</div></blockquote>Notice that there's no &lt;channel&gt; argument in MSG's proc.</div></blockquote>I see what you mean, I will try and fix that in the other code just so that I can learn a little more.  Maybe the old one will work for me afterall.  <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=7522">chadrt</a> — Fri Feb 09, 2007 10:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chadrt]]></name></author>
		<updated>2007-02-09T22:51:47-04:00</updated>

		<published>2007-02-09T22:51:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70350#p70350</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70350#p70350"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70350#p70350"><![CDATA[
I changed the post because this script is much more advanced it seems and I have more control over who, how and where the definitions are added and called upon.  Thanks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7522">chadrt</a> — Fri Feb 09, 2007 10:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Alchera]]></name></author>
		<updated>2007-02-09T22:25:22-04:00</updated>

		<published>2007-02-09T22:25:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70347#p70347</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70347#p70347"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70347#p70347"><![CDATA[
You will find an example msg proc  <a href="http://forum.egghelp.org/viewtopic.php?t=13043&amp;highlight=proc+msg" class="postlink">here</a>.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3646">Alchera</a> — Fri Feb 09, 2007 10:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2007-02-09T22:24:42-04:00</updated>

		<published>2007-02-09T22:24:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70346#p70346</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70346#p70346"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70346#p70346"><![CDATA[
From Tcl-commands.doc:<blockquote class="uncited"><div>(4)  PUB<br>bind pub &lt;flags&gt; &lt;command&gt; &lt;proc&gt;<br><strong class="text-strong">procname &lt;nick&gt; &lt;user@host&gt; &lt;handle&gt; &lt;channel&gt; &lt;text&gt;</strong><br><br>Description: used for commands given on a channel. The first word<br>becomes the command and everything else is the text argument.<br><br>(1)  MSG<br>bind msg &lt;flags&gt; &lt;command&gt; &lt;proc&gt;<br><strong class="text-strong">procname &lt;nick&gt; &lt;user@host&gt; &lt;handle&gt; &lt;text&gt;</strong><br><br>Description: used for /msg commands. The first word of the user's<br>msg is the command, and everything else becomes the text argument.</div></blockquote>Notice that there's no &lt;channel&gt; argument in MSG's proc.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Fri Feb 09, 2007 10:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[chadrt]]></name></author>
		<updated>2007-02-09T22:49:30-04:00</updated>

		<published>2007-02-09T21:11:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=70344#p70344</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=70344#p70344"/>
		<title type="html"><![CDATA[dlearn.tcl is giving an error re args]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=70344#p70344"><![CDATA[
I installed the script and it learns new definitions thru the public commands very well but I would like to be able to add definitions thru msg's but it gives an error when I do:<br><blockquote class="uncited"><div>[20:06] Tcl error [learn_add]: wrong # args: should be "learn_add learn_add nick host hand chan text"</div></blockquote>Here is the script: (minus the copyright info to shorten post)<div class="codebox"><p>Code: </p><pre><code>## Files &amp; Backup time (note: never give the same name to the files or the script will make the bot die ## #Don't forget, all this files need to have +rw permissions you can do that with chmod command.#The file to store learn dataset learn(file) "dlearn.dat"#The file to backup the dataset learn(backupfile) "dlearn.dat.old"#The file where the lock definitions will be stored/savedset learn(lockfile) "dlearn.lock.dat"#The temp file when you need to delete/insert something or add/delete words of lock fileset learn(tempfile) "dlearn.tmp"#The time in minutes between each backup, '0' for no backup usage but you can manualy force backup to be saved.set learn(backuptime) "480"## Triggers ###To add a definition to a word --&gt; trigger &lt;word&gt; &lt;definition&gt;set learn(add) "!learn"#To delete all word --&gt; trigger &lt;word&gt;set learn(forget) "!forget"#To insert a definition to word, the definition will be added to the end --&gt; trigger &lt;word&gt; &lt;definition&gt;set learn(insert) "!insert"#To delete one definition from word --&gt; trigger &lt;word&gt; &lt;n&gt;set learn(del) "!del"#To lock one word, if word is locked it's impossible insert/delete that word --&gt; trigger &lt;word&gt;set learn(lock) "!lock"#This will unlock a locked word --&gt; trigger &lt;word&gt;set learn(unlock) "!unlock"#This is used to retrieve a definition of word --&gt; ?? &lt;word&gt;set learn(view) "??"#The list of words in learn fileset learn(wordlist) "!learnlist"#This is used to see the lock wordsset learn(lockwords) "!locklist"#This is the trigger to force backup to be savedset learn(forcebackup) "!forceback"#This is the trigger to show some misc infoset learn(misc) "!learninfo"#The help with all triggers and other misc stuff. This will change consoant if you have or not permission to change the data.set learn(help) "!lhelp"## Misc ###The flag needed add/insert/delete one definition/delete wordset learn(flags-change) "o"#The flag needed to lock/unlock a word and even to force backup to be saved, i recomend and it's logical# never give less access than the flags-changeset learn(owner) "m"#This is the method PRIVMSG/NOTICE when something changed this will work only for the nick who changeset learn(method) "PRIVMSG"#This is the method PRIVMSG/NOTICE when you try to retrieve a definition, this will be sended to a target request(channel/nick)set learn(method-def) "PRIVMSG"#This is the exempt channels to the bot separated by commas(,)set learn(non-channels) "#Lame,#Bots"############# Don't change nothing below if you don't know what you are doing ################# BINDS ##bind pub - $learn(add) learn_addbind pub - $learn(forget) learn_forgetbind pub - $learn(lock) learn_lockbind pub - $learn(unlock) learn_unlockbind pub - $learn(insert) learn_insertbind pub - $learn(del) learn_delbind pub - $learn(view) learn_viewbind pub - $learn(forcebackup) learn_forcebackbind pub - $learn(lockwords) learn_lockwordsbind pub - $learn(wordlist) learn_listbind pub - $learn(misc) learn_miscbind pub - $learn(help) learn_helpbind msg - $learn(add) learn_addbind msg - $learn(forget) learn_forgetbind msg - $learn(lock) learn_lockbind msg - $learn(unlock) learn_unlockbind msg - $learn(insert) learn_insertbind msg - $learn(del) learn_delbind msg - $learn(view) learn_view_msgbind msg - $learn(forcebackup) learn_forcebackbind msg - $learn(lockwords) learn_lockwordsbind msg - $learn(wordlist) learn_listbind msg - $learn(misc) learn_miscbind msg - $learn(help) learn_help## Misc ##set learn(version) "v1.0.1"putlog "Dekadent Learn $learn(version) by CoolMaster &lt;coolmaster@GameOver.co.pt&gt; &lt;http://coolmaster.cjb.net&gt;"if {$learn(backuptime) &gt; 0} {timer $learn(backuptime) learn_backup}if {[string compare $learn(file) $learn(backupfile)] == 0} {die "Dekadent Learn, you probably have the same name to other types of file, please edit your Dekadent Learn"}if {[string compare $learn(file) $learn(lockfile)] == 0} {die "Dekadent Learn, you probably have the same name to other types of file, please edit your Dekadent Learn"}if {[string compare $learn(file) $learn(tempfile)] == 0} {die "Dekadent Learn, you probably have the same name to other types of file, please edit your Dekadent Learn"}if {[string compare $learn(backupfile) $learn(lockfile)] == 0} {die "Dekadent Learn, you probably have the same name to other types of file, please edit your Dekadent Learn"}if {[string compare $learn(backupfile) $learn(tempfile)] == 0} {die "Dekadent Learn, you probably have the same name to other types of file, please edit your Dekadent Learn"}if {[string compare $learn(tempfile) $learn(lockfile)] == 0} {die "Dekadent Learn, you probably have the same name to other types of file, please edit your Dekadent Learn"}if {![file exists $learn(file)]} {set fxtmp [open $learn(file) w] ; close $fxtmp}if {![file exists $learn(lockfile)]} {set fxtmp [open $learn(lockfile) w] ; close $fxtmp}## Procs ###This will check if word is locked, if is return 1 else return 2proc check_lock {word} {global learnset fx [open $learn(lockfile) r]while {![eof $fx]} {set word_check [gets $fx]if {[string compare $word $word_check] == 0} {close $fx ; return 1}}close $fx ; return 2}# Verify if user have access flags to use learn changes, return 1 if yes else return 2proc check_access {hand type} {global learnif {[matchattr $hand $learn($type)] == 1} {return 1} else {return 2}}# Verify if definition allready exists, if yes will return 1 else return 2proc check_word {word} {global learnset fx [open $learn(file) r]while {![eof $fx]} {set word_check [lindex [gets $fx] 0]if {[string compare $word $word_check] == 0} {close $fx ; return 1}}close $fx ; return 2}# Verify if channel is not on exempt list, if is return 1 else return 2proc isvalidchan {chan} {global learnset chans [string tolower [split "$learn(non-channels)" ","]]set i 0while {1} {set chan_c [lindex $chans $i]if {$chan_c == ""} {return 2} elseif {$chan_c == "$chan"} {return 1}incr i 1}}proc learn_add {nick host hand chan text} {global learnif {[check_access $hand flags-change] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}set word [string tolower [lindex $text 0]]set definition [lrange $text 1 end]if {$definition == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(add) &lt;word&gt; &lt;definition&gt;"return 0}if {[check_word $word] == 1} {putserv "$learn(method) $nick :Definition allready exists"return 0}set fx [open $learn(file) a]puts $fx "$word $definition ¦"close $fxputserv "$learn(method) $nick :Added \"$word\" to database"}proc learn_forget {nick host hand chan text} {global learnif {[check_access $hand flags-change] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}set word [string tolower [lindex $text 0]]if {$word == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(forget) &lt;word&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :Unable to delete, definition not found"return 0}if {[check_lock $word] == 1} {putserv "$learn(method) $nick :Unable to delete, definition is locked"return 0}set fx1 [open $learn(file) r]set fx2 [open $learn(tempfile) w]while {![eof $fx1]} {set tmp [gets $fx1]set word_check [lindex $tmp 0]if {$tmp != ""} {if {[string compare $word $word_check] == 0} {continue} else {puts $fx2 $tmp}}}close $fx1 ; close $fx2exec rm -f $learn(file) ; exec mv $learn(tempfile) $learn(file)putserv "$learn(method) $nick :\"$word\" deleted from database"}proc learn_list {nick host hand chan text} {global learnset words "" ; set check 0set fx [open $learn(file) r]while {![eof $fx]} {set tmp [lindex [gets $fx] 0]set words "$words $tmp"if {$tmp != ""} {set check 1}}close $fxif {$check == 0} {putserv "$learn(method) $nick :The learn file is empty"} else {putserv "$learn(method) $nick :Learn words: $words"}}proc learn_lockwords {nick host hand chan text} {global learnif {[check_access $hand owner] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}set words "" ; set check 0set fx [open $learn(lockfile) r]while {![eof $fx]} {set tmp [gets $fx]set words "$words $tmp"if {$tmp != ""} {set check 1}}close $fxif {$check == 0} {putserv "$learn(method) $nick :The lock file is empty"} else {putserv "$learn(method) $nick :Lock words: $words"}}proc learn_forceback {nick host hand chan text} {global learnif {[check_access $hand owner] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}putlog "#$hand# forced learn backup"learn_backup}proc learn_backup {} {global learnset fx1 [open $learn(file) r]set fx2 [open $learn(backupfile) w]while {![eof $fx1]} {set tmp [gets $fx1]if {$tmp != ""} {puts $fx2 $tmp}}putlog "Learn: backup saved to $learn(backupfile)"timer $learn(backuptime) learn_backupclose $fx1 ; close $fx2}proc learn_view {nick host hand chan text} {global learnif {[isvalidchan [string tolower $chan]] == 1} {putserv "$learn(method) $nick :I can't use learn in this channel"return 0}set word [string tolower [lindex $text 0]]if {$word == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(view) &lt;word&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :The word \"$word\" is unknown to me"return 0}set fx [open $learn(file) r]while {![eof $fx]} {set tmp [gets $fx]if {[string compare $word [lindex $tmp 0]] != 0} {continue}set i 1set defs [split [lrange $tmp 1 end] "¦"]set defi ""while {1} {set d [lindex $defs [expr $i-1]]if {$d == ""} {break}putserv "$learn(method-def) $chan :$word\002\[\002$i\002\]\002\037:\037 $d"incr i 1}}close $fx}proc learn_view_msg {nick host hand chan text} {global learnif {[isvalidchan $chan] == 1} {putserv "$learn(method) $nick :I can't use learn in this channel"return 0}set word [string tolower [lindex $text 0]]if {$word == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(view) &lt;word&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :The word \"$word\" is unknown to me"return 0}set fx [open $learn(file) r]while {![eof $fx]} {set tmp [gets $fx]if {[string compare $word [lindex $tmp 0]] != 0} {continue}set i 1set defs [split [lrange $tmp 1 end] "¦"]set defi ""while {1} {set d [lindex $defs [expr $i-1]]if {$d == ""} {break}putserv "$learn(method-def) $nick :$word\002\[\002$i\002\]\002\037:\037 $d"incr i 1}}close $fx}proc learn_del {nick host hand chan text} {global learnif {[check_access $hand flags-change] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}set word [string tolower [lindex $text 0]]set n [lindex $text 1]if {$n == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(del) &lt;word&gt; &lt;N&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :Word not found please use !learn first"return 0}if {[check_lock $word] == 1} {putserv "$learn(method) $nick :Unable to delete, word is locked"return 0}set fx1 [open $learn(file) r]set fx2 [open $learn(tempfile) w]while {![eof $fx1]} {set tmp [gets $fx1]set word_check [lindex $tmp 0]set i 0set defs [split [lrange $tmp 1 end] "¦"]set defi ""while {1} {if {[expr $i+1] == $n} {incr i 1 ; continue}set d [lindex $defs $i]if {$d == ""} {break}if {$defi == ""} {set defi $d¦} else {set defi $defi$d¦}incr i 1}if {$tmp != ""} {if {[string compare $word $word_check] == 0} {puts $fx2 "$word_check $defi"} else {puts $fx2 $tmp}}}close $fx1 ; close $fx2exec rm -f $learn(file) ; exec mv $learn(tempfile) $learn(file)putserv "$learn(method) $nick :Definition \"$n\" deleted from \"$word\" if exists"}proc learn_insert {nick host hand chan text} {global learnif {[check_access $hand flags-change] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}set word [string tolower [lindex $text 0]]set definition [lrange $text 1 end]if {$definition == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(insert) &lt;word&gt; &lt;definition&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :Word not found please use !learn first"return 0}if {[check_lock $word] == 1} {putserv "$learn(method) $nick :Unable to insert, word is locked"return 0}set fx1 [open $learn(file) r]set fx2 [open $learn(tempfile) w]while {![eof $fx1]} {set tmp [gets $fx1]set word_check [lindex $tmp 0]if {$tmp != ""} {if {[string compare $word $word_check] == 0} {puts $fx2 "$tmp$definition ¦"} else {puts $fx2 $tmp}}}close $fx1 ; close $fx2exec rm -f $learn(file) ; exec mv $learn(tempfile) $learn(file)putserv "$learn(method) $nick :Definition inserted at the end of word"}proc learn_unlock {nick host hand chan text} {global learnif {[check_access $hand owner] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}set word [string tolower [lindex $text 0]]if {$word == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(unlock) &lt;word&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :Unable to lock word, word not found"return 0}if {[check_lock $word] == 2} {putserv "$learn(method) $nick :Unable to unlock, word is not locked"return 0}set fx1 [open $learn(lockfile) r]set fx2 [open $learn(tempfile) w]while {![eof $fx1]} {set tmp [gets $fx1]set word_check [lindex $tmp 0]if {[string compare $word $word_check] == 0} {continue} else {puts $fx2 $tmp}}close $fx1 ; close $fx2exec rm -f $learn(lockfile) ; exec mv $learn(tempfile) $learn(lockfile)putserv "$learn(method) $nick :\"$word\" unlocked"}proc learn_lock {nick host hand chan text} {global learnif {[check_access $hand owner] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}set word [string tolower [lindex $text 0]]if {$word == ""} {putserv "$learn(method) $nick :Invalid syntax, use $learn(lock) &lt;word&gt;"return 0}if {[check_word $word] == 2} {putserv "$learn(method) $nick :Unable to lock definition, not found"return 0}if {[check_lock $word] == 1} {putserv "$learn(method) $nick :Definition allready locked"return 0}set fx [open $learn(lockfile) a]puts $fx $word ; close $fxputserv "$learn(method) $nick :\"$word\" locked"}proc learn_misc {nick host hand chan text} {global learnif {[check_access $hand owner] == 2} {putserv "$learn(method) $nick :You don't have access"return 0}putserv "$learn(method) $nick :\002Dekadent Learn $learn(version) misc information\002"putserv "$learn(method) $nick :The learn file is: \"$learn(file)\", the backup file is: \"$learn(backupfile)\", the learn temp file is \"$learn(tempfile)\", the learn lock file is \"$learn(lockfile)\", the time between each backup is \"$learn(backuptime)\" minutes, the channels that learn views will not appear is/are \"$learn(non-channels)\"."putserv "$learn(method) $nick :The flags to learn/forget/insert/delete/list words is/are \"$learn(flags-change)\", the flags to lock/unlock/list locked words/force backup is/are \"$learn(owner)\", the method to response when a nick add/insert/delete/forget.... is \"$learn(method)\" to a nick, the method to response to a view is \"$learn(method-def)\" to a channel."}proc learn_help {nick host hand chan text} {global learnputserv "$learn(method) $nick :\002*** Dekadent Learn $learn(version) help, the help will be showed if you have the access to that command. ***\002"putserv "$learn(method) $nick :To view a word do: $learn(view) &lt;word&gt;"if {[check_access $hand flags-change] == 1} {putserv "$learn(method) $nick :To add a word do: $learn(add) &lt;word&gt; &lt;definition&gt;"putserv "$learn(method) $nick :To forget a word do: $learn(forget) &lt;word&gt;"putserv "$learn(method) $nick :To insert a definition to a word do: $learn(insert) &lt;word&gt; &lt;definition&gt;"putserv "$learn(method) $nick :To delete a definition from one word do: $learn(del) &lt;word&gt; &lt;N&gt;"putserv "$learn(method) $nick :To see all definied words do: $learn(wordlist)"}if {[check_access $hand owner] == 1} {putserv "$learn(method) $nick :To lock a word do: $learn(lock) &lt;word&gt;"putserv "$learn(method) $nick :To unlock a locked word do: $learn(unlock) &lt;word&gt;"putserv "$learn(method) $nick :To list all locked words do: $learn(lockwords)"putserv "$learn(method) $nick :To force the learn file to be backuped do: $learn(forcebackup)"putserv "$learn(method) $nick :If word is locked the word can't be deleted or some definition be inserted to the word"putserv "$learn(method) $nick :To see some misc information do: $learn(misc)"}}# Happy new 2002 to all dekadents :)</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7522">chadrt</a> — Fri Feb 09, 2007 9:11 pm</p><hr />
]]></content>
	</entry>
	</feed>
