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

	<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>2009-03-19T23:48:25-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Ikaa]]></name></author>
		<updated>2009-03-19T23:48:25-04:00</updated>

		<published>2009-03-19T23:48:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87966#p87966</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87966#p87966"/>
		<title type="html"><![CDATA[Changing quote search output in Quote_Tcl-3.52 by Stigmata]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87966#p87966"><![CDATA[
This script does everything I want it to with one exception: Searching. It creates a file and DCC sends it to you, instead of displaying the numbered results in the channel.<br><br>In looking at other scripts and trying to determine how to modify the search output for this script, i came to the conclusion I'm way in over my head, and needed some help.<br><br>Ideally what I'd like it to do is when it is given the !findquote command and a search string, have it display in the channel the quote numbers that match that string, such as this:<br><br>Results found: #4, #6, #32<br><br>or<br><br>No Results found for search string<br><br>Any help or direction on where to find how to make these mods is most appreciated.<br><div class="codebox"><p>Code: </p><pre><code>################################################### QUOTE TCL V3.52 BY STIGMATA ######### Quote TCL version 3.52, by stigmata# Email: stigmata@hvc.rr.com# IRC: EFNet, [stig] OR [st1gg0r]# Read the README for more information# This script contains the flood protection procedures from the BSeen script.# This script requires alltools.tcl v1.3 (loaded by default)# ################################################### QUOTE TCL V3.52 BY STIGMATA ############################################################ DEFAULT COMMANDS AND INFO ########### Note: The following commands are all public commands, they are available via message#       and DCC chat also. With or without the command designation, they will work in#       private message. File request commands are not available in DCC chat.## !quote(s) &lt;num&gt;# ### Displays a random quote or the number specified.# ### Default access: Everyone## !addquote &lt;quote&gt;# ### This adds quotes to the storage file, quotes can contain any type of character.# ### Default access: global/channel +o OR +Q globally.## !delquote &lt;num&gt;# ### Deletes the quote number specified.# ### Default access: global/channel +o OR +Q globally.## !selquote &lt;num&gt;# ### Prints out the specified quote number.# ### Default access: Everyone## !findquote &lt;word&gt;# ### Searches for the word in the storage file, parses the results to a# ### text file, and sends the user the results.# ### Default access: Everyone## !lastquote# ### Displays the last quote added.# ### Default access: Everyone## !quotehelp# ### Sends the user the quote help file. # ### Default access: Everyone## !getquotes# ### Sends the user the quote storage file.# ### Default access: Everyone## !getscript# ### Sends the user the quote script.# ### Default access: Everyone## !quotestats# ### Shows how many quotes there are and how big the quote storage file is.# ### Default access: Everyone.## !quoteversion# ### Displays the quote version and author name. :)# ### Default access: Everyone#################################################### DEFAULT COMMANDS AND INFO ############################################################ SETTINGS ############################ Select this to your perferred command prefix, "" is acceptable.set qot(cmd) "!"## File name of the storage file for added quotes.set qot(file) "quote.txt"## File name of the backup store file for added quotes.        set qot(backup) "quote.txt.bak"## Access required to read quotes &amp; access help. (Probably don't need# to change this.)set qot(readflag) "-"## Access required to add quotes, "-" is everyone. Note: If a user has any# of these flags, he/she can add quotes.set qot(addflag) "-"## Access required to delete quotes. Note: If a user has any of these flags,# he/she can delete quotes.set qot(delflag) "Qo|m"## This settings is used for flood protection, in the form x:y. Any queries # beyond x in y seconds is considered a flood and the user is ignored.set qot(flood) 4:15## Switch for ignoring flooders if they violate qot(flood) (1=On, 0=Off)set qot(ignore) 1## This is used to set the amount of time a flooder is  ignored (minutes). This# value is useless if qot(ignore) is set to 0.set qot(ignore_time) 5## Access needed to send/recieve quote file.set qot(dccflag) "-|-"## Access needed to restore the backed up quote file.set qot(mergflag) "Qm|-"#################################################### SETTINGS ############################## BINDINGS ### PUBLIC COMMANDS BINDINGS## Random quote bindingsbind pub $qot(readflag) [string trim $qot(cmd)]quotes qot_randombind pub $qot(readflag) [string trim $qot(cmd)]quote qot_random## Add quote bindingsbind pub $qot(addflag) [string trim $qot(cmd)]addquote qot_addquote## Delete quote bindingsbind pub $qot(delflag) [string trim $qot(cmd)]delquote qot_del## Select quote bindingsbind pub $qot(readflag) [string trim $qot(cmd)]selquote qot_sel## Search quote bindingsbind pub $qot(readflag) [string trim $qot(cmd)]quotefind qot_srcbind pub $qot(readflag) [string trim $qot(cmd)]findquote qot_src## DCC Send (Quote file &amp; Script package) bindingsbind pub $qot(dccflag) [string trim $qot(cmd)]getquotes qot_getbind pub $qot(dccflag) [string trim $qot(cmd)]getscript qot_script## Help bindingsbind pub $qot(readflag) [string trim $qot(cmd)]quotehelp qot_helpbind pub $qot(readflag) [string trim $qot(cmd)]quotecommands qot_help## Miscellaneous bindingsbind pub $qot(readflag) [string trim $qot(cmd)]quoteversion qot_verbind pub $qot(readflag) [string trim $qot(cmd)]totalquotes qot_totalbind pub $qot(readflag) [string trim $qot(cmd)]quotestats qot_totalbind pub $qot(readflag) [string trim $qot(cmd)]lastquote qot_last### MESSAGE COMMANDS BINDINGS## Random quote bindingsbind msg $qot(readflag) [string trim $qot(cmd)]quote qot_msgrandombind msg $qot(readflag) [string trim $qot(cmd)]quotes qot_msgrandombind msg $qot(readflag) quote qot_msgrandombind msg $qot(readflag) quotes qot_msgrandom## Add quote bindings bind msg $qot(addflag) [string trim $qot(cmd)]addquote qot_msgaddbind msg $qot(addflag) addquote qot_msgadd## Delete quote bindingsbind msg $qot(delflag) [string trim $qot(cmd)]delquote qot_msgdelbind msg $qot(delflag) delquote qot_msgdel## Select quote bindingsbind msg $qot(readflag) [string trim $qot(cmd)]selquote qot_msgselbind msg $qot(readflag) selquote qot_msgsel## Search quote bindingsbind msg $qot(readflag) [string trim $qot(cmd)]quotefind qot_msgsrcbind msg $qot(readflag) [string trim $qot(cmd)]findquote qot_msgsrcbind msg $qot(readflag) quotefind qot_msgsrcbind msg $qot(readflag) findquote qot_msgsrc## DCC Send (Quote file &amp; Script package) bindingsbind msg $qot(dccflag) [string trim $qot(cmd)]getquotes qot_msggetbind msg $qot(dccflag) [string trim $qot(cmd)]getscript qot_msgscriptbind msg $qot(dccflag) getquotes qot_msggetbind msg $qot(dccflag) getscript qot_msgscript## Help bindingsbind msg $qot(readflag) [string trim $qot(cmd)]quotehelp qot_msghelpbind msg $qot(readflag) [string trim $qot(cmd)]quotecommands qot_msghelpbind msg $qot(readflag) quotehelp qot_msghelpbind msg $qot(readflag) quotecommands qot_msghelp## Miscellaneous bindingsbind msg $qot(readflag) [string trim $qot(cmd)]quoteversion qot_msgverbind msg $qot(readflag) [string trim $qot(cmd)]totalquotes qot_msgtotalbind msg $qot(readflag) [string trim $qot(cmd)]quotestats qot_msgtotalbind msg $qot(readflag) [string trim $qot(cmd)]lastquote qot_msglastbind msg $qot(readflag) quoteversion qot_msgverbind msg $qot(readflag) totalquotes qot_msgtotalbind msg $qot(readflag) quotestats qot_msgtotalbind msg $qot(readflag) lastquote qot_msglast### DCC COMMANDS BINDINGS## Random quote bindingsbind dcc $qot(readflag) quote qot_dccrandombind dcc $qot(readflag) quotes qot_dccrandom## Add quote bindings bind dcc $qot(addflag) addquote qot_dccadd## Delete quote bindingsbind dcc $qot(delflag) delquote qot_dccdel## Select quote bindingsbind dcc $qot(readflag) selquote qot_dccsel## Miscellaneous bindingsbind dcc $qot(readflag) quoteversion qot_dccverbind dcc $qot(readflag) totalquotes qot_dcctotalbind dcc $qot(readflag) quotestats qot_dcctotalbind dcc $qot(readflag) lastquote qot_dcclastbind dcc $qot(mergflag) mergequotes qot_dccmerge########################################################################## TCL PROCEDURES ##################################################### MISC TCL [censored] #################################################set qot(vershort) "3.52"set qot(script) "scripts/quote_tcl-$qot(vershort).tcl"set qot(package) "scripts/quote_tcl-$qot(vershort).tar.gz"putlog "Quote TCL version $qot(vershort) by stigmata loaded. &lt;stigmata@hvc.rr.com&gt;"proc check_string {text} {  regsub -all "&gt;" $text "" text  regsub -all "&lt;" $text "" text  regsub -all "|" $text "" text  regsub -all "&amp;" $text "" text  return $text} proc qot_flood_init {} {  global qot qot_flood_array ; if {![string match *:* $qot(flood)]} {putcmdlog "Quote TCL: var qot(flood) not set correctly." ; return}  set qot(flood_num) [lindex [split $qot(flood) :] 0] ; set qot(flood_time) [lindex [split $qot(flood) :] 1] ; set i [expr $qot(flood_num) - 1]  while {$i &gt;= 0} {set qot_flood_array($i) 0 ; incr i -1 ; }} ; qot_flood_initproc qot_flood {nick uhost} {  global qot qot_flood_array ; if {$qot(flood_num) == 0} {return 0} ; set i [expr $qot(flood_num) - 1]  while {$i &gt;= 1} {set qot_flood_array($i) $qot_flood_array([expr $i - 1]) ; incr i -1} ; set qot_flood_array(0) [unixtime]  if {[expr [unixtime] - $qot_flood_array([expr $qot(flood_num) - 1])] &lt;= $qot(flood_time)} {putcmdlog "Quote TCL: Flood detected from $nick. Ignoring for $qot(ignore_time) minutes." ; if {$qot(ignore)} {newignore [maskhost [getchanhost $nick]] Quote-TCL "$nick flooded the quote script." $qot(ignore_time)} ; return 1  } {return 0}}# moretools stuff... reason why they're here is to make the script easier for people to load. from mc.moretools1.2.tcl by MC_8proc strip:color {ar} { set argument "" if {![string match *\003* $ar]} {return $ar} ; set i -1 ; set length [string length $ar] while {$i &lt; $length} {  if {[string index $ar $i] == "\003"} {   set wind 1 ; set pos [expr $i+1]   while {$wind &lt; 3} {    if {[string index $ar $pos] &lt;= 9 &amp;&amp; [string index $ar $pos] &gt;= 0} {     incr wind 1 ; incr pos 1} {set wind 3    }   }   if {[string index $ar $pos] == "," &amp;&amp; [string index $ar [expr $pos + 1]] &lt;= 9 &amp;&amp;       [string index $ar [expr $pos + 1]] &gt;= 0} {    set wind 1 ; incr pos 1    while {$wind &lt; 3} {     if {[string index $ar $pos] &lt;= 9 &amp;&amp; [string index $ar $pos] &gt;= 0} {      incr wind 1 ; incr pos 1} {set wind 3     }    }   }   if {$i == 0} {    set ar [string range $ar $pos end]    set length [string length $ar]   } {    set ar "[string range $ar 0 [expr $i - 1]][string range $ar $pos end]"    set length [string length $ar]   }   set argument "$argument[string index $ar $i]"  } {incr i 1} } set argument $ar return $argument}proc strip:bold {ar} { set argument "" if {[string match *\002* $ar]} {  set i 0  while {$i &lt;= [string length $ar]} {   if {![string match \002 [string index $ar $i]]} {    set argument "$argument[string index $ar $i]"   } ; incr i 1  } } {set argument $ar} return $argument}proc strip:uline {ar} { set argument "" if {[string match *\037* $ar]} {  set i 0  while {$i &lt;= [string length $ar]} {   if {![string match \037 [string index $ar $i]]} {    set argument "$argument[string index $ar $i]"   } ; incr i 1  } } {set argument $ar} return $argument}proc strip:reverse {ar} { set argument "" if {[string match *\026* $ar]} {  set i 0  while {$i &lt;= [string length $ar]} {   if {![string match \026 [string index $ar $i]]} {    set argument "$argument[string index $ar $i]"   } ; incr i 1  } } {set argument $ar} return $argument}proc strip:all {ar} { return [strip:reverse [strip:uline [strip:bold [strip:color $ar]]]]}proc bold {} {return \002}proc reverse {} {return \026}proc color {} {return \003}proc underline {} {return \037}#### PUBLIC COMMANDS PROCEDURESS ######################################proc qot_random {nick uhost hand chan rest} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    if {![file exists $qot(file)]} {putquick "PRIVMSG $chan :Error: No quotes found--file does not exist"return    } else {    set qot_fd [open $qot(file) r]    }     for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt } {gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    if {$rest==""} {    set qot_cnt [expr $qot_cnt - 2]    set qot_sel $qot_list([set qot_cur [rand [expr $qot_cnt + 1]]])    putquick "PRIVMSG $chan :Quote [bold][expr $qot_cur + 1][bold] of [bold][expr $qot_cnt + 1]:[bold] $qot_sel"    } else {     if {[string is integer $rest]} {    set qot_cnt [expr $qot_cnt - 2]    unset qot_list([expr $qot_cnt + 1])    if {![info exists qot_list([expr {$rest} - 1])]} {        putquick "PRIVMSG $chan :Error: that quote does not exist"        return    } else {    set qot_sel $qot_list([expr {$rest} - 1])    putquick "PRIVMSG $chan :Quote [bold]$rest[bold] of [bold][expr $qot_cnt + 1]:[bold] $qot_sel"    return }}}}proc qot_sel {nick uhost hand chan rest} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    if {![file exists $qot(file)]} {putquick "PRIVMSG $chan :Error: No quotes found--file does not exist"return    }    set qot_fd [open $qot(file) r]    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt 1 } {gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]    unset qot_list([expr $qot_cnt + 1])    if {![info exists qot_list([expr {$rest} - 1])]} {putquick "PRIVMSG $chan :Error: that quote does not exist"return    } else {    set qot_sel $qot_list([expr {$rest} - 1])    putquick "PRIVMSG $chan :Quote [bold]$rest[bold] of [bold][expr $qot_cnt + 1][bold]: $qot_sel"    return    }    return}proc qot_src {nick uhost hand chan rest} {    global qot    set checked [check_string $rest]    if {[qot_flood $nick $uhost]} {return 0}    set qot_src(file) "results-$nick-$rest.txt"    exec grep -i -n "$checked" $qot(file) &gt; $qot_src(file)    dccsend $qot_src(file) $nick    exec rm -f $qot_src(file)    putquick "PRIVMSG $nick :Search performed, writing to a text file and sending it to you."    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Searched for a quote in $chan."     return }proc qot_addquote {nick uhost hand chan rest} {    global qot    set stripped [strip:all $rest]    set qot_fd [open $qot(file) a+]    puts $qot_fd $stripped    close $qot_fd    putquick "PRIVMSG $chan :Quote has been added to storage file."    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Added a quote in $chan."    exec cp "$qot(file)" "$qot(backup)"    return}proc qot_del {nick uhost hand chan rest} {    global qot    set delnum $rest    set type [lindex $rest 0]    set rest [lrange $rest 1 end]    if {![file exists $qot(file)]} {putquick "PRIVMSG $chan :Error: No quotes found--file does not exist"return    } else {set qot_fd [open $qot(file) r]    }    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt 1 } {gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]    if {[string is integer $delnum]} {        set qot_fd [open $qot(file) w]        for { set i 0 } { $i &lt;= $qot_cnt } { incr i 1 } {    if {($qot_list($i) == "") || ($i == [expr $delnum - 1])} {putquick "PRIVMSG $chan :Quote [expr $i + 1] deleted"                putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Deleted a quote in $chan."continue                    } else {puts $qot_fd $qot_list($i)    }}close $qot_fd    } else {    if {$type == "num"} {set qot_fd [open $qot(file) w]for { set i 0 } { $i &lt;= $qot_cnt } { incr i 1 } {    if {($qot_list($i) == "") || ($i == [expr $rest - 1])} {putquick "PRIVMSG $chan :Quote [expr $i + 1] deleted"                putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Deleted a quote in $chan."continue    } else {puts $qot_fd $qot_list($i)    }}close $qot_fd    }    return}}proc qot_get {nick uhost hand chan args} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Requested the quote storage file in $chan"    putquick "NOTICE $nick :Sending the quote storage file."    dccsend $qot(file) $nick    return}proc qot_script {nick uhost hand chan args} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Requested the quote script package in $chan"    putquick "NOTICE $nick :Sending the quote_tcl-$qot(vershort).tar.gz package."    dccsend $qot(package) $nick    return }proc qot_help {nick uhost hand chan rest} {    global qot    set qot(helpfile) "quote_help.txt"    if {[qot_flood $nick $uhost]} {return 0}    putquick "NOTICE $nick :Sending the Quote TCL Help file."    dccsend $qot(helpfile) $nick    return}proc qot_total {nick uhost hand chan rest} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    set qot(byte_size) [file size $qot(file)]    set qot(kb_size) [expr $qot(byte_size) / 1024]    if {![file exists $qot(file)]} {        putchan $chan "Error: No quotes found--file does not exist"        return    } else {    set qot(cnt) [exec grep -c "" $qot(file)]    putquick "PRIVMSG $chan :[bold]$qot(cnt)[bold] quotes total using [bold]$qot(kb_size)kb[bold]."}}proc qot_ver {nick uhost hand chan rest} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    putquick "PRIVMSG $chan :Quote TCL[bold] v$qot(vershort)[bold] by stigmata.[bold]"}proc qot_last {nick uhost hand chan arg} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    if {![file exists $qot(file)]} {        putchan $chan "Error: No quotes found--file does not exist"        return    } else {    set qot_fd [open $qot(file) r]    }    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt } {        gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]        set qot(last) $qot_list([expr $qot_cnt])    putquick "PRIVMSG $chan :[bold]Last Quote ([expr $qot_cnt + 1]):[bold] $qot(last)"    return }#### MESSAGE COMMANDS PROCEDURES #####proc qot_msgrandom {nick uhost hand rest} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    if {![file exists $qot(file)]} {putquick "PRIVMSG $nick :Error: No quotes found--file does not exist"return    } else {      set qot_fd [open $qot(file) r]    }     for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt } {gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    if {$rest==""} {      set qot_cnt [expr $qot_cnt - 2]      set qot_sel $qot_list([set qot_cur [rand [expr $qot_cnt + 1]]])        putquick "PRIVMSG $nick :Quote [bold][expr $qot_cur + 1][bold] of [bold][expr $qot_cnt + 1]:[bold] $qot_sel"    } else {       if {[string is integer $rest]} {        set qot_cnt [expr $qot_cnt - 2]        unset qot_list([expr $qot_cnt + 1])      if {![info exists qot_list([expr {$rest} - 1])]} {        putquick "PRIVMSG $nick :Error: that quote does not exist"        return    } else {        set qot_sel $qot_list([expr {$rest} - 1])           putquick "PRIVMSG $nick :Quote [bold]$rest[bold] of [bold][expr $qot_cnt + 1]:[bold] $qot_sel"    return }}}}proc qot_msgsel {nick uhost hand rest} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    if {![file exists $qot(file)]} {putquick "PRIVMSG $nick :Error: No quotes found--file does not exist"return    }    set qot_fd [open $qot(file) r]    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt 1 } {gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]    unset qot_list([expr $qot_cnt + 1])    if {![info exists qot_list([expr {$rest} - 1])]} {putquick "PRIVMSG $nick :Error: that quote does not exist"return    } else {    set qot_sel $qot_list([expr {$rest} - 1])    putquick "PRIVMSG $nick :Quote [bold]$rest[bold of [bold][expr $qot_cnt + 1][bold]: $qot_sel"    return    }    return}proc qot_msgsrc {nick uhost hand arg} {    global qot    set checked [check_string $arg]    if {[qot_flood $nick $uhost]} {return 0}    set qot_src(file) "results-$nick-$arg.txt"    exec grep -i -n "$checked" $qot(file) &gt; $qot_src(file)    if {![file exists $qot_src(file)]} {       putquick "PRIVMSG $nick :Error, no quotes found. Please try again."    }    dccsend $qot_src(file) $nick    exec rm -f $qot_src(file)    putquick "PRIVMSG $nick :Search performed, writing to a text file and sending it to you."    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Searched for a quote via message."    return}proc qot_msgadd {nick uhost hand arg} {    global qot    set stripped [strip:all $arg]    set qot_fd [open $qot(file) a+]    puts $qot_fd $stripped    close $qot_fd    putquick "PRIVMSG $nick :Quote has been added to storage file."    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Added a quote via message."    exec cp $qot(file) $qot(backup)    return}proc qot_msgdel {nick uhost hand rest} {    global qot    set delnum $rest    set type [lindex $rest 0]    set rest [lrange $rest 1 end]    if {![file exists $qot(file)]} {putquick "PRIVMSG $nick :Error: No quotes found--file does not exist"return    } else {set qot_fd [open $qot(file) r]    }    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt 1 } {gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]    if {[string is integer $delnum]} {        set qot_fd [open $qot(file) w]        for { set i 0 } { $i &lt;= $qot_cnt } { incr i 1 } {            if {($qot_list($i) == "") || ($i == [expr $delnum - 1])} {                putquick "PRIVMSG $nick :Quote [expr $i + 1] deleted"                putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Deleted a quote via essage."                continue            } else {                puts $qot_fd $qot_list($i)            }        }        close $qot_fd    } else {    if {$type == "num"} {set qot_fd [open $qot(file) w]for { set i 0 } { $i &lt;= $qot_cnt } { incr i 1 } {    if {($qot_list($i) == "") || ($i == [expr $rest - 1])} {                putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Deleted a quote via message."putquick "PRIVMSG $nick :Quote [expr $i + 1] deleted"continue    } else {puts $qot_fd $qot_list($i)    }}close $qot_fd        }        return}}proc qot_msgget {nick uhost hand arg} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Requested the quote storage file via message."    putquick "PRIVMSG $nick :Sending the quotes storage file."    dccsend $qot(file) $nick    return}proc qot_msgscript {nick uhost hand arg} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Requested the quote script package via message."    putquick "PRIVMSG $nick :Sending the quote_tcl-$qot(vershort).tar.gz package."    dccsend $qot(package) $nick    return }proc qot_msghelp {nick uhost hand chan rest} {    global qot    set qot(helpfile) "quote_help.txt"    if {[qot_flood $nick $uhost]} {return 0}    putcmdlog "&lt;&lt;$nick&gt;&gt; !$hand! Requested the quote help file via message."    putquick "PRIVMSG $nick :Sending the Quote TCL Help file."    dccsend $qot(helpfile) $nick    return}proc qot_msgtotal {nick uhost hand arg} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    set qot(byte_size) [file size $qot(file)]    set qot(kb_size) [expr $qot(byte_size) / 1024]    if {![file exists $qot(file)]} {        putquick "PRIVMSG $nick :Error: No quotes found--file does not exist"        return    } else {    set qot(cnt) [exec grep -c "" $qot(file)]    putquick "PRIVMSG $nick :[bold]$qot(cnt)[bold quotes total using [bold]$qot(kb_size)kb[bold]."}}proc qot_msgver {nick uhost hand arg} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    putquick "PRIVMSG $nick :Quote TCL[bold] v$qot(vershort)[bold] by stigmata.[bold]"}proc qot_msglast {nick uhost hand arg} {    global qot    if {[qot_flood $nick $uhost]} {return 0}    if {![file exists $qot(file)]} {        putquick "PRIVMSG $nick :Error: No quotes found--file does not exist"        return    } else {    set qot_fd [open $qot(file) r]    }    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt } {        gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]        set qot(last) $qot_list([expr $qot_cnt])    putquick "PRIVMSG $nick :[bold]Last Quote ([expr $qot_cnt + 1]):[bold] $qot(last)"    return}#### DCC COMMANDS PROCEDURES ####proc qot_dccrandom {hand idx rest} {    global qot    if {![file exists $qot(file)]} {        putidx $idx "Error: No quotes found--file does not exist"    return     } else {    set qot_fd [open $qot(file) r]    }    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt } {        gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    if {$rest==""} {    set qot_cnt [expr $qot_cnt -2]    set qot_sel $qot_list([set qot_cur [rand [expr $qot_cnt + 1]]])    putcmdlog "#$hand# quotes"    putidx $idx "Quote [bold][expr $qot_cur + 1][bold] of [bold][expr $qot_cnt + 1]:[bold] $qot_sel"    } else {     if {[string is integer $rest]} {    set qot_cnt [expr $qot_cnt - 2]    unset qot_list([expr $qot_cnt + 1])    if {![info exists qot_list([expr {$rest} - 1])]} {        putidx $idx "Error: that quote does not exist"        return    } else {    set qot_sel $qot_list([expr {$rest} - 1])    putcmdlog "#$hand# quote $rest"    putidx $idx "Quote [bold]$rest[bold] of [bold][expr $qot_cnt + 1]:[bold] $qot_sel"    return}}}}proc qot_dccadd {hand idx rest} {    global qot    set stripped [strip:all $rest]    putcmdlog "#$hand# addquote $rest"    set qot_fd [open $qot(file) a+]    puts $qot_fd $stripped    close $qot_fd    putidx $idx "Quote added to storage file."    exec cp $qot(file) $qot(backup)    return}proc qot_dccdel {hand idx rest} {    global qot    set delnum $rest    set type [lindex $rest 0]    set rest [lrange $rest 1 end]    if {![file exists $qot(file)]} {putidx $idx "Error: No quotes found--file does not exist"return    } else {set qot_fd [open $qot(file) r]    }    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt 1 } {gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]        if {[string is integer $delnum]} {        set qot_fd [open $qot(file) w]        for { set i 0 } { $i &lt;= $qot_cnt } { incr i 1 } {            if {($qot_list($i) == "") || ($i == [expr $delnum - 1])} {                putidx $idx "Quote [expr $i + 1] deleted"                putcmdlog "#$hand# delquote $rest"                continue            } else {                puts $qot_fd $qot_list($i)            }        }        close $qot_fd    } else {    if {$type == "num"} {set qot_fd [open $qot(file) w]for { set i 0 } { $i &lt;= $qot_cnt } { incr i 1 } {    if {($qot_list($i) == "") || ($i == [expr $rest - 1])} {                putcmdlog "#$hand# delquote $rest"putidx $idx "Quote [expr $i + 1] deleted"continue    } else {puts $qot_fd $qot_list($i)    }}close $qot_fd    }    return}}proc qot_dccsel {hand idx rest} {    global qot    if {![file exists $qot(file)]} {        putidx $idx "Error: No quotes found--file does not exist"        return    }    set qot_fd [open $qot(file) r]    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt 1 } {        gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]    unset qot_list([expr $qot_cnt + 1])    if {![info exists qot_list([expr {$rest} - 1])]} {        putidx $idx "Error: that quote does not exist"        return    } else {    set qot_sel $qot_list([expr {$rest} - 1])    putcmdlog "#$hand# selquote $rest"    putidx $idx "Quote [bold]$rest[bold] of [bold][expr $qot_cnt + 1][bold]: $qot_sel"    return    }    return}proc qot_dcctotal {hand idx arg} {    global qot    set qot(byte_size) [file size $qot(file)]    set qot(kb_size) [expr $qot(byte_size) / 1024]    putcmdlog "#$hand# totalquotes"    if {![file exists $qot(file)]} {        putidx $idx "Error: No quotes found--file does not exist"        return    } else {    set qot(cnt) [exec grep -c "" $qot(file)]    putidx $idx "[bold]$qot(cnt)[bold quotes total using [bold]$qot(kb_size)kb[bold]."}}proc qot_dccver {hand idx arg} {    global qot    putcmdlog "#$hand# quoteversion"    putidx $idx "Quote TCL[bold] v$qot(vershort)[bold] by stigmata.[bold]"}proc qot_dcclast {hand idx arg} {    global qot    putcmdlog "#$hand# lastquote"    if {![file exists $qot(file)]} {        putidx $idx "Error: No quotes found--file does not exist"        return    } else {    set qot_fd [open $qot(file) r]    }    for {set qot_cnt 0} { ![eof $qot_fd] } { incr qot_cnt } {        gets $qot_fd qot_list($qot_cnt)    }    close $qot_fd    set qot_cnt [expr $qot_cnt - 2]    set qot(last) $qot_list([expr $qot_cnt])    putidx $idx "[bold]Last Quote ([expr $qot_cnt + 1]):[bold] $qot(last)"    return}proc qot_dccmerge {hand idx arg} {    global qot    putcmdlog "#$hand# mergequotes"    exec cp "$qot(backup)" "$qot(file)"    putidx $idx "Backup quotes storage file restored successfully."    return}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10365">Ikaa</a> — Thu Mar 19, 2009 11:48 pm</p><hr />
]]></content>
	</entry>
	</feed>
