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 text file and retrive information to an channel

Old posts that have not been replied to for several years.
Locked
User avatar
esix
Voice
Posts: 39
Joined: Thu Aug 12, 2004 11:16 am
Location: [esix@localhost]
Contact:

Search text file and retrive information to an channel

Post by esix »

Hi,

I wonder if it's possible to make a script that will search text file and retrive information from it. Something like this:

<nick> !Search format
<bot> you can format your hard drive with "format c:"
<nick> !search how to format
<bot> you can format your hard drive with "format c:"

i mean.. bot searches through all lines in a text files than retrieves all lines that match the word that has been searched. If anyone have a sample of this post it in here pls :P
The End
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Search text file and retrive information to an channel

Post by user »

esix wrote:<nick> !search how to format
<bot> you can format your hard drive with "format c:"
Please describe the algorithm used to make this match in a bit more detail.
Have you ever read "The Manual"?
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

The function you seek can be found within a wide variety of already written tcl's that can be found in the tcl archives. Look under "quote scripts"...there are so many, like fluxlearn.tcl, learn.tcl, cufs.tcl......
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Here is a small piece of code to help to get you started. Although you might have to manipulate it alot add lists and arrays to get it working for multiple words and search formats. (You can add multiple response detecting patterns if you like too)

Note: The database doesn't use files here.
(You would have to modify that to if you want to read from a file search a specific match pattern and then display the line)

Code: Select all

set respond_words {
"cya:See you later..."
"lol:Laughs out loud"
"brb:Be Right back"
"gtg:Got to go!"
"tc:Take care!"
}

proc check_word {nick uhost hand chan text} {
 global respond_words
  foreach respond_word $respond_words {
   set acronym [lrange [split $respond_word ":"] 0 end]
   set acronym_definition [lrange [split $respond_word ":"] 1 end]
    if {([string match -nocase *$acronym* $text])} {
     set response $acronym_definition
     send_response $nick $chan $response
     }
   }
 return 0
}

proc send_response {nick chan response} {
 putquick "PRIVMSG $chan :$response" -next
 return 0
} 
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked