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.

customized info script

Old posts that have not been replied to for several years.
Locked
a
ac1d
Voice
Posts: 15
Joined: Mon May 02, 2005 2:02 am

customized info script

Post by ac1d »

hello.
i know there's lots of info scripts already.
but i couldn't find an info script that can work with my large db.
my db is terms and definition stored in a text file. and also terms are have spaces
terms and definitions are seperated by | and one term per line.
so my db file looks like below

example #1 | definition here
exam ple #2 | definition here
exa mpl e #3 | definition here

as you see above, i need search function cause of my db size. and terms have spaces

ex)
'!db example' shows term 1
'!db exam' shows term 1 and 2
'!db exa mpl' shows term 3 (which means can query with space)

i don't need add/del/modify functions since i have db already.
i think if script have separation character option, it will be useful to the people that in similar situation with me.
if someone can make it for me and others. it would be really great. i need it badly :(

Looking for your help
Thanks
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Code: Select all

set infodb "/path/to/dbfile/info.dat"
set maxhits 5

proc pub:info {nick uhost hand chan text} {
 set search [lrange [split $text] 0 e]
 set hits 0
 set db [open $::infodb r]
  while {![eof $db]} {
   set line [gets $db]
   set keyword [concat [lindex [split $line |] 0]]
   if {[string match -noc *[join $search]* $keyword]&&$hits<$::maxhits} {
     set result [concat [lindex [split $line |] 1]]
     putserv "PRIVMSG $chan :\[INFO\] $keyword => $result"
     incr hits
   }
 }
 close $db
 if {!$hits} {
  putserv "PRIVMSG $chan :\[INFO\] I don't know anything about $search."
 }
}

bind pub - !db pub:info
Untested
a
ac1d
Voice
Posts: 15
Joined: Mon May 02, 2005 2:02 am

Post by ac1d »

Oh my god, greenbear
it's working 100% as what i requested!!! (NO ERRORS!)
i did not expect that it can be done with only few lines!
that's the most short script that i've seen
but it works more than that!!
and it's so fast. fast searching and fast paste.
really great. THANK YOU SO MUCH greenbear
it was my first request that someone made for me
i didn't realized that how much i can be happy if someone make own script just for me.

ONCE AGAIN, THANK YOU
YOU ROCK! greenbear :!:

sorry for if there was bad english. i'm too excited :lol:

PS/ for other people who reading this thread.
you can use greenbear's script for such as address book, email index etc,
(friendname | email address or phone number etc,)
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

/me pets ac1id
down boy
Locked