mIRC Home    About    Download    Register    News    Help

Print Thread
#137259 10/12/05 07:08 PM
Joined: Mar 2005
Posts: 212
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
i actually hate trivia bots
but i have a promotion coming up, and i need to stay on top of 200+little bits of japanese related material

which i've already done but i need to retain it till tueday evening past my exams and anything else i might do

so i figured if i had a trivia bot that asked me the questions i need; you can see where this is going

I really dont know how to approach this, and indeed fear that my abilities are entirely inadequate

any help is welcome

#137260 10/12/05 11:21 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Try here if you are looking for a trivia bot: http://tatarize.com/modules.php?name=Content&pa=showpage&pid=1

-genius_at_work

#137261 11/12/05 12:20 AM
Joined: Mar 2005
Posts: 212
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
thats way way way way way way over my head
im just looking to make something small and having tried to look at that one im betting i wont be able to
none the less something small all it would need is start and stop no scoring or any of that crap
i just cant get my head around a way to have it read the question and assess the answer and all that business

but dont worry about it, just something i wanted to help me study and its looking like more work than it will be worth

#137262 11/12/05 12:26 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Are all of your questions answers in a specific format? Typically, a trivia bot stores the questions in a text file in a format similar to this:
Question text is here?|Answer1|Answer2

If you have or can put your questions into a format like that, it would be very easy to make a simple question ask/answer script.

If you could give an example of the format of the questions, it would be helpful.

-genius_at_work

#137263 11/12/05 12:50 AM
Joined: Mar 2005
Posts: 212
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
yeah i sat down sith a pad and pencil and im starting to get somewhere
it wont be real polished but who cares
i was gonna split the questions and answers into two seperate txt and number them then use $read to have it read whatever line then use $readn to have it read that same line from the answer text to a variable
then making the text comparison to that variable so on and so forth
anyways thanks for helping

#137264 11/12/05 01:16 AM
Joined: Mar 2005
Posts: 212
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
knocked this out its heavily flawed but it does exactly what i want ill need to add a few timers just to smooth things out
maybe a few other little bits but it functions and im stoked about that

what im not stoked about is typing out 200 questions and answers smile

anyways
Code:
alias trivia {
  msg %trivchan $read(q.txt)
  set %anum $readn
  set %answer $read(a.txt, %anum)
}
on *:text:*:#:{
  if (($1 == !start) && ($ulevel >= 4)) {
    timert 0 30 trivia
  }
  if ($1- == %answer) {
    msg $chan $nick is correct, the answer is %answer $+ .
    timert off
    trivia
  }
  if (($1 == !stop) && ($ulevel >= 4)) {
    timert off
  }
} 

#137265 11/12/05 03:09 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Here is a simple 'trivia' script I made up:
Code:
on *:TEXT:!start:$($trivchan):{
  [color:purple]if ($ulevel < 4) return[/color]
  unset %triv.*
  msg $trivchan Trivia is now ON
  .timertriv 1 7 showquestion
}
on *:TEXT:!stop:$($trivchan):{
  [color:purple]if ($ulevel < 4) return[/color]
  .disable #trivanswer
  unset %triv.*
  .timertriv off
  msg $trivchan Trivia is now OFF
}
on *:TEXT:!next:$($trivchan):{
  [color:purple]if ($ulevel < 4) return[/color]
  endquestion
}
on *:TEXT:!question &:$($trivchan):{
  [color:purple]if ($ulevel < 4) return[/color]
  endquestion $2
}

alias -l trivchan return [color:orange]#testtriv[/color]

alias -l showquestion {
  .disable #trivanswer

  ;** Read specific question? 
  if (($1) && ($1 !isnum $+(1-,$lines(qdb.txt)))) $& 
    msg $trivchan Invalid Question- $+(",$1,")
  else var %qline = $read(qdb.txt,$1)
  if (%qline) goto skip

  ;** Find random question
  var %c = 0
  while (%c <= 5) {
    inc %c
    var %qline = $read(qdb.txt)
    if ($istok(%triv.L,$readn,44)) continue
    else break
  }
  :skip

  ;** Display question, wait for answer
  set %triv.q $gettok(%qline,1,124)
  set %triv.a $gettok(%qline,2-,124)
  set %triv.L $readn $+ , $+ $gettok(%triv.L,1-4,44)
  set %triv.C $ctime
  msg $trivchan Question $readn $+ : %triv.q
  .enable #trivanswer
  .timertriv 1 [color:green]30[/color] endquestion
}

alias -l endquestion {
  .disable #trivanswer
  msg $trivchan Time is up.
  .timertriv 1 7 showquestion $1
}

#trivanswer on
on *:TEXT:*:#:{
  if ($istok(%triv.a,$remove($1-,$chr(124)),124)) {
    msg $trivchan $nick got the answer in $calc($ctime - %triv.C) seconds
[color:red]    msg $trivchan The answer: $remove($1-,$chr(124))[/color]
[color:blue]    msg $trivchan The answer: $gettok(%triv.a,1,124)[/color]
    .timertriv 1 7 showquestion
  }
}
#trivanswer end


The script reads a file called 'qdb.txt' for a single line. The qdb.txt file has a format like this:

Code:
Question A?|answerAa|answerAb
Question B?|answerBa|answerBb
Question C?|answerCa|answerCb|AnswerCc
Question D?|answerDa|answerDb|AnswerD c|Answer D d
Question E?|answerEa|answerEb
Question F?|answerFa|answerFb
Question G?|answerGa
Question H?|answerHa|answerHb
Question I?|answerIa|answerIb
Question J?|answerJa|answerJb
Question K?|answerKa|answerKb
Question L?|answerLa|answerLb


Each line has 1 question, and as many answers as mIRC will allow without overflowing a variable. The question/answers are separated by a single pipe | character (124). The question and answers can have spaces if necessary.

The questions are asked, and then the script waits some time for the answer. If there is no answer, it reports that the time is up, waits 7 seconds, then asks the next question. If someone answers the question, the script reports that someone has won, waits 7 seconds, then asks the next question.

Options:
The time given for answering the questions can be altered by adjusting the GREEN 30 in the code to the desired number of seconds.
-
The way that the answer is displayed can be altered by choosing either the RED or BLUE lines above. The red line will show the answer as exactly what the person answered with. The blue line will always display the FIRST answer as given in the qdb.txt, regardless of which answer the person answered with. Just comment out (;msg $trivchan...) the line that you don't want to use. Personally, I prefer using the blue line.
-
The purple text is where you can specify who can use the commands. Your own example used $ulevel 4, but you could replace that line with something like if ($nick !isop $trivchan) return to only allow channel operators to use the commands.
-
The orange text is where you would specify the name of your trivia channel.

There are 4 commands included in the script. The commands are as follows:
!start - Start the trivia
!stop - Stop the trivia
!next - Skip to the next question
!question ## - Skip to specified question ##

* Note that you CANNOT use any of the commands or answer the questions from the same connection that the script is running on. You will have to connect to your channel with the script in one mIRC and you in another.

If there are any problems, let me know here.

-genius_at_work

#137266 11/12/05 04:47 AM
Joined: Mar 2005
Posts: 212
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
heres a way simpler trivia script i made up
Code:
alias trivia {
  msg %trivchan $read(q.txt)
  set %anum $readn
  set %answer $read(a.txt, %anum)
}
on *:text:*:#:{
  if ($1 == !start) {
    timert 1 10 trivia
    timert2 0 40 trivia  
  }
  if ($1- == %answer) {
    msg $chan $nick is correct, the answer is %answer $+ .
    timert off
    timert2 off    
    timert 1 10 trivia
    timert2 0 35 trivia
  }
  if ($1 == !stop) {
    timert off
    timert2 off  
  }
  if (($1 == !answer) && ($ulevel >= 4)) {
    msg $chan %answer
  } 
  if (($1 == !skip) && ($ulevel >= 4)) {
    timert off
    timert2 off    
    timert 1 10 trivia
    timert2 0 35 trivia
  }
}

is it a piece of crap yes
does it get the job done yes
did i really name it pos_trivia_bot yes

as per usual im insistent on using my own stuff
and seeing as i have no experience with tokens
and frankly i didnt want real polished its just a study aid

i had to go ultra simple, but at least i came out with something that does what i need it to do

i really appreciate you taking the time to write that and i'll certainly hang on to it should i ever be struck by the urge to do a trivia bot semi right

Last edited by NeUtRoN_StaR; 11/12/05 04:50 AM.

Link Copied to Clipboard