Author Topic: Quote Script  (Read 3830 times)

DarkStar

  • Full Member
  • ***
  • Posts: 135
  • Scripts for Praise
    • CorpseCorp
Quote Script
« on: October 21, 2006, 10:26:15 PM »
Okay, I just wrote this quote script.

Features:
- When someone types "!quote" it will randomly choose and display a quote.
- When someone types "!quote <category>" It will randomly choose a quote from that category.
- When someone types "!quote <category> #<number>" It will display that specific quote.
- Lets users know if the quote is not found
- When someone types "!quoteinfo <category> #<number>" it will display information for when the quote was added.
-- Will Display Who submitted it, channel Submitted on, server submitted on, time submitted, and date.
- when someone types "!addquote" it gives them the syntax for adding a quote
- when someone types "!addquote <category> #<quote>" It will automatically configure the ini file, the random system, and evreything, basically making it very user friendly.

Heres the code:

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)

if Instr(lcase(Message),"!quote") then
if Instr(lcase(Message),"!quoteinfo") then
else
  if left(lcase(message),6) = "!quote" then
    if lcase(Message) = "!quote" then
      rndnum = Int(Rnd * GetIniFile("quote.ini","control","quotes","0")) + 1
      quote = GetIniFile("quote.ini","master","" & rndnum & "","NA")
      title = "Random Quote"
    end if
    if len(message) > 7 then
      if Instr(lcase(Message),"#") then
        temp1 = Mid(lcase(Message),8)
        temp2 = instr(lcase(Message),"#")
        if temp2 > 0 then
          num = Mid(Message,temp2+1)
          tmp = instr(lcase(temp1),"#")
          tempvar = Mid(Message,8,tmp - 2)
          temp3 = GetIniFile("quote.ini","" & tempvar & "","" & num & "","NA")
          quote = GetIniFile("quote.ini","master","" & temp3 & "","NA")
          temptitle = GetIniFile("quote.ini","control","" & tempvar & "","0")
          title = "" & tempvar & " (" & num & " of " & temptitle & ")"
        end if
      else
      rndnum = Int(Rnd * GetIniFile("quote.ini","control","" & Mid(lcase(Message),8) & "","0")) + 1
      temp1 = GetIniFile("quote.ini","" & Mid(lcase(Message),8) & "","" & rndnum & "","NA")
      quote = GetIniFile("quote.ini","master","" & temp1 & "","NA")
      title = Mid(Lcase(Message),8)
      end if
    end if
    if quote = "NA" then
      SendCommand "/msg " & Channel & " No Entry Found.", ServerNumber
    else
      SendCommand "/msg " & Channel & " " & title & ": " & quote & "", ServerNumber
    end if
  end if
end if
end if

if Instr(lcase(Message),"!quoteinfo") then
  if left(lcase(message),10) = "!quoteinfo" then
    if len(message) > 11 then
      if Instr(lcase(Message),"#") then
        temp1 = Mid(lcase(Message),12)
        temp2 = instr(lcase(Message),"#")
        if temp2 > 0 then
          num = Mid(Message,temp2+1)
          tmp = instr(lcase(temp1),"#")
          tempvar = Mid(Message,12,tmp - 2)
          info = GetIniFile("quoteinfo.ini","" & tempvar & "","" & num & "","No Information Available")
        end if
      else
        info = "Third Paramiter Not Specified, Syntax: !quoteinfo <category> #<number>"
      end if
    else
      if lcase(Message) = "!quoteinfo" then
        info = "This will retrieve information about a quote. Syntax: !quoteinfo <category> #<number>"
      end if
    end if
    SendCommand "/msg " & Channel & " " & info & "", ServerNumber
  end if
end if

if Instr(lcase(Message),"!addquote") then
  if left(lcase(message),9) = "!addquote" then
    if len(message) > 10 then
      if Instr(lcase(Message),"#") then
         temp1 = Mid(lcase(Message),11)
         temp2 = instr(lcase(Message),"#")
        quote = Mid(Message,temp2+1)
         tmp = instr(lcase(temp1),"#")
        category = Mid(Message,11,tmp - 2)
        control = GetIniFile("quote.ini","control","" & category & "","0") + 1
        quotes = GetIniFile("quote.ini","control","quotes","0") + 1
        master = GetIniFile("quote.ini","control","quotes","0") + 1
         ttime = GetIdentifier("$time",ServerNumber)
         tdate = GetIdentifier("$date",ServerNumber)
         tserver = GetIdentifier("$network",ServerNumber)
        info = "This Quote Submitted By: " & Nickname & " On: " & Channel & ", " & tserver & " At: " & ttime & ", " & tdate & "."
   if len(quote) > 1 then
        WriteIniFile "quoteinfo.ini","" & category & "","" & control & "","" & info & ""
        WriteIniFile "quote.ini","control","" & category & "","" & control & ""
        WriteIniFile "quote.ini","" & category & "","" & control & "","" & master & ""
        WriteIniFile "quote.ini","master","" & master & "","" & quote & ""
        WriteIniFile "quote.ini","control","quotes","" & quotes & ""
        SendCommand "/notice " & Nickname & " Quote has been filed as: " & category & " #" & control & ".", ServerNumber
   else
        SendCommand "/notice " & Nickname & " No Quote Specified.", ServerNumber
end if
      end if
    else
      if lcase(Message) = "!addquote" then
        SendCommand "/notice " & Nickname & " Syntax: !addquote <category> #<quote>", ServerNumber
        SendCommand "/notice " & Nickname & " Do Not Include a space between the number sign and <quote>.", ServerNumber
      end if
    end if
  end if
end if

End Sub
This message brought to you by the Wonderful Wizard of Oz.