rendered paste body#!/usr/bin/env python
"""
trivia.py - A trivia extension for phenny
Author: Andrew Collins, [wrtpeeps]
URL: http://w00tage.be
"""
import random
import os
def t_begin(self, origin, match, args):
self.msg(origin.sender, "Trivia starting...")
t_begin.rule = '^\.tbegin$'
def t_ask(self, origin, match, args):
f=open('modules/questions.txt', 'r')
questions = f.read()
questions = questions.split('\n')
mini = 0
maxi = len(questions)
question_num = random.randint(mini, int(maxi)-1)
current_q = questions[question_num].split('-!-')
self.msg(origin.sender, current_q[0])
t_listen(self, origin.sender, match, args, 30, current_q[1])
global answer
answer = current_q[1]
t_ask.rule = '^\.task$'
def t_listen(self, chnl, match, args):
self.msg(chnl, 'CORRECT!')
t_listen.rule = answer