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.

Search and display.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
S
Swinder
Voice
Posts: 5
Joined: Wed Aug 10, 2005 6:00 am

Search and display.

Post by Swinder »

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!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
S
Swinder
Voice
Posts: 5
Joined: Wed Aug 10, 2005 6:00 am

Post by Swinder »

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.
S
Swinder
Voice
Posts: 5
Joined: Wed Aug 10, 2005 6:00 am

Post by Swinder »

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 :(
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

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: Select all

# 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)
Post Reply