Posted to tcl by hypnotoad at Sat May 05 02:04:35 GMT 2018view raw

  1. ##############################################################################################
  2. ## To use this script you must set channel flag +trivia (ie .chanset #chan +trivia) ##
  3. ##############################################################################################
  4. ##############################################################################################
  5. ## ## Start Setup. ## ##
  6. ##############################################################################################
  7. ## Change trivia_cmdchar to the character you want to use. ##
  8. set trivia_cmdchar "!"
  9. proc trivia {nick host hand chan args} {
  10. if {[lsearch -exact [channel info $chan] +trivia] != -1} {
  11. ## Change the characters between the "" below to change the logo shown with each result. ##
  12. set trivialogo "\002\00301,11-Trivia-\002\003"
  13. ## Change the format codes between the "" below to change the color/state of the text. ##
  14. set textf "\0034"
  15. ##############################################################################################
  16. ## ## End Setup. ## ##
  17. ##############################################################################################
  18. set triviasite "www.etoyoc.com"
  19. set triviaurl "/trivia/text"
  20. if {[catch {set triviaSock [socket -async $triviasite 80]} sockerr]} {
  21. putserv "PRIVMSG $chan :$triviasite $triviaurl $sockerr error"
  22. return 0
  23. } else {
  24. puts $triviaSock "GET $triviaurl HTTP/1.0"
  25. puts $triviaSock "Host: $triviasite"
  26. puts $triviaSock ""
  27. flush $triviaSock
  28. # Trivia is only ever one line
  29. set fact [gets $triviaSock]
  30. putserv "PRIVMSG $chan :${textf}[$fact] ${trivialogo}"
  31. return 0
  32. }
  33. }
  34. }
  35. proc triviastrip {string} {
  36. regsub -all {<[^<>]+>} $string "" string
  37. return $string
  38. }
  39. proc triviadehex {string} {
  40. regsub -all {[\[\]]} $string "" string
  41. set string [subst [regsub -nocase -all {\&#([0-9]{2});} $string {[format %c \1]}]]
  42. return [string map {&quot; \"} $string]
  43. }
  44. bind pub - [string trimleft $trivia_cmdchar]trivia trivia
  45. setudef flag trivia
  46. putlog "\002*Loaded* \002\00301,11-Trivia-\002\003 \002Random by Sean Woods, stolen from Ford_Lawnmower irc.GeekShed.net #Script-Help"