hey guys
i found this for some time ago and it works really fine for what im using it at
beside 1 thing
its case sentesive i would really like it to search in the .txt file with a -nocase mode
exampel !search Something would the return both something and Something
i have tryed with the -nocase insted of -all ... but i cant make it work
do any of u guys have a clue/hint on it? i would be very greatfull
####################################################################################################
putlog "TextSearcher v0.2 - 1st Offcial Release by IsP (q_lander@hotmail.com)"
#
# This script simply searches a txt file (or text files) for search criteria specified via pub
# or msg commands. It Lets you search within a text file for key words using case insensitive
# trigger commands.
#
# Test on eggdrop v1.6.X.....use at own risk ;)
#
# This script was originally made from another script for 1Real by y0manda,
# rewritten from ground up by IsP@Underent.org
#
# TODO:
# - You tell me?
#
# v0.1 - 1st scripted
# v0.2 - Fixed the counter to display the correct count!
# - Minor bug fix with proc $args - opps, was a mistake, honest ;P
#
####################################################################################################
#Where are the data files? (Use "{file location1} {file location2} {file location 3} {etc...}")
set cd_release ""
#Which channels do I check for the command?
set rlschans ""
#Max number of ourputs?
set rlsmaxsearch 9
#What's the public trigger?
set cmdsearch "!search"
#What Users are allowed to use this trigger/command? (Leave blank for anyone)
set rlsflag ""
#Set your inital tag info here
set rlsinfo ""
########## DO NOT EDIT BELOW ##########
if {$rlsflag == ""} {set rlsflag "-"}
bind pub $rlsflag $cmdsearch rlssearchpub
proc rlssearchpub {nick uhost handle chan arg} {
global rlschans
set valch 0
foreach ch [split $rlschans] {if {$chan == $ch} {set valch 1}}
if {$valch == 0} {return}
rlslocate $chan $uhost $handle "PRIVMSG" "$arg"
}
bind msg $rlsflag $cmdsearch rlssearchmsg
proc rlssearchmsg {nick uhost handle arg} {
global rlschans
set valch 0
foreach ch [split $rlschans] {if {[botonchan $ch]} {if {[onchan $nick $ch]} {set valch 1}}}
if {$valch == 0} {return}
rlslocate $nick $uhost $handle "PRIVMSG" "$arg"
}
proc rlslocate {nick uhost handle type arg} {
global rlsmaxsearch cd_release rlsinfo
if {$arg == ""} {puthelp "$type $nick :Syntax: $cmdsearch <search string>" ;return 0}
regsub -all -- " " ${arg} "*" rlsarg
puthelp "$type $nick : $rlsinfo ...Searching for '$rlsarg'"
set totrlsfound 0
foreach database $cd_release {
set rlsfile [open $database r]
while {![eof $rlsfile]} {
set rlsline [gets $rlsfile]
if {[string match "*$rlsarg*" $rlsline]} {
incr totrlsfound 1
if {$totrlsfound < $rlsmaxsearch} {
puthelp "$type $nick : \002Found:\002 $rlsline"
}
}
}
close $rlsfile
}
if {$totrlsfound > $rlsmaxsearch} {puthelp "$type $nick :There are over $rlsmaxsearch matches. Please be more specific"}
puthelp "$type $nick :There was a total of $totrlsfound entries matching your query."
}
Can anyone please modify this script to search the file from BOTTOM to TOP instead of top to bottom? ie, return the top results starting from the last line to the first
####################################################################################################
putlog "TextSearcher v0.2 - 1st Offcial Release by IsP (q_lander@hotmail.com)"
#
# This script simply searches a txt file (or text files) for search criteria specified via pub
# or msg commands. It Lets you search within a text file for key words using case insensitive
# trigger commands.
#
# Test on eggdrop v1.6.X.....use at own risk ;)
#
# This script was originally made from another script for 1Real by y0manda,
# rewritten from ground up by IsP@Underent.org
#
# TODO:
# - You tell me?
#
# v0.1 - 1st scripted
# v0.2 - Fixed the counter to display the correct count!
# - Minor bug fix with proc $args - opps, was a mistake, honest ;P
#
####################################################################################################
#Where are the data files? (Use "{file location1} {file location2} {file location 3} {etc...}")
set cd_release "scripts/MCC/search_file"
#Which channels do I check for the command?
set rlschans "#BotZone"
#Max number of outputs?
set rlsmaxsearch 9
#What's the public trigger?
set cmdsearch "!search"
#What Users are allowed to use this trigger/command? (Leave blank for anyone)
set rlsflag ""
#Set your inital tag info here
set rlsinfo ""
########## DO NOT EDIT BELOW ##########
if {$rlsflag == ""} {set rlsflag "-"}
bind pub $rlsflag $cmdsearch rlssearchpub
proc rlssearchpub {nick uhost handle chan arg} {
global rlschans
set valch 0
foreach ch [split $rlschans] {if {$chan == $ch} {set valch 1}}
if {$valch == 0} {return}
rlslocate $chan $uhost $handle "PRIVMSG" "$arg"
}
bind msg $rlsflag $cmdsearch rlssearchmsg
proc rlssearchmsg {nick uhost handle arg} {
global rlschans
set valch 0
foreach ch [split $rlschans] {if {[botonchan $ch]} {if {[onchan $nick $ch]} {set valch 1}}}
if {$valch == 0} {return}
rlslocate $nick $uhost $handle "PRIVMSG" "$arg"
}
proc rlslocate {nick uhost handle type arg} {
global rlsmaxsearch cd_release rlsinfo
if {$arg == ""} {puthelp "$type $nick :Syntax: $cmdsearch <search string>" ;return 0}
regsub -all -- " " ${arg} "*" rlsarg
puthelp "$type $nick : $rlsinfo ...Searching for '$rlsarg'"
set totrlsfound 0
set alltext ""
foreach database $cd_release {
set rlsfile [open $database r]
while {![eof $rlsfile]} {
set rlsline [gets $rlsfile]
if {[string match "*$rlsarg*" $rlsline]} {
incr totrlsfound 1
if {$totrlsfound < $rlsmaxsearch} {
lappend alltext $rlsline
}
}
}
close $rlsfile
}
if {$alltext != ""} {
foreach allline [lreverse $alltext] {
puthelp "$type $nick : \002Found:\002 $allline"
}
}
if {$totrlsfound > $rlsmaxsearch} {puthelp "$type $nick :There are over $rlsmaxsearch matches. Please be more specific"}
puthelp "$type $nick :There was a total of $totrlsfound entries matching your query."
}
[15:20] <+dirty> !search a
[15:20] <@BotZone> ...Searching for 'a'
[15:20] <@BotZone> Found: a b c
[15:20] <@BotZone> There was a total of 1 entries matching your query.
[15:20] <+dirty> !search b
[15:20] <@BotZone> ...Searching for 'b'
[15:20] <@BotZone> Found: n t b
[15:20] <@BotZone> Found: k l b m
[15:20] <@BotZone> Found: h i j b
[15:20] <@BotZone> Found: a b c
[15:20] <@BotZone> There was a total of 4 entries matching your query.
Believe that's because the script was still counting the found lines from the top of the file.
This version doesn't count found lines until after finding all matching lines and reversing their order.
Also, added a -nocase tag to the string match code, to make the search ignore case.
####################################################################################################
putlog "TextSearcher v0.2 - 1st Offcial Release by IsP (q_lander@hotmail.com)"
#
# This script simply searches a txt file (or text files) for search criteria specified via pub
# or msg commands. It Lets you search within a text file for key words using case insensitive
# trigger commands.
#
# Test on eggdrop v1.6.X.....use at own risk ;)
#
# This script was originally made from another script for 1Real by y0manda,
# rewritten from ground up by IsP@Underent.org
#
# TODO:
# - You tell me?
#
# v0.1 - 1st scripted
# v0.2 - Fixed the counter to display the correct count!
# - Minor bug fix with proc $args - opps, was a mistake, honest ;P
#
####################################################################################################
#Where are the data files? (Use "{file location1} {file location2} {file location 3} {etc...}")
set cd_release "scripts/MCC/search_file"
#Which channels do I check for the command?
set rlschans "#BotZone"
#Max number of outputs?
set rlsmaxsearch 9
#What's the public trigger?
set cmdsearch "!search"
#What Users are allowed to use this trigger/command? (Leave blank for anyone)
set rlsflag ""
#Set your inital tag info here
set rlsinfo ""
########## DO NOT EDIT BELOW ##########
if {$rlsflag == ""} {set rlsflag "-"}
bind pub $rlsflag $cmdsearch rlssearchpub
proc rlssearchpub {nick uhost handle chan arg} {
global rlschans
set valch 0
foreach ch [split $rlschans] {if {$chan == $ch} {set valch 1}}
if {$valch == 0} {return}
rlslocate $chan $uhost $handle "PRIVMSG" "$arg"
}
bind msg $rlsflag $cmdsearch rlssearchmsg
proc rlssearchmsg {nick uhost handle arg} {
global rlschans
set valch 0
foreach ch [split $rlschans] {if {[botonchan $ch]} {if {[onchan $nick $ch]} {set valch 1}}}
if {$valch == 0} {return}
rlslocate $nick $uhost $handle "PRIVMSG" "$arg"
}
proc rlslocate {nick uhost handle type arg} {
global rlsmaxsearch cd_release rlsinfo
if {$arg == ""} {puthelp "$type $nick :Syntax: $cmdsearch <search string>" ;return 0}
regsub -all -- " " ${arg} "*" rlsarg
puthelp "$type $nick : $rlsinfo ...Searching for '$rlsarg'"
set totrlsfound 0
set alltext ""
foreach database $cd_release {
set rlsfile [open $database r]
while {![eof $rlsfile]} {
set rlsline [gets $rlsfile]
if {[string match -nocase "*$rlsarg*" $rlsline]} {
incr totrlsfound 1
lappend alltext $rlsline
}
}
close $rlsfile
}
if {$alltext != ""} {
set cnt 0
foreach allline [lreverse $alltext] {
incr cnt
if {$cnt > $rlsmaxsearch} { break }
puthelp "$type $nick : \002Found:\002 $allline"
}
}
if {$totrlsfound > $rlsmaxsearch} {puthelp "$type $nick :There are over $rlsmaxsearch matches. Please be more specific"}
puthelp "$type $nick :There was a total of $totrlsfound entries matching your query."
}