This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[SOLVED] Search for files via Eggdrop

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

[SOLVED] Search for files via Eggdrop

Post by tessa1 »

Hi,

i need a a small dj-searchscript that displays the path from a file on my shell.

When i type this in my shell:
root:~# find /home/dj/djpool -iname "*What is Love*"
putty displays the following result:
/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-00_What is Love.mp3
/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-05_What is Love (Rapino-Brothers-Mix).mp3
What i want to do, is to display the result in an IRC-Channel when i type

!find what is love

should the bot display:

/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-00_What is Love.mp3

/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-05_What is Love (Rapino-Brothers-Mix).mp3


Best regards
tessa1
Last edited by tessa1 on Mon Sep 25, 2006 12:48 pm, edited 1 time in total.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

I know this is the scripts request forum, and you probably want a whole working script. I just thought I'd point out that the manpage for "file" for tcl has an example of a filesearch script (although not specifically for eggdrop output.)
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

Hm... something like this?

Thats untested and i dunno if it works.

Code: Select all

bind pub "-|-" !find find_proc
proc find_proc {nick uhost handle channel arg} {
 set num [lindex [split $arg] 0 end]
 set command [concat find /home/dj/djpool -iname *$num*]
 set return [eval $command]

 foreach output [split $return \n] {
  putserv "PRIVMSG $channel :\002$output\002"
 }
}
Best regards
tessa1
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

Ok...

concat is false

i replaced that with exec :wink:

Code: Select all

bind pub "-|-" !find find_proc
proc find_proc {nick uhost handle channel arg} {
 set num [lindex [split $arg] 0 end]
 set command [exec find /home/dj/djpool -iname *$num*]
 set return [eval $command]
  foreach output [split $return \n] {
  putserv "PRIVMSG $channel :$output"
 }
}
But don't works because the output begins with /home/blaaaaa...
Tcl error [find_proc]: invalid command name "/home/dj/djpool/H/test.txt"
Plz help me a little bit :)

Best regards
tessa1
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

bind pub -|- !find find_proc
proc find_proc {nick uhost handle channel arg} {
  set results [glob -nocomplain /home/dj/djpool/*[lrange [split $arg] 0 end]*]

  if {[llength $results]} {
    foreach result $results {
      putserv "PRIVMSG $channel :\002[file tail $result]\002"
    }
  } else {
    putserv "PRIVMSG $channel :Found no results."
  }
}
If you want it to state the entire path (no idea why you would want that)

Change

Code: Select all

putserv "PRIVMSG $channel :\002[file tail $result]\002"
into

Code: Select all

putserv "PRIVMSG $channel :\002$result\002"

(untested)
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

Many thanks...

this code works for me :wink:

Code: Select all

set filepath "/path/to/dirctory"

bind pub -|- !find find_proc
proc find_proc {nick uhost handle channel arg} {
  set results [exec find $filepath -iname *[lindex [split $arg] 0 end]*]

  if {[llength $results]} {
    foreach result $results {
      putserv "PRIVMSG $channel :\002$result\002"
    }
  } else {
    putserv "PRIVMSG $channel :\002No results\002"
  }
}
Best regards
tessa1
Post Reply