• Home
  • Servers
  • Chat
  • Channels
  • Commands
  • Forum
  • FAQ
  • Software
  • Quotes
Topic Options
Rate This Topic
#4537 - 03/14/09 01:14 AM !Fact Random Fact Script. Get Smarter :)
FordLawnmower Offline
Over 100 posts

Registered: 02/15/09
Posts: 111
Loc: Ohio
Pretty simple script. Gets a random fact from CoolQuiz. This type of script is good for killing boredom of stimulating conversation.
Usage:Copy to clipboard, Paste to new remote, Save with a unique filename.
Or:Download the attachment. Extract to your mirc directory. Type /load -rs Fact.mrc
**note** If you don't know where your mirc directory is type //echo -a $mircdir
Code:
;***
;***
;Simple fact Script by Ford_Lawnmower
;This is a simple script gets a random new fact from coolquiz.com
;***
;***
alias fact.factout {
  if (%fact.chan == ECHO) {
    echo -at >error< >connection timed out<
  }
  else {
    .msg %fact.chan Sorry %fact.nick the connection was timed out... Please try again... :(
  }  
  fact.clear
}
alias fact.clear {
  unset %fact*
  sockclose fact
  .timer-fact off
  halt
}
#fact.trigger on
on *:TEXT:!fact:#: {
  if (%fact.inuse == 1) { .notice $nick Sorry, But Somebody else is already looking up a a fact. Please try again. | halt }
  set %fact.inuse 1
  set %fact.nick $nick
  set %fact.chan $chan
  sockclose fact
  set %facturl /trivia/facts/
  set %factsite www.coolquiz.com
  sockopen fact %factsite 80
  .msg $chan 4 $chan 5fact Search... 7Searching for4 Your fact 3Please Wait.....
  .timer-fact 1 15 fact.factout
}
#fact.trigger end
alias fact {
  if (%fact.inuse == 1) { echo -at >error in use< | fact.clear }
  set %fact.inuse 1
  set %fact.nick $me
  set %fact.chan ECHO
  sockclose fact
  set %facturl /trivia/facts/
  set %factsite www.coolquiz.com
  sockopen fact %factsite 80
  .timer-fact 1 15 fact.factout
}
on *:sockopen:fact: {
  sockwrite -n $sockname GET %facturl HTTP/1.1
  sockwrite -n $sockname Host: %factsite $+ $CRLF $+ $CRLF
}
on *:sockread:fact: {
  if ($sockerr > 0) { .notice %fact.nick There has been an error... We could not retrive your Fact. Sorry | fact.clear }
  else {
    var %factvar |  sockread %factvar
    if (<p> && </p> isin %factvar) && (Advanced Search &raquo !isin %factvar) {
      if ($len(%factvar) >= 400) {
        var %fact.output1 = $left($httpstrip(%factvar),400) $+ -
        var %fact.offset = $calc($len($httpstrip(%factvar)) - 400)
        var %fact.output2 = $right($httpstrip(%factvar),%fact.offset)
        if (%fact.chan == ECHO) {
          echo -at 4 Your random fact is **--  6 $replace(%fact.output1,</b>,4---**7)
          echo -at 4**--  6 $replace(%fact.output2,</b>,4---**7)
        }
        else {
          .msg %fact.chan %fact.offset
          .msg %fact.chan 4 Your random fact is **--  6 $replace(%fact.output1,</b>,4---**7)
          .msg %fact.chan 4**--  6 $replace(%fact.output2,</b>,4---**7)        
        }
      }
      else {
        if (%fact.chan == ECHO) {
          echo -at 4 Your random fact is **--  6 $httpstrip($replace(%factvar,</b>,4---**7))
        }
        else {
          .msg %fact.chan 4 Your random fact is **--  6 $httpstrip($replace(%factvar,</b>,4---**7))
        }  
      }
      sockread %factvar
      fact.clear
    }
  }
}
menu channel {
  .CoolQuiz
  ..Fact Trigger On:.enable #fact.trigger
  ..Fact Trigger Off:.disable #fact.trigger
}
alias -l httpstrip {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;,$chr(9))
  return %x
}


Attachments
Fact.rar (20 downloads)
Description: Fact Script by Ford_Lawnmower


_________________________
If you already know everything, You can never learn anything :P

Top
Sponsored Links
Sponsored Links
Member
*****

Registered: 27/08/04
Posts: 10136
Loc: Mountain View, CA
Top


Moderator:  Jeff, mandy, usrbingeek