Welcome to the first release of JoTrivia, "not just another mIRC trivia bot" (remind me to fire my PR guy). I'll call this version 1.0, but I don't think there will be any more versions unless I get a wealth of bug reports and feel guilty enough about it to fix them. As with all the code I write, this bot is complete freeware. Feel free to steal my ideas, cut and paste my code, or bastardize my code and pretend you wrote it. This is my first published mIRC script, and as such my code is most likely severely un-optimized, but so far as I can tell it is functional and bug free.

Jotrivia is a fairly simple trivia bot, most closely resembling the bot Jigglypuf uses on Undernet's #chat_central, with some cool features I didn't see in similar bots including:

Private hint mode - There are two hint modes in JoTrivia: public and private. Public hint is the typical way trivia bots respond to the !hint command - three letters of the answer are populated and the results are displayed in the channel window for all to see. When private hint mode is turned on, each user that types !hint gets /noticed a message containing three characters of the answer populated. Also each user gets /noticed a new answer (e.g. _a_gman _s _a fun _am_.) showing how many letters in his/her answer attempt matched the real answer.

Flexible !top command - most trivia bots have a !top5 or a !top10 command in them that private messages the user who types it a list of the current top winners and their scores. Change a single variable (%topcount) to change how many scores are recorded. Any command issued that starts with !top will kick off the command (i.e. !top, !top5, and !top10 would all display the same results).

%botop - Simple and useful. If you want to run two copies of mIRC so you can play against other users, set the %botop variable to the nickname that you want to be the bot. That way you will avoid having both mIRC copies trying to run the bot at the same time. The script checks the $me variable to make sure it matches %botop before responding to "on TEXT" commands.

Setup
-----

Import the script into mIRC, then issue the command "/init" to initialize the game. You will be asked three questions, and then all the necessary variables will be populated and you can begin running the bot in a channel. The three questions are:

1 - What channel will the bot be run in? (Don't forget the #)

2 - What percentage chance do you want for switching public and private hint modes between questions? (Just enter a number between 1 and 100 without the % sign - I don't do any checks for mistakes, so do it right or weird things might happen.)

3 - How many top scorers do you want to list with !top command? Enter a number between 1 and ????. I haven't tested the upper limits of this, but not only will you be more likely to be booted for flooding a server if it's set to 10,000, the scoring sorter will run much slower and will greatly increase the time between questions. Also, in the unlikely event you don't get booted, you can expect the recipient of your 10,000 top scorers, most of which are "Nobody" with a score of 0, to be very VERY mad. I suppose that has it's place, but as a rule I recommend against it. 5 to 10 seems to be the correct range. You'd want to go higher if hundreds of competitive people were playing in the same channel all the time - a fairly unlikely occurrence.

Question file, file format - The question file looked for is q.txt. Included is a sample q.txt with 1100 questions I pulled from various places. The format looked for by the bot is:
 - First line of the file is a number representing the number of questions
 - Each line is in the format "question|answer".

Most bots use * as a separator, but less often will you need a pipe in the actual text of a question than an asterisk, so I chose a pipe as a separator instead. Lines that aren't in the right format will be logged to corrupt.txt when the bot picks those questions. You can manually check all the questions (slower as the number of questions goes up) with the "/checkcorrupt" command.


Private/Public hint stuff - When prompted for the hint mode switching chance, I usually say 30 - Often enough that most users will see both of them, but infrequent enough to let users get used to the advantages and disadvantages of both methods. The setting can be 100 to switch after every question, or the operator can force one mode to be always on by setting the chance to 0, then setting the %nickspecific variable to on or off.

General use - Here is what the bot says when !help is issued:

  !trivon activates trivia bot if it is not already running
  !hint displays a three letter hint to the channel if bot is in public hint mode,
  or as a /notice to you if bot is in private hint mode
  !won will display the number of questions you've answered correctly
  !won (nick) will display other users' winnings
  !repeat will redisplay the current question
  !top shows the top scorers as a private message
  To answer a question, simply type the answer in the channel window
  Answers are not case sensitive
  JoTweak can be reached at jdown@columbus.rr.com for comments, flames, and questions.

What it doesn't say is how to turn it off. The !trivoff command turns the bot off after the current question has been answered, and the operator can use /trivoff to immediately shut the bot down. If 10 questions in a row go unanswered, the bot will automatically shut down.

That should be enough to get you started. Remember mIRC won't grep text coming from $me, so to play or test changes, you need to spawn a new copy of mIRC and use a different nick. If you're going to build a huge collection of questions, I recommend doing it with discretion and slowly. A lot of prefab question files have some incorrect answers, misspellings, and some questions of the "what is 2 + 2" and "what color is blue" variety. Including a few of those in the mix is sometimes unavoidable, but too many of them will chase away users.

Lastly, a file "usednums.txt" is created to monitor what questions have been asked. No question will be asked twice until all the questions have been asked. If you end up with a question file of 50,000 questions and the bot at some point starts taking 5 times as long between questions, delete usednums.txt and that should speed things up again.

Enjoy! Comments, etc. welcome.
JoTweak