Advertisement
Xzempt

Untitled

Sep 21st, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 4.27 KB | None | 0 0
  1. alias rsearch {
  2.   var %x = 0
  3.  
  4.   ;--------------iterate through quotes table
  5.   while (%x <= $hget(quotes,0).item) {
  6.  
  7.     ;--------------set string data(the quote text);;;;;;;;;;
  8.     var %string = $hget(quotes,%x).data
  9.  
  10.     ;--------------perform a regular expression match on the search parameters
  11.     if ($regex(%string, /(.* $+ %search $+ .*)/i)) {
  12.  
  13.       ;--------------found a match, add it to the results table
  14.       hadd -m results $hget(quotes,%x).item $hget(quotes,%x).data
  15.  
  16.       ;--------------set quote number and it's item referral
  17.       var %qnumber %qnumber $+($chr(35),$hget(quotes,%x).item,=,%x)
  18.       inc %x
  19.     }
  20.     inc %x
  21.   }
  22.   var %results = 1
  23.  
  24.   ;--------------iterate through the results table
  25.   while (%results <= $hget(results,0).item) {
  26.  
  27.     ;--------------set quote number with the # sign for the return values
  28.     set -u3 %quotes %quotes $chr(35) $+ $hget(results, %results).item
  29.     inc %results
  30.   }
  31.  
  32.   ;--------------sets a random number between 1 and $numtok(%qnumber,32), this variable determines the quote number displayed
  33.   var %rquote = $rand(1,$numtok(%qnumber,32))
  34.  
  35.   ;--------------this is the item number of the quote in the table
  36.   var %item.no = $gettok($gettok(%qnumber,%rquote,32),2,61)
  37.  
  38.   ;--------------this is the quote number of the quote in the table
  39.   var %quote.no = $remove($gettok($gettok(%qnumber,%rquote,32),1,61),$chr(35))
  40.  
  41.   ;--------------this is the quote text
  42.   var %quote = $hget(quotes,%item.no).data
  43.  
  44.   ;--------------!%find represents the !randquote command used to trigger this script.
  45.   if (!%find) {
  46.  
  47.     ;--------------found matches for our search parameters...
  48.     if (%quote != $null) {
  49.  
  50.       ;--------------Display the number of matches found for the search parameters...
  51.       msg $chan  09Found1107 $hget(results,0).item 09entries.
  52.  
  53.       ;--------------Display the quote details.
  54.       msg $chan  09Quote Number11:04 %quote.no 09Quote11: $replace($gettok(%quote,1,191),%search,09 $+ %search $+ ) $&
  55.         14-09 $gettok($gettok($read(quotes.txt,%quote.no),2,191),1,58) $+ 11: $+ 07 $+ $gettok($gettok($read(quotes.txt,%quote.no),2,191),2,58) $+ 09 $&
  56.         $gettok($gettok($read(quotes.txt,%quote.no),3,191),1,58) $+ 11:07 $+ $gettok($gettok($read(quotes.txt,%quote.no),3,191),2,58)
  57.  
  58.       ;--------------determines if more than 1 match was found, if so, notices the requesting nick the quote numbers for the remaining entries matched via the supplied search parameters.
  59.       if ($calc($numtok(%quotes,32) - 1) > 0) {
  60.  
  61.         ;--------------notices the requesting nick the remaining matches
  62.         .notice $nick 09 $+ $calc($numtok(%quotes,32) - 1) other related entries11:07 $remove(%quotes, $chr(35) $+ %quote.no)
  63.       }
  64.  
  65.     }
  66.     ;--------------no matches found, error.
  67.     else {
  68.       msg $chan  09Error11:07 There's no quotes containing what you specified.
  69.       unset %quotes
  70.     }
  71.   }
  72.   ;--------------!findquote intext searchparameters command was used.
  73.   else {
  74.  
  75.     ;--------------found matches for our search parameters
  76.     if (%quote != $null) {
  77.  
  78.       ;--------------Display result total
  79.       msg $chan  09Found1107 $hget(results,0).item 09entries.
  80.  
  81.       ;--------------Send quote data
  82.       msg $chan 09Entries11:07 $hget(results,0).item 09Quote Number:04 %quote.no $+  $replace($gettok(%quote,1,191),%search,09 $+ %search $+ ) $&
  83.         14-09 $gettok($gettok($read(quotes.txt,%quote.no),2,191),1,58) $+ : $+ 07 $+ $gettok($gettok($read(quotes.txt,%quote.no),2,191),2,58) $+ 09 $&
  84.         $gettok($gettok($read(quotes.txt,%quote.no),3,191),1,58) $+ :07 $+ $gettok($gettok($read(quotes.txt,%quote.no),3,191),2,58)
  85.  
  86.       ;--------------checks if more than 1 result was found.
  87.       if ($calc($numtok(%quotes,32) - 1) > 0) {
  88.  
  89.         ;--------------notices requesting nick the remaining quote numbers matching our search parameters
  90.         notice $nick 09 $+ $calc($numtok(%quotes,32) - 1) other related entries11:07 $remove(%quotes, $chr(35) $+ %quote.no)
  91.         unset %quotes
  92.       }
  93.       unset %quotes
  94.     }
  95.     ;--------------No matches found, error.
  96.     else {
  97.       ;--------------send error.
  98.       msg $chan 09Error11:07 There's no quotes containing what you specified.
  99.       unset %quotes
  100.     }
  101.   }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement