Guest User

Untitled

a guest
Jul 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. __module_name__ = "defaultmodule"
  2. __module_version__ = "1.0"
  3. __module_description__ = """
  4. My default module, containing all the things I find necessary.
  5. """
  6.  
  7. import xchat
  8. import random
  9. xchat.prnt("Attempting to load module...")
  10. fquestions = []
  11. questionnumb = 0
  12. answer = ""
  13. def initiate_game():
  14. f = open("/home/brax/.xchat2/questions.txt")
  15. i = 0
  16. for line in f:
  17. fquestions[i] = line
  18. i = i+1
  19. xchat.emit_print("Channel Message", "TriviaBot", """
  20. Trivia Game, (C) Braxton Spence, 2009.
  21. Type [question] to start another question.
  22. Type only what you think is the answer, not "is it _______?"
  23. """)
  24. f.close()
  25. def question(numb):
  26. questionnumb = numb
  27. answer = fquestions[numb+1]
  28. xchat.emit_print("Channel Message", "TriviaBot", "Question 1: " + fquestions[numb])
  29. def get_answer(word, word_eol, userdata):
  30. if word[1] == answer:
  31. xchat.emit_print("Channel Message", "TriviaBot", "Congratulations! *Gives cookie to " + word[0] + "*")
  32. elif word[1] == "[question]":
  33. question((random.randint(0,(len(fquestions))/2)*2))
  34. xchat.hook_print("Channel Message", get_answer)
  35. xchat.prnt("Module loaded.")
  36. initiate_game()
Add Comment
Please, Sign In to add comment