Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if stringdetect(":CB trivia"):
- triviakill = 0
- badfile = 0
- scores = dict()
- triviatype = stringSplit(ircmsg, "trivia", 7)
- print("Trivia type:"+triviatype)
- if os.path.isfile(os.path.normpath(filelocation+'/trivia-'+triviatype)) == True:
- ircsock.send("PRIVMSG "+ channel +" :Loading trivia pack "+triviatype+"!\n")
- print("Loading trivia")
- time.sleep(1)
- with open(os.path.normpath(filelocation+'/trivia-'+triviatype)) as triviafile:
- try:
- triviapack = triviafile.read()
- print(triviapack)
- triviapack = eval(triviapack)
- trivq = triviapack.keys()
- triva = triviapack.values()
- print(trivq)
- print(triva)
- except:
- ircsock.send("PRIVMSG "+ channel +" :Bad trivia file.\n")
- badfile = 1
- ircmsg = ""
- if badfile == 0:
- ircsock.send("PRIVMSG "+ channel +" :Trivia mode is activated. All other bot functions will not work. Type 'CB trivia stop' to stop the game.\n")
- trivcounter = 0
- trivanswered = 0
- for x in trivq:
- trivcounter = trivcounter + 1
- ircsock.send("PRIVMSG "+ channel +" :\x0304Question "+str(trivcounter)+": "+trivq[trivcounter - 1]+"\x03\n")
- while trivanswered == 0:
- ircmsg = ircsock.recv(2048) # receive data from the server
- ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
- print(ircmsg) # Here we print what's coming from the server
- if stringdetect(":CB trivia stop"):
- if any(word in ircmsg for word in mods):
- ircsock.send("PRIVMSG "+ channel +" :Stopping trivia game immediately.\n")
- triviakill = 1
- break
- else:
- ircsock.send("PRIVMSG "+ channel +" :You are not authorized to stop the game!\n")
- if str(triva[trivcounter - 1]).lower() in ircmsg.lower():
- trivanswered = 1
- if triviakill == 1:
- break
- user = ircmsg[1:]
- ircmsgr = user.index("!")
- user = user[:ircmsgr]
- ircsock.send("PRIVMSG "+ channel +" :"+user+" got it right!\n")
- try:
- scores[user] = scores[user] + 1
- except:
- scores[user] = 1
- ircmsg = ""
- trivanswered = 0
- ircsock.send("PRIVMSG "+ channel +" :Game over! :) \n")
- ircsock.send("PRIVMSG "+ channel +" :Scores:\n")
- scoresstr = str(scores)
- scoresstr = scoresstr.strip("{")
- scoresstr = scoresstr.strip("}")
- ircsock.send("PRIVMSG "+ channel +" :"+scoresstr+"\n")
- else:
- ircsock.send("PRIVMSG "+ channel +" :Trivia pack not found!\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement