| View previous topic :: View next topic |
| Author |
Message |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Mon Apr 06, 2009 1:00 pm Post subject: [SOLVED] Question about Split and array |
|
|
Hello everyone,
again here i am XD
| Quote: | <Way2Death> uhm, i did this but i get invalid command name lassign
[17:50:04] <Way2Death> set numqdata [split $line ":"] lassign $numqdata \ qdatanum qdatatext
[17:50:18] <Way2Death> lassgin is on another line
[17:50:37] <Way2Death> and qdatanum qdatatext are together on another line |
I would like to make the line spit it out in an array, so that i can use the things that are splitted separately
the txt file contains:
| Quote: | 1:Hello
2:Again hello
3:Bla
|
and so on..
This is the whole thing:
| Quote: | 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"
putquick "PRIVMSG $nick : $qot_src(file) $nick "
# Slurp up the data file
set fp [open $qot_src(file) r]
set data [read $fp]
close $fp
set data [split $data "\n"]
foreach line $data {
if { $line=="" } {
set mythin "lol"
} else {
set numqdata [split $line ":"]
putquick "PRIVMSG $chan :Quote $line"
}
}
exec grep -i -n "$checked" $qot(file) > $qot_src(file)
exec rm -f $qot_src(file)
putcmdlog "<<$nick>> !$hand! Searched for a quote in $chan."
return
} |
Last edited by Way2Death on Tue Apr 07, 2009 2:20 pm; edited 2 times in total |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Apr 06, 2009 1:32 pm Post subject: |
|
|
Not entirely sure I understand the question.
Towards the end of the code you pasted, a variable is assigned a value as follows :-
| Code: |
set numqdata [split $line ":"]
|
You don't subsequently use the variable. Neither is it declared within your proc as global, so it couldn't be used elsewhere in other undisclosed code.
As an example, I'll change the variable to an array as follows :-
| Code: |
set numqdata([lindex [split $line \:] 0]) [lindex [split $line \:] 1]
|
Using your example, the array element names become 1, 2, and 3 and the corresponding array element values "Hello", "Again hello" and "Bla".
Obviously, there must not be any additional occurances of : in the text.
Does this go any way towards answering your question? _________________ I must have had nothing to do |
|
| Back to top |
|
 |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Mon Apr 06, 2009 1:42 pm Post subject: |
|
|
Q1: So this would split these 2 ( 1:hello ) in different array's?
but how would output those arrays?
are there like $numqdata(1) ?
Q2: hm on second thought, this wouldn't be smart, as it is a quotation.
As soon as someone put Me Said: Hi
this script becomes useless
Any beter way of doing this? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Apr 06, 2009 2:19 pm Post subject: |
|
|
This would be safe for additional colons...
| Code: | set i [string first ":" $line]
set key [string range $line 0 [expr $i - 1]]
set value [string range $line [expr $i + 1] end]
set numqdata($key) $value |
As for Q1; I hope this commented example illustrates how that array would be used.
| Code: | puthelp "PRIVMSG #somechan :Content of numqdata(1): $numqdata(1)"
#Writes "Content of numqdata(1): Hello" in channel #somechan |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Apr 06, 2009 2:20 pm Post subject: |
|
|
A1. My method creates elements within the SAME array as folows :-
numqdata(1) = "Hello"
numqdata(2) = "Again hello"
numqdata(3) = "Bla"
A2. Whatever character is used to split the line of text into 1. a line number, and 2. the remainder of the text (in this case a colon) must not occur elsewhere within the line.
I did have a similar problem once where I had to use a character within a line to split at, such that there was practically zero possibility of it occuring elsewhere within the text. I used the Yen character, or \xA5 in hex.
Sorry nml375, we seemed to have posted simultaneously. Yours would be a better idea. _________________ I must have had nothing to do
Last edited by arfer on Mon Apr 06, 2009 2:24 pm; edited 1 time in total |
|
| Back to top |
|
 |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Mon Apr 06, 2009 2:21 pm Post subject: |
|
|
| Ok so how would i get the number? so that would be 1 2 3? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Apr 06, 2009 2:31 pm Post subject: |
|
|
The numbers would be whatever is in front of the colon. In your file, that would be numbers. You'll have to explain how you wish to select one specific of the quotesin order to answer your question better.
arfer,
You could adapt your split-code by using lrange and join to get the complete "value", rather than a simple lindex. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Mon Apr 06, 2009 2:43 pm Post subject: |
|
|
what would i be using to count how many arrays there are?
Edit i've got this
| Code: | foreach line $data {
set i [string first ":" $line]
set key [string range $line 0 [expr $i - 1]]
set value [string range $line [expr $i + 1] end]
set numqdata($key) $value
if { $line=="" } {
set mythin "lol"
} else {
if { $total <= 3 } {
putquick "PRIVMSG $chan :Quote $key: $numqdata($key)"
} else {
set totals 3
set counter 0
while {$counter < 3} {
putquick "PRIVMSG $chan :Quote $key: $numqdata($key)"
}
putquick "PRIVMSG $chan :And again all of them: $key"
}
}
|
so what im trying to do is count how many $key's there are,
and then if it is below 3 output them normal
and if there are more than 3 output only 3 and 1 message with all $key's in them |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Apr 06, 2009 7:00 pm Post subject: |
|
|
Check the "array size" command. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Tue Apr 07, 2009 5:42 am Post subject: |
|
|
| nml375 wrote: | | Check the "array size" command. |
Thanks one more thing, is it possible to read the file from the bottom up? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Apr 07, 2009 8:33 am Post subject: |
|
|
Not sure why'd you want that?
You could use the seek command to constantly reposition the file pointer within the file, but that'd be alot of work for no good reason in my mind. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Tue Apr 07, 2009 9:56 am Post subject: |
|
|
The command 'array names numqdata' will return a list of array element names (or 'keys' to put it in context of what has been posted so far).
That list can be sorted in various ways using the 'lsort' command and then you can iterate through the sorted list using say a foreach loop.
For example :-
| Code: |
set namelist [lsort -integer -decreasing [array names numqdata]]
foreach item $namelist {
#code here using $numqdata($item) to reference the element value
}
|
_________________ I must have had nothing to do |
|
| Back to top |
|
 |
Way2Death Voice
Joined: 31 Mar 2009 Posts: 15
|
Posted: Tue Apr 07, 2009 11:35 am Post subject: |
|
|
Thanks
the quote script has been finished.
I Have also added it to the tcl database.
The reason i asked all of this is because i downloaded the quote script of Sigma, but what he did was !findquote would put the search result in a txt file and would dcc it to you. Also the !delquote function didn't work so i also fixed that. Now everything works perfect, thanks to you guys =D
Here is the code
| Code: | ################################################### QUOTE TCL V3.52-W2D01 BY Way2Death - Original Concept Stigma #######
#
# Quote TCL version 3.52-W2D01, by Way2Death
# Email: stigmata@hvc.rr.com
# Email: info@syilmaz.nl
# 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-W2D01 BY Way2Death - Original Concept Stigma #######
#
#
################################################### DEFAULT COMMANDS AND INFO #########
#
#
# !quote(s) <num>
# ### Displays a random quote or the number specified.
# ### Default access: Everyone
#
# !addquote <quote>
# ### This adds quotes to the storage file, quotes can contain any type of character.
# ### Default access: global/channel +o OR +Q globally.
#
# !delquote <num>
# ### Deletes the quote number specified.
# ### Default access: global/channel +o OR +Q globally.
#
# !selquote <num>
# ### Prints out the specified quote number.
# ### Default access: Everyone
#
# !findquote <word>
# ### 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 & 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) "-"
#
# 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|-"
#
# Number of quotes to show
set qot(quoteshow) "3"
################################################### SETTINGS ##########################
#### BINDINGS
### PUBLIC COMMANDS BINDINGS
set quotefile quote.txt
# 0 = display quotes in channel
# 1 = display quotes via private notice.
set quotevianotice 0
bind pub - !quote quote:pub:quote
## Random quote bindings
bind pub $qot(readflag) [string trim $qot(cmd)]quotes qot_random
bind pub $qot(readflag) [string trim $qot(cmd)]quote qot_random
## Add quote bindings
bind pub $qot(addflag) [string trim $qot(cmd)]addquote qot_addquote
## Delete quote bindings
bind pub $qot(delflag) [string trim $qot(cmd)]delquote qot_del
## Select quote bindings
bind pub $qot(readflag) [string trim $qot(cmd)]selquote qot_sel
## Search quote bindings
bind pub $qot(readflag) [string trim $qot(cmd)]quotefind qot_src
bind pub $qot(readflag) [string trim $qot(cmd)]findquote qot_src
## Help bindings
bind pub $qot(readflag) [string trim $qot(cmd)]quotehelp qot_help
bind pub $qot(readflag) [string trim $qot(cmd)]quotecommands qot_help
## Miscellaneous bindings
bind pub $qot(readflag) [string trim $qot(cmd)]quoteversion qot_ver
bind pub $qot(readflag) [string trim $qot(cmd)]totalquotes qot_total
bind pub $qot(readflag) [string trim $qot(cmd)]quotestats qot_total
bind pub $qot(readflag) [string trim $qot(cmd)]lastquote qot_last
#####################################################################
##### TCL PROCEDURES ################################################
##### MISC TCL [censored] #################################################
set qot(vershort) "3.52-W2D01"
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 Way2Death - Original Concept Stigma loaded."
proc check_string {text} {
regsub -all ">" $text "" text
regsub -all "<" $text "" text
regsub -all "|" $text "" text
regsub -all "&" $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 >= 0} {set qot_flood_array($i) 0 ; incr i -1 ; }
} ; qot_flood_init
proc 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 >= 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])] <= $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_8
proc strip:color {ar} {
set argument ""
if {![string match *\003* $ar]} {return $ar} ; set i -1 ; set length [string length $ar]
while {$i < $length} {
if {[string index $ar $i] == "\003"} {
set wind 1 ; set pos [expr $i+1]
while {$wind < 3} {
if {[string index $ar $pos] <= 9 && [string index $ar $pos] >= 0} {
incr wind 1 ; incr pos 1} {set wind 3
}
}
if {[string index $ar $pos] == "," && [string index $ar [expr $pos + 1]] <= 9 &&
[string index $ar [expr $pos + 1]] >= 0} {
set wind 1 ; incr pos 1
while {$wind < 3} {
if {[string index $ar $pos] <= 9 && [string index $ar $pos] >= 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 <= [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 <= [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 <= [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 (4#[bold][expr $qot_cur + 1]/[expr $qot_cnt + 1][bold]1): $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 (4#[bold]$rest/[expr $qot_cnt + 1][bold]1): $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 quote:pub:quotef {nick uhost hand chan arg} {
global quotefile quotevianotice
set quotes ""
if { [file exists $quotefile] } { set file [open $quotefile r]
} else {
if { $quotevianotice == 0 } { putmsg $chan "$quotefile does not exist. You'll need to add quotes to the database first by typing \002!addquote <a quote>\002" }
if { $quotevianotice == 1 } { putnotc $nick "$quotefile does not exist. You'll need to add quotes to the database first by typing \002!addquote <a quote>\002" }
return 0
}
while { ![eof $file] } {
set quote [gets $file]
if { $quote != "" } {
set quotes [linsert $quotes end $quote]
}
}
close $file
if { $arg != "" } {
set pattern [string tolower $arg]
set aquotes ""
set quote ""
foreach quote $quotes {
set lowquote [string tolower $quote]
if { [string match $pattern $lowquote] } {
set aquotes [linsert $aquotes end $quote]
}
set quotes ""
set quotes $aquotes
}
}
set row [rand [llength $quotes]]
if { [expr $row >= 0] && [expr $row < [llength $quotes]] } {
set quote [lindex $quotes $row]
}
if { $quote != "" } {
if { $quotevianotice == 0 } {
putmsg $chan "Quote: $quote"
}
if { $quotevianotice == 1 } {
putnotc $nick "$quote"
}
}
return 1
}
proc qot_src {nick uhost hand chan rest} {
if {$rest == ""} {
putquick "PRIVMSG $chan :Searching for something does require a word to search for..."
break
}
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) > $qot_src(file)
set fp [open $qot_src(file) r]
set data [read $fp]
close $fp
set data [split $data "\n"]
set total 0
set number 0
set totalkeys ""
foreach line $data {
set i [string first ":" $line]
set key [string range $line 0 [expr $i - 1]]
set totalkeys "$totalkeys $key"
}
foreach line $data {
set i [string first ":" $line]
set key [string range $line 0 [expr $i - 1]]
set value [string range $line [expr $i + 1] end]
set numqdata($key) $value
if { $line=="" } {
break
} else {
putquick "PRIVMSG $chan :Quote (4#[bold]$key[bold]1): $numqdata($key)"
set number [expr $number + 1]
if {$number == $qot(quoteshow)} {
putquick "PRIVMSG $chan :And again all of them: $totalkeys"
break
}
}
}
exec rm -f $qot_src(file)
putcmdlog "<<$nick>> !$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 "<<$nick>> !$hand! Added a quote in $chan."
exec cp "$qot(file)" "$qot(backup)"
return
}
proc qot_del {nick uhost hand chan rest} {
if {![isop $nick $chan]} { break }
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 <= $qot_cnt } { incr i 1 } {
if {($qot_list($i) == "") || ($i == [expr $delnum - 1])} {
putquick "PRIVMSG $chan :Quote [expr $i + 1] deleted"
putcmdlog "<<$nick>> !$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 <= $qot_cnt } { incr i 1 } {
if {($qot_list($i) == "") || ($i == [expr $rest - 1])} {
putquick "PRIVMSG $chan :Quote [expr $i + 1] deleted"
putcmdlog "<<$nick>> !$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 "<<$nick>> !$hand! Requested the quote storage file in $chan"
putquick "NOTICE $nick :Sending the quote storage file."
return
}
proc qot_script {nick uhost hand chan args} {
global qot
if {[qot_flood $nick $uhost]} {return 0}
putcmdlog "<<$nick>> !$hand! Requested the quote script package in $chan"
putquick "NOTICE $nick :Sending the quote_tcl-$qot(vershort).tar.gz package."
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."
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 Way2Death.[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
} |
|
|
| Back to top |
|
 |
|