Advertisement
severen1999

Main Quote Script

Aug 5th, 2018
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 9.24 KB | None | 0 0
  1. #fcheck on
  2. alias -l fcheck {
  3.   if ($regex($1,/(quote|qotd|qsearch)$/Si)) {
  4.     if ($prop = add) set -z $+(%,$regml(1),$site,$network) %fMins
  5.     else return $+(%,$regml(1),$site,$network)
  6.   }
  7. }
  8. #fcheck end
  9.  
  10. ;local alias to convert variable 1 and 2 to uppercase
  11. alias -l up return $+($upper($left($1,1)),$mid($1,2))
  12.  
  13. on *:text:*:#landail: {
  14.   var %file quote.txt, %x $lines(%file), %y $read(%file, n, $2), %rx $r(1,$lines(%file)), %ry $read(%file, n, %rx)
  15.   ; %x  = total lines in quote file
  16.   ; %rx = random number between 1 and max lines in quote file
  17.  
  18.   if (!%x && $regex($1,/^!q(del|uote|otd|search|lines|open)$/Si)) { msg # There does not appear to be any quotes added yet. | halt }
  19.  
  20.   ;--------------------------------------------------------------------------------------------;
  21.   ;   !ADDING, DELETING, Quotes.  !qadd requires ulevel access 5+  !qdel requires ulevel 9+   ;
  22.   ;--------------------------------------------------------------------------------------------;
  23.  
  24.   if ($1 = !qadd || $1 = !addquote || $1 = !quoteadd || $1 = !addq) {
  25.     if ($ulevel < 5) {
  26.       msg # Sorry $nick you need to be a regular to add a quote.
  27.     }
  28.     if (!$2) {
  29.       msg # Syntax: $1 QuoteHere
  30.       echo -s $nick ran the $1 command incorrectly
  31.     }
  32.     tokenize 59 $2- | write %file $+($up($1),) $asctime(mmmm $+(dd,$chr(44)) yyyy) | var %x $lines(%file) | msg # Thank You for the quote! Your quote is number %x $+ . !quote %x to access it.
  33.     set %LandailQuoteTotal $lines(%file)
  34.     echo -s $nick added the quote $1-
  35.   }
  36.  
  37.   if ($1 = !qdel) {
  38.     if ($ulevel < 10) { msg # $v1 Only an admin may delete quotes. | halt }
  39.     if (!$2) { msg # Syntax: $1 [1 - %x $+ ] | halt }
  40.     var %i $numtok($2-, 32)
  41.     while (%i) { var %list $sorttok($addtok(%list,$gettok($sorttok($2-, 32, n),%i,32),32),32,n) | dec %i }
  42.     var %j $numtok(%list, 32)
  43.     while (%j) {
  44.       if (!$read(%file, n, $gettok(%list,%j,32))) {
  45.         msg # Quote # $+ $gettok(%list,%j,32) Does not exist. Quotes 1 to %x exist.
  46.       }
  47.       else {
  48.         msg # Quote $gettok(%list,%j,32) has been removed.
  49.         write -dl $gettok(%list,%j,32) %file
  50.       }
  51.       dec %j
  52.     }
  53.   }
  54.  
  55.   ;------------------------------------------------------------------;
  56.   ;MAIN !QUOTE function calls random quote and also specific quotes  ;
  57.   ;------------------------------------------------------------------;
  58.  
  59.  
  60.   ;-------------------------------------------;
  61.   ;----- QUOTE SCRIPT IF CALLED BY !QUOTE-----;
  62.   ;-------------------------------------------;
  63.  
  64.  
  65.   if ($1 = !Quote) || ($1 = !Quotes) {
  66.     ;OLD IF CHECK WITH JUST !QUOTE BEFORE !QUOTE OR !QUOTES ADDED --->  if ($1 = !quote) {
  67.     ;check if command syntax ran correctly, if not then output correct format
  68.     if ($2 && $2 !isnum) {
  69.       msg # Syntax: $1 [1 - %x $+ ]
  70.       echo -s quote sent to chat. | halt
  71.     }
  72.     ;check if quote number provided exists, if not then output total number of quotes
  73.     if ($2 && !%y || $2 < 0) {
  74.       msg # BibleThump $chr(160) Quote $chr(160) $+ $2 Does not exist. You can select 1 to %x $+ . | halt
  75.     }
  76.     ;antiflood protection. If user level under 4 then flood protection enabled
  77.     if ($ulevel < 7) {
  78.       if ($($fcheck($right($1, -1)),2)) { msg # $nick You must wait $duration($v1) before you can use !quote again.
  79.         echo -s $nick triggered Anti-Flood protection for !quote | halt
  80.       }
  81.     }
  82.     ;$fcheck($right($1, -1)).add
  83.  
  84.     if (!$2) {
  85.       msg # Quote %rx $lower(-) %ry      
  86.       echo -s Should do msg # Quote $chr(160) $+ $2 - %y | halt
  87.     }
  88.     msg # Quote $chr(160) $+ $2 - %y
  89.     echo -s sent quote to the chat
  90.   }
  91.  
  92.   ;-----------------------------------------------------------------------------------------------;
  93.   ; !QOTD QUOTE OF THE DAY!                                                                       ;
  94.   ; Checks & Updates to the current day everytime called.  Keeps same quote until day is changed. ;
  95.   ;-----------------------------------------------------------------------------------------------;
  96.  
  97.   if ($1 = !qotd) {
  98.     if (%date != $date) var -g %date $v2, %qotd %rx
  99.     if ($ulevel < 7) {
  100.       if ($($fcheck($right($1, -1)),2)) {
  101.         msg # You must wait $duration($v1) before you can use that again. | halt
  102.       }
  103.     }
  104.     $fcheck($right($1, -1)).add | msg # $chr(160) $+ $read(%file, n, %qotd)
  105.     echo -s !qotd in $chan was ran.
  106.   }
  107.  
  108.   if ($ulevel = 10 && $1 = !newqotd) {
  109.     echo -s Old qotd number was %qotd
  110.     set %qotd $rand(0,%x)
  111.     echo -s New qotd number chosen randomly from 0 to %x $+ .  Set it to %qotd
  112.     echo -s New qotd number is %qotd $+ . | halt
  113.   }
  114.  
  115.   ;-------------------------------------------------------------------------------;
  116.   ; !QUOTE COMMANDS  ---- SEND LIST OF COMMANDS TO THE # Channel it detects from  ;
  117.   ;  Sends MSG # to calling channel                         ;
  118.   ;-------------------------------------------------------------------------------;
  119.  
  120.   if ($1 = !quotecommands || $1 = !quotehelp || $1 = !quoteshelp || $1 = !helpquote || $1 = !helpquotes || $1 = !qcommands ) {
  121.     msg # !Quote or !Quote %ast #. $&
  122.       !FindQuote or !FindLewd searches Quotes / LewdQuotes for a word or phrase. !qotd for DailyQuote. !AddQuote / !AddLewd to add a quote ^_^ | halt
  123.   }    
  124.  
  125.  
  126.   ;-----------------------------------------------------------------------;
  127.   ; !QSEARCH !FINDQUOTE !QUOTEFIND !QFIND SEARCH THE QUOTE FILE BY TERM   ;
  128.   ;  This Is the Quote Search By Phrase Function and its various aliases  ;
  129.   ;-----------------------------------------------------------------------;
  130.  
  131.   if ($1 = !qsearch || $1 = !findquote || $1 = !quotefind || $1 = !qfind || $1 = !searchquote || $1 = !searchquotes) {
  132.     if ($ulevel < 7) {
  133.       if ($($fcheck($right($1, -1)),2)) { msg # You must wait $duration($v1) before you can use that again. | halt }
  134.     }
  135.     $fcheck($right($1, -1)).add
  136.     if (!$2) { msg # Syntax: $+ $1 [term] | halt }
  137.     var %i 1 | while ($read(%file,n,%i)) {
  138.       if ($2 = -a) {
  139.         if (!$3) { msg # Syntax: $+ $1-2 [author] | halt }
  140.         var %author $gettok($read(%file,n,%i),1,2)
  141.         if ($3- $+ : = $strip(%author,b)) var %qsearch $addtok(%qsearch,%i,32)
  142.       }
  143.       elseif ($2- isin $read(%file,n,%i)) var %qsearch $addtok(%qsearch,%i,32)
  144.       inc %i
  145.     }
  146.  
  147.     if (!%qsearch) msg # There aren't any quotes matching $+($iif($2 = -a,$3-,$2),.)
  148.     else msg # The following Quote #'s contain $+($iif($2 = -a,$3-,$2-), : %qsearch)
  149.   }
  150.  
  151.   if ($1 = !aquote && $regex($2,/^o(|n|ff)$/Si) && $nick isin %owner) {
  152.     if (!%aMins) { msg # You have first to set the duration of aQuote. | msg # Syntax: !aTime [mins] | halt }
  153.     if ($regml(1) = n) { msg # aQuote has been activated. | timerAQuote 0 %aMins msg # Auto Quote: $!read( %file , n) }
  154.     elseif ($timer(AQuote)) { timerAQuote $2 | msg # $+ aQuote has been turned off. }
  155.   }
  156.  
  157.   ;-------------------------------------------------------------------------------;
  158.   ;   !TOTALQUOTES - ANYONE CAN SEND A LIST OF TOTAL LINES IN THE QUOTE FILE      ;
  159.   ;-------------------------------------------------------------------------------;
  160.  
  161.   if ($1 = !TotalQuotes) msg # There are %x quotes of memorable moments collected so far. Used that !addquote to add to the collection.
  162.   ;-----------------------------------------;
  163.   ;   SET THE COOL DOWN TIMER VIA CHAT      ;
  164.   ;-----------------------------------------;
  165.  
  166.   if ($regex($1,/^!(a|f)time$/Si) && $nick isin %owner) {
  167.     if ($2 isnum && $2 >= 0) {
  168.       set $+(%,$regml(1),Mins $calc($int($2) * 60 + $gettok($2,2,46)))
  169.       msg # Set the cooldown timer to $iif($regml(1) = a,aQuote) $2 minutes.
  170.     }
  171.   }
  172.   ;------------------------;
  173.   ;  FLOOD CHECK STUFF     ;
  174.   ;------------------------;
  175.  
  176.   if ($1 = !fcheck && $regex($2,/^o(|n|ff)$/Si) && $nick isin %owner) {
  177.     if (!%fMins) { msg # You have first to set the duration of fTime. | msg # Syntax: !fTime [mins] | halt }
  178.     $iif($regml(1) = n,en,dis) $+ able #fcheck
  179.     msg # Floodcheck has been $iif($v1 = $v2,en,dis) $+ abled.
  180.   }
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement