zQuote

By zfg2000 on Jan 28, 2006

zQuote is a quote database made for bots.
Use .Quote to view a random quote
Use .Quote number to view the the quote you want
Use .Quote words to search the quote file for that word and prints a random line with that word in it
Use .findquote string to find all of the quotes with the string in them
Use .lastquote to view the newest added quote
Use .addquote to add a quote
Use .delquote to delete a quote

on *:TEXT:.quote*:#:{
  if !$read(quotes.txt, n, 1) { .msg $chan zQuote currently does not have any quotes. Maybe you should add some. }
  else {
    if !$2 { .msg $chan zQuote Random Quote: $read(quotes.txt, n) }
    else {
      if $2 isnum {
        if !$read(quotes.txt, n, $2) { .msg $chan zQuote number $2 does not exist! There are only $lines(quotes.txt) quotes in the database. }
        else {
          .msg $chan zQuote Number $2 $+ : $read(quotes.txt, n, $2)
        }
      }
      else {
        set %s * $+ $2- $+ *
        set %r $null
        set %i 1
        while %i <= $lines(quotes.txt) {
          if %s iswm $read(quotes.txt, n, %i) {
            %r = %r $+ $chr(32) $+ %i
          }
          inc %i
        }
        if $numtok(%r,32) == 0 { .msg $chan There are not any quotes found using those words. Try diffrent words for your search. | halt }
        set %q $gettok(%r,$rand(1,$numtok(%r,32)),32)
        .msg $chan zQuote Random quote for %s $+ : $read(quotes.txt, n, %q)
      }  
    }
  }
}
on *:TEXT:.findquote*:#:{
  set %s * $+ $2- $+ *
  set %r $null
  set %i 1
  while %i <= $lines(quotes.txt) {
    if %s iswm $read(quotes.txt, n, %i) {
      %r = %r $+ $chr(32) $+ %i
    }
    inc %i
  }
  if $numtok(%r,32) == 0 { .msg $chan There are not any quotes found using those words. Try diffrent words for your search. | halt }
  .msg $chan zQuote Quotes found for %s $+ : %r
}
on *:TEXT:.lastquote:#:{ .msg $chan zQuote Last Quote: $read(quotes.txt, n, $lines(quotes.txt)) }
on 3:TEXT:.addquote*:#:{
  .write quotes.txt $2-
  .msg $chan $nick $+ , The quote has been added!
}
on 3:TEXT:.delquote*:#:{
  .write -dl $+ $2 quotes.txt 
  .msg $chan $nick $+ , The quote has been deleted!
}

Comments

Sign in to comment.
zfg2000   -  Jan 28, 2006

Thanks... Edited

 Respond  
Hyper   -  Jan 28, 2006

hm, time to go edit my own quote script... :-\

 Respond  
noMen   -  Jan 28, 2006

If the n switch is specified then the line read in will not be evaluated and will be treated as plain text.

 Respond  
Hyper   -  Jan 28, 2006

noMen, I don\'t see anything about the ,n parameter in $read help. What is it?

Oh, btw zfg, I recommend using var instead of set. :)

 Respond  
noMen   -  Jan 28, 2006

I havetested this snippet, it is vulnerable! Add the ,n parameter to all $read statements!!! Use /help $read for more info.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.