def Network_requestChallenge(self, data): # Challenge number name = data["name"] N = int(data["number"]) challengefile = "challenges/" + str(N) if N==-1 or not os.path.exists(challengefile): # Loop through all challenges for N in sorted(os.listdir("challenges/")): userpath = "stats/" + name + "/" trophyfile = os.path.join(userpath, N) if not os.path.exists(trophyfile): break challengefile = "challenges/" + str(N) # Verification info verification = [time.time(), name, N] challengestr = challenge.ChallengeScheme(challenge.readText(challengefile)).generate(SECRET_KEY, verification).__str__() self.Send({"action": "chat", "text": challengestr})
def submitAnswer(self, filename, name): answer = challenge.readText(filename) answer = answer.__str__() connection.Send({"action": "submitAnswer", "text": answer, "name": name}) self.Loop()
#!/usr/bin/python import challenge import sys secret_key = "testkey" sys.stdout.write(challenge.ChallengeScheme(challenge.readText("challenges/1")).generate(secret_key).__str__())