mIRC Home    About    Download    Register    News    Help

Print Thread
#94625 18/08/04 12:48 AM
Joined: Aug 2004
Posts: 1
O
ouiji Offline OP
Mostly harmless
OP Offline
Mostly harmless
O
Joined: Aug 2004
Posts: 1
Hi,

I just got a quotebot, and all is well with it, however it has no search function. I'd like to add a hunk of script that would make it search each quote (line) in the quote.txt file and return a list of quote numbers that contain that string.
Something like !find mIRC
and the bot would reply..
The following quotes contain "mIRC" : [5] [12] [34] [987] (or whatever numbers have mIRC somewhere in their text.)

The problem is I have no clue where to begin and cant for the life of me find one. (after over 5 hours looking online, and an hour looking at every post here that contained "quote" thats been posted since 2003)

Please help with that !find function if you could, or just post/link to any working bot script that has the usual functions that includes !find would be greatly appreciated.

Thanks in advance.
jon

Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
You can use /filter with an alias to do this quite quickly:

on *:text:!find *:#:{
;; Filter all matching lines to the alias
filter -fkn quote.txt fquote $+(*,$2-,*)
;; Output results, $filtered contains number of matching lines
if (!$filtered) msg # No quotes found matching $+(*,$2-,*)
else msg # $filtered quote $+ $iif($filtered != 1,s) matching $+(*,$2-,*) found on line $+ $iif($filtered != 1,s:,:) %temp.fquote
unset %temp.fquote
}

;; Add the line number of a found quote to a temporary global variable
alias -l fquote { %temp.fquote = %temp.fquote $+([,$gettok($1,1,32),]) }

Edit: Added if statement

Last edited by Sigh; 18/08/04 04:25 AM.

Link Copied to Clipboard