mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2016
Posts: 3
E
Self-satisified door
OP Offline
Self-satisified door
E
Joined: May 2016
Posts: 3
Hello! I am making a twitch bot of my own.
So far I've managed to add to it the features I wanted.
But now I would like to add a Trivia feature!
So far I've made a code with timers which cycle questions, events when a correct or wrong answer is given. I think everything is ready, but the way I will store the questions.
I am not sure how to save my questions and their answers. I would like the questions and answer to consist of more than one word.
Any help is much appreciated

Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
Posts: 133
you create the .txt file in your mirc directory (default is under c:\users\uname\AppData\Roaming\mIRC\test.txt) and then you can write and read with these:

Code:
write text.txt $var
$read(text.txt,n,$var)


Now you can manually put them in the text file and just read them in, or if you want to do it mostly from twitch chat you can use the write commands.

Have a look at this one, it's pretty good: https://github.com/crdx/trivia-mrc


twitter @keyeslol
Joined: May 2016
Posts: 3
E
Self-satisified door
OP Offline
Self-satisified door
E
Joined: May 2016
Posts: 3
Thank you.
I forgot to say, that what I dont know how to do is:
make a variable and assign for it the question. And make a variable and assign for it the answer, taken from a file.
And then make sure the question doesn't repeat itself in the current session of trivia

Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
Posts: 133
That depends on how you code it. There are plenty of these scripts already out there. I suggest finding one, using it and based on the code ask your question.

But from a high level, after a question is displayed, you can do:

Code:
set -u0 %trivia.question on


and then when you exit mirc or stop the trivia, make sure you do:

Code:
unset %trivia.question 


Making a question and answer, i've answered in the previous. You can separate them how you want, your code will determine what the separator will be.

In the code i linked to, it will be the following:

Code:
set %trivia.question $gettok(%qa, 1, 42)
set %trivia.answer $gettok(%qa, -1, 42)


and in the question file, it's the question on the left and the answer after the "*"

Example:

Code:
80s Films: "In the Southeast, they say if you want to go to heaven, you have to change planes in Atlanta."*Accidental Tourist


You can literally wipe out the whole questions file and put your own stuff in there, just follow the same format.


twitter @keyeslol
Joined: May 2016
Posts: 3
E
Self-satisified door
OP Offline
Self-satisified door
E
Joined: May 2016
Posts: 3
okay, once I assign %question and %answer and this question is asked, how can I make sure it doesnt get asked again in the same trivia session

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
http://godsnotwheregodsnot.blogspot.com/2015/05/tats-trivia-bot-v37.html

This script adds asked questions to a hash table and checks when choosing a new question.

Code:
alias -l create.question {
  while ($thget(Ask1)) {
    var %qread = $qread($thget(Ask1))
    ask.deleteitem 1
    thset Catq
    if (%qread) return
  }
  var %temp.ask = $trivia.getq
  thset Catq $qcat(%temp.ask)
  hadd Asked $+ $idenn %temp.ask %temp.ask
}
alias -l trivia.getq {
  unset %ask
  while ((!%ask) || ($hget(Asked $+ $idenn, %ask))) {
    var %tempnumqvalue = $numq
    if (%tempnumqvalue == 0) {
      echo Attempted start without any questions to process. Bailing.
      halt
    }
    if ($hget(Asked $+ $idenn,0).item >= %tempnumqvalue) { hdel -w Asked $+ $idenn * }
    var %ask = $rand(1, %tempnumqvalue)
    if (!$qread(%ask)) { hadd Asked $+ $idenn %ask NA }
  }
  thset Asking %ask
  return %ask
}


Link Copied to Clipboard