| View previous topic :: View next topic |
| Author |
Message |
Swinder Voice
Joined: 10 Aug 2005 Posts: 5
|
Posted: Tue Jun 06, 2006 9:20 am Post subject: Search and display. |
|
|
Hi, i am looking for a script that will search within a specified directory for a text file, the search trigger would be $search <name>
The bot would then go on to list matching files (max of 10), then the user can type $display filename.txt and the bot would display the contents of the text file in priv message to the user.
I did search for the script but found nothing
Any help would be great! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jun 06, 2006 4:46 pm Post subject: |
|
|
What's the purpose of this? Soulds like something *warez* related.. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Swinder Voice
Joined: 10 Aug 2005 Posts: 5
|
Posted: Tue Jun 06, 2006 7:09 pm Post subject: |
|
|
| I am starting like a shop sort of thing but based via IRC, user will be able to search for like CPU and the bot will display a list of 10 CPU's then a user can check out individual CPU's. |
|
| Back to top |
|
 |
Swinder Voice
Joined: 10 Aug 2005 Posts: 5
|
Posted: Sun Jun 11, 2006 12:03 pm Post subject: |
|
|
Anyone intrested in helping out with the script?
Sorry to post again but i have literally got a week to show my boss that it can all be done via IRC, after a week he not going to bother  |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Wed Jun 14, 2006 2:32 am Post subject: |
|
|
| Quote: | Hi, i am looking for a script that will search within a specified directory for a text file, the search trigger would be $search <name>
The bot would then go on to list matching files (max of 10), then the user can type $display filename.txt and the bot would display the contents of the text file in priv message to the user.
I did search for the script but found nothing Sad
Any help would be great! |
| Code: | # no / at the end.
set folder ~/my/texts/here
# trigger
set trigger $
bind PUB -|- ${trigger}search pub:search
bind PUB -|- ${trigger}display pub:spew
proc pub:search {n u h c t} {
global folder
set results [lrange [glob -nocomplain $folder/[lindex [split $t] 0]] 0 9];#max of 10 results
if {![llength $results]} {
putserv "NOTICE $n :No results."
} else {
putserv "NOTICE $n :Found [llength $results] results: [join [tail $results]]"
}
}
proc pub:spew {n u h c t} {
global folder
if {![file exists $folder/[lindex [split $t] 0]]} {
putserv "NOTICE $n :That file doesn't exist."
} else {
set cont [split [read [set fd [open $folder/[lindex [split $t] 0] r]]] \n][close $fd]
foreach line $cont {
putserv "PRIVMSG $n :$line"
}
}
}
proc tail {list} {
set r ""
foreach i $list {
lappend r [file tail $i]
}
return $r
} |
(untested) |
|
| Back to top |
|
 |
|