Coders-IRC


IRC for Coders

BRAIN BLASTER TRIVIA BOT


image

 🎯 BRAIN BLASTER TRIVIA BOT - Next Generation Trivia Experience            
 🚀 Modern Design, Unique Commands, Awesome Features By:Chain                        

; 🔥 CONFIGURATION SECTION
alias -l trivia.version return BrainBlaster v2.0
alias -l trivia.prefix return 🧠 
alias -l trivia.file trivia_questions.txt
alias -l trivia.scores trivia_scores.dat
alias -l trivia.settings trivia_config.dat

; 🎮 GAME VARIABLES
alias -l trivia.reset {
  unset %trivia.active
  unset %trivia.current.question
  unset %trivia.current.answer
  unset %trivia.current.category
  unset %trivia.question.number
  unset %trivia.question.total
  unset %trivia.hint.level
  unset %trivia.answer.time
  unset %trivia.streak.*
  unset %trivia.temp.*
}

; 🌟 INITIALIZATION
on *:START:{
  echo -ag $trivia.prefix 4,1▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  echo -ag $trivia.prefix 0,4 BRAIN BLASTER TRIVIA BOT LOADED! 4,1
  echo -ag $trivia.prefix 4,1▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  
  ; Create default question file if it doesn't exist
  if (!$isfile($trivia.file)) {
    write $trivia.file Science|What is the chemical symbol for gold?|Au
    write $trivia.file Science|What planet is known as the Red Planet?|Mars
    write $trivia.file Science|How many bones are in the human body?|206
    write $trivia.file Geography|What is the capital of Japan?|Tokyo
    write $trivia.file Geography|Which is the largest ocean?|Pacific
    write $trivia.file History|In which year did World War II end?|1945
    write $trivia.file Entertainment|Who directed the movie Inception?|Christopher Nolan
    write $trivia.file Sports|How many players are on a basketball team?|5
    write $trivia.file Technology|What does CPU stand for?|Central Processing Unit
    write $trivia.file Random|What is the largest mammal?|Blue Whale
  }
}

; 🎯 CORE COMMANDS
on *:TEXT:*:#:{
  ; Convert to lowercase for command checking
  var %cmd = $strip($1-)
  
  ; 🔥 START TRIVIA - New command style
  if (%cmd == !blast || %cmd == !brainblast || %cmd == !startrivia) {
    trivia.start $chan $nick $2-
    halt
  }
  
  ; 🛑 STOP TRIVIA - Cool new command
  if (%cmd == !stopblast || %cmd == !brainfreeze || %cmd == !endtrivia) {
    trivia.stop $chan $nick
    halt
  }
  
  ; 📊 STATS - Modern stats display
  if (%cmd == !brainpower || %cmd == !mystats || %cmd == !mybrain) {
    trivia.stats $chan $nick
    halt
  }
  
  ; 🏆 LEADERBOARD - Awesome leaderboard
  if (%cmd == !brainiacs || %cmd == !topbrains || %cmd == !elites) {
    trivia.leaderboard $chan
    halt
  }
  
  ; 🎯 SKIP QUESTION - New skip command
  if (%cmd == !nextbrain || %cmd == !skipblast || %cmd == !pass) {
    trivia.skip $chan $nick
    halt
  }
  
  ; 💡 HINT SYSTEM - Smart hints
  if (%cmd == !brainhint || %cmd == !hintme || %cmd == !helpme) {
    trivia.hint $chan $nick
    halt
  }
  
  ; 🎮 CATEGORIES - Category selection
  if (%cmd == !braincats || %cmd == !categories || %cmd == !topics) {
    trivia.categories $chan
    halt
  }
  
  ; 🎲 RANDOM TRIVIA FACT - Fun facts
  if (%cmd == !brainfact || %cmd == !trivianugget || %cmd == !factoid) {
    trivia.fact $chan
    halt
  }
  
  ; 🎯 ANSWER PROCESSING - Check for answers
  if (%trivia.active == $chan) {
    trivia.check.answer $chan $nick $strip($1-)
  }
}

; 🚀 START TRIVIA FUNCTION
alias -l trivia.start {
  var %chan = $1
  var %nick = $2
  var %questions = $3
  
  ; Check if trivia is already running
  if (%trivia.active) {
    msg %chan $trivia.prefix 4⚠️ Brain Blast already active! Use !stopblast to end it.
    return
  }
  
  ; Validate number of questions
  if (%questions == $null) %questions = 10
  if (%questions !isnum 1-50) %questions = 10
  
  ; Initialize game
  set %trivia.active %chan
  set %trivia.question.total %questions
  set %trivia.question.number 0
  set %trivia.hint.level 0
  set %trivia.start.time $ctime
  
  ; Welcome message with style
  msg %chan 4,1 $+ $str(▓,60)
  msg %chan 0,4 $trivia.prefix 🧠 BRAIN BLASTER TRIVIA ACTIVATED! 
  msg %chan 14Questions: %questions | Category: Mixed | Time Limit: 45 seconds per question
  msg %chan 4,1 $+ $str(▓,60)
  
  ; Start first question
  .timer.trivia.next 1 3 trivia.next.question %chan
}

; 🎯 NEXT QUESTION FUNCTION
alias -l trivia.next.question {
  var %chan = $1
  
  ; Check if game should end
  if (%trivia.question.number >= %trivia.question.total) {
    trivia.end.game %chan
    return
  }
  
  ; Increment question counter
  inc %trivia.question.number
  set %trivia.hint.level 0
  set %trivia.answer.time $ctime
  
  ; Select random question from file
  var %total.lines $lines($trivia.file)
  var %random.line $rand(1,%total.lines)
  var %question.data $read($trivia.file, %random.line)
  
  ; Parse question data
  var %category $gettok(%question.data,1,124)
  var %question $gettok(%question.data,2,124)
  var %answer $gettok(%question.data,3,124)
  
  ; Store current question
  set %trivia.current.category %category
  set %trivia.current.question %question
  set %trivia.current.answer %answer
  
  ; Display question with awesome formatting
  msg %chan 12 $+ $str(═,50)
  msg %chan 0,12 $trivia.prefix Question #%trivia.question.number of %trivia.question.total
  msg %chan 14📚 Category: %category
  msg %chan 0 $+ $str(─,40)
  msg %chan 3 $+ %question
  msg %chan 12 $+ $str(═,50)
  
  ; Start timers for hints and timeout
  .timer.trivia.hint.1 1 15 trivia.show.hint %chan 1
  .timer.trivia.hint.2 1 30 trivia.show.hint %chan 2
  .timer.trivia.timeout 1 45 trivia.timeout %chan
}

; 🧠 ANSWER CHECKING
alias -l trivia.check.answer {
  var %chan = $1
  var %nick = $2
  var %answer = $3-
  
  ; Check if answer is correct (case insensitive)
  if ($strip(%answer) == $strip(%trivia.current.answer)) {
    ; Calculate points based on speed
    var %time.taken $calc($ctime - %trivia.answer.time)
    var %base.points 10
    var %speed.bonus $calc(20 - %time.taken)
    if (%speed.bonus < 0) %speed.bonus = 0
    var %total.points $calc(%base.points + %speed.bonus)
    
    ; Update streak
    if (%trivia.streak.nick == %nick) {
      inc %trivia.streak.count
      var %streak.bonus $calc(%trivia.streak.count * 2)
      inc %total.points %streak.bonus
    } else {
      set %trivia.streak.nick %nick
      set %trivia.streak.count 1
    }
    
    ; Update player score
    var %current.score $read($trivia.scores, nw, %nick)
    if (%current.score == $null) %current.score = 0
    var %new.score $calc(%current.score + %total.points)
    write -ds $trivia.scores %nick
    write $trivia.scores %nick %new.score
    
    ; Display win message with style
    msg %chan 4,1 $+ $str(★,40)
    msg %chan 0,4 $trivia.prefix 🏆 BRAIN BLAST! %nick got it right! 
    msg %chan 14Answer: %trivia.current.answer | Points: %total.points | Time: %time.taken seconds | Streak: %trivia.streak.count
    msg %chan 4,1 $+ $str(★,40)
    
    ; Clear timers and move to next question
    .timer.trivia.hint.* off
    .timer.trivia.timeout off
    .timer.trivia.next 1 5 trivia.next.question %chan
  }
}

; 💡 HINT SYSTEM
alias -l trivia.show.hint {
  var %chan = $1
  var %level = $2
  var %answer %trivia.current.answer
  var %hint
  
  if (%level == 1) {
    ; First hint - show first letter and length
    var %first.letter $left(%answer,1)
    var %length $len(%answer)
    var %spaces $count(%answer,$chr(32))
    %hint = First letter: %first.letter $+ , Length: %length characters
    if (%spaces > 0) %hint = %hint $+ , Spaces: %spaces
  } elseif (%level == 2) {
    ; Second hint - show more letters
    var %visible $left(%answer, $calc($len(%answer) // 2))
    var %hidden $str(•, $calc($len(%answer) - $len(%visible)))
    %hint = Partial answer: %visible $+ %hidden
  }
  
  if (%hint) {
    msg %chan 8💡 HINT: %hint
  }
}

; ⏰ TIMEOUT FUNCTION
alias -l trivia.timeout {
  var %chan = $1
  
  msg %chan 4 $+ $str(⏰,30)
  msg %chan 14Time's up! The answer was: %trivia.current.answer
  msg %chan 4 $+ $str(⏰,30)
  
  ; Reset streak
  set %trivia.streak.nick $null
  set %trivia.streak.count 0
  
  ; Move to next question
  .timer.trivia.next 1 5 trivia.next.question %chan
}

; 🏁 END GAME FUNCTION
alias -l trivia.end.game {
  var %chan = $1
  var %duration $duration($calc($ctime - %trivia.start.time))
  
  ; Get winner
  var %winner $trivia.get.winner(%chan)
  var %winner.score $read($trivia.scores, nw, %winner)
  
  ; Final results
  msg %chan 4,1 $+ $str(█,50)
  msg %chan 0,4 $trivia.prefix 🏆 BRAIN BLASTER COMPLETE! 🏆
  msg %chan 14Duration: %duration | Questions: %trivia.question.total
  if (%winner != $null) {
    msg %chan 3👑 Champion: %winner with %winner.score points!
  }
  msg %chan 4,1 $+ $str(█,50)
  
  ; Reset game
  trivia.reset
}

; 🛑 STOP TRIVIA FUNCTION
alias -l trivia.stop {
  var %chan = $1
  var %nick = $2
  
  if (!%trivia.active) {
    msg %chan $trivia.prefix 4No active Brain Blast to stop!
    return
  }
  
  if (%trivia.active != %chan) {
    msg %chan $trivia.prefix 4Brain Blast is running in %trivia.active
    return
  }
  
  ; Clear all timers
  .timer.trivia.* off
  
  msg %chan 8,1 $+ $str(■,40)
  msg %chan 0,8 $trivia.prefix ❄️ BRAIN BLAST FROZEN BY %nick! 
  msg %chan 8,1 $+ $str(■,40)
  
  trivia.reset
}

; 📊 STATS FUNCTION
alias -l trivia.stats {
  var %chan = $1
  var %nick = $2
  var %score $read($trivia.scores, nw, %nick)
  
  if (%score == $null) %score = 0
  
  ; Get games played
  var %games $read($trivia.settings, nw, games_ $+ %nick)
  if (%games == $null) %games = 0
  
  ; Get current streak if active
  var %current.streak 0
  if (%trivia.streak.nick == %nick) %current.streak = %trivia.streak.count
  
  msg %chan 12 $+ $str(═,40)
  msg %chan 0,12 $trivia.prefix 🧠 %nick's Brain Power Stats
  msg %chan 14Total Score: %score points
  msg %chan 14Games Played: %games
  msg %chan 14Current Streak: %current.streak
  msg %chan 12 $+ $str(═,40)
}

; 🏆 LEADERBOARD FUNCTION
alias -l trivia.leaderboard {
  var %chan = $1
  var %top.list $trivia.get.top.players(5)
  
  msg %chan 4,1 $+ $str(★,45)
  msg %chan 0,4 $trivia.prefix 🏆 TOP BRAINIACS 🏆
  
  var %rank 1
  var %i 1
  while ($gettok(%top.list,%i,44) != $null) {
    var %player.data $gettok(%top.list,%i,44)
    var %player $gettok(%player.data,1,58)
    var %score $gettok(%player.data,2,58)
    msg %chan 14 $+ %rank $+ . %player - %score points
    inc %i
    inc %rank
  }
  
  msg %chan 4,1 $+ $str(★,45)
}

; 🎯 SKIP QUESTION FUNCTION
alias -l trivia.skip {
  var %chan = $1
  var %nick = $2
  
  if (!%trivia.active) {
    msg %chan $trivia.prefix 4No active Brain Blast to skip!
    return
  }
  
  if (%trivia.active != %chan) {
    msg %chan $trivia.prefix 4Brain Blast is running in %trivia.active
    return
  }
  
  ; Vote system for skipping
  if (%trivia.skip.votes == $null) set %trivia.skip.votes %nick
  else {
    if ($istok(%trivia.skip.votes,%nick,32)) {
      msg %chan $trivia.prefix %nick already voted to skip!
      return
    }
    set %trivia.skip.votes %trivia.skip.votes %nick
  }
  
  var %total.votes $numtok(%trivia.skip.votes,32)
  var %needed.votes 2
  
  msg %chan 8📋 %nick voted to skip! (%total.votes/%needed.votes votes needed)
  
  if (%total.votes >= %needed.votes) {
    msg %chan 8⏭️ Question skipped! Moving to next brain buster...
    .timer.trivia.hint.* off
    .timer.trivia.timeout off
    .timer.trivia.next 1 3 trivia.next.question %chan
    unset %trivia.skip.votes
  }
}

; 💡 HINT REQUEST FUNCTION
alias -l trivia.hint {
  var %chan = $1
  var %nick = $2
  
  if (!%trivia.active) {
    msg %chan $trivia.prefix 4No active Brain Blast for hints!
    return
  }
  
  if (%trivia.active != %chan) {
    msg %chan $trivia.prefix 4Brain Blast is running in %trivia.active
    return
  }
  
  ; Provide hint based on current level
  if (%trivia.hint.level == 0) {
    trivia.show.hint %chan 1
    set %trivia.hint.level 1
  } elseif (%trivia.hint.level == 1) {
    trivia.show.hint %chan 2
    set %trivia.hint.level 2
  } else {
    msg %chan $trivia.prefix 8No more hints available! Use your brain power! 🧠
  }
}

; 📚 CATEGORIES FUNCTION
alias -l trivia.categories {
  var %chan = $1
  
  ; Read all categories from question file
  var %categories $trivia.get.categories()
  
  msg %chan 11 $+ $str(─,40)
  msg %chan 0,11 $trivia.prefix 📚 Available Brain Categories
  msg %chan 14%categories
  msg %chan 11 $+ $str(─,40)
}

; 🎲 RANDOM FACT FUNCTION
alias -l trivia.fact {
  var %chan = $1
  
  var %facts = Did you know? The human brain uses 20% of the body's energy!|Amazing fact: Octopuses have three hearts!|Fun fact: Bananas are berries, but strawberries aren't!|Weird fact: A group of flamingos is called a "flamboyance"!|Cool fact: The shortest war in history lasted 38 minutes!|Mind blown: There are more possible iterations of a game of chess than there are atoms in the known universe!
  
  var %random.fact $gettok(%facts,$rand(1,$numtok(%facts,124)),124)
  msg %chan 13💡 BRAIN NUGGET: %random.fact
}

; 🛠️ UTILITY FUNCTIONS
alias -l trivia.get.winner {
  var %chan = $1
  var %highest.score 0
  var %winner $null
  
  ; This would need to track scores per game session
  ; For now, return the player with highest overall score
  var %i 1
  while ($read($trivia.scores, %i) != $null) {
    var %line $read($trivia.scores, %i)
    var %player $gettok(%line,1,32)
    var %score $gettok(%line,2,32)
    if (%score > %highest.score) {
      set %highest.score %score
      set %winner %player
    }
    inc %i
  }
  
  return %winner
}

alias -l trivia.get.top.players {
  var %count = $1
  if (%count == $null) %count = 5
  
  ; Simple bubble sort to get top players
  var %scores $null
  var %i 1
  while ($read($trivia.scores, %i) != $null) {
    var %line $read($trivia.scores, %i)
    var %player $gettok(%line,1,32)
    var %score $gettok(%line,2,32)
    %scores = %scores $+ %player $+ : $+ %score $+ $chr(44)
    inc %i
  }
  
  ; Sort and return top %count
  return $gettok(%scores,1- $+ %count,44)
}

alias -l trivia.get.categories {
  var %categories $null
  var %seen $null
  
  var %i 1
  while ($read($trivia.file, %i) != $null) {
    var %line $read($trivia.file, %i)
    var %category $gettok(%line,1,124)
    if (!$istok(%seen,%category,44)) {
      %seen = %seen %category
      if (%categories == $null) %categories = %category
      else %categories = %categories $+ , %category
    }
    inc %i
  }
  
  return %categories
}

; 🎯 HELP SYSTEM
on *:TEXT:!brainhelp:#:{
  msg $chan 4,1 $+ $str(▓,60)
  msg $chan 0,4 $trivia.prefix 🧠 BRAIN BLASTER COMMANDS
  msg $chan 14!blast - Start Brain Blast Trivia
  msg $chan 14!stopblast - Stop current game
  msg $chan 14!brainpower - Your stats
  msg $chan 14!brainiacs - Top players
  msg $chan 14!nextbrain - Skip question
  msg $chan 14!brainhint - Get a hint
  msg $chan 14!braincats - Show categories
  msg $chan 14!brainfact - Random trivia fact
  msg $chan 14!brainhelp - This help
  msg $chan 4,1 $+ $str(▓,60)
}

; 🔒 CLEANUP ON DISCONNECT
on *:DISCONNECT:{
  if (%trivia.active) {
    .timer.trivia.* off
    trivia.reset
  }
}
🎯 FEATURES OF THIS AWESOME TRIVIA BOT:

🔥 Unique Commands:

  • !blast or !brainblast - Start trivia (way cooler than !trivia!)
  • !stopblast or !brainfreeze - Stop trivia
  • !brainpower - Your personal stats
  • !brainiacs - Top players leaderboard
  • !nextbrain - Skip current question
  • !brainhint - Get smart hints
  • !braincats - Show available categories
  • !brainfact - Random trivia facts

🌟 Awesome Features:

  • Modern Design - Colorful, eye-catching messages with borders
  • Smart Scoring - Points based on speed + streak bonuses
  • Hint System - Progressive hints (first letter, then partial reveal)
  • Vote Skipping - Players can vote to skip questions
  • Streak Tracking - Consecutive correct answers give bonus points
  • Category Support - Questions organized by category
  • Random Facts - Fun trivia nuggets between games
  • Timeout System - 45 seconds per question
  • Statistics Tracking - Persistent player scores

🎮 Game Flow:

  1. Start with !blast [number] (default 10 questions)
  2. Answer questions by just typing in channel
  3. Get hints with !brainhint
  4. Skip questions with !nextbrain (requires votes)
  5. Check stats with !brainpower
  6. View leaderboard with !brainiacs

💡 Installation:

  1. Copy the entire script into a new .mrc file
  2. Load it in mIRC (/load -rs yourfile.mrc)
  3. It creates a default question file automatically
  4. Add more questions using format: Category|Question|Answer
This is completely different from traditional trivia bots - it's got personality, modern styling, and unique commands that will make your channel stand out! The "Brain Blast" theme makes it feel fresh and exciting compared to boring old trivia bots.



Comments 0