💰 Added money-based commands
This commit is contained in:
@ -2,6 +2,7 @@ import json
|
||||
import urllib
|
||||
import random
|
||||
|
||||
from . import money
|
||||
from funcs import logThis
|
||||
|
||||
def triviaStart(channel : str):
|
||||
@ -24,7 +25,19 @@ def triviaStart(channel : str):
|
||||
with open("resources/games.json", "w") as f:
|
||||
json.dump(triviaFile,f,indent=4)
|
||||
|
||||
question = data["results"][0]["question"].replace("'","\'").replace(""","\"")
|
||||
replacements = {"'": "\'",
|
||||
""": "\"",
|
||||
"“": "\"",
|
||||
"”": "\"",
|
||||
"é": "é"}
|
||||
question = data["results"][0]["question"]
|
||||
|
||||
for key, value in replacements.items():
|
||||
question = question.replace(key,value)
|
||||
|
||||
for answer in answers:
|
||||
for key, value in replacements.items():
|
||||
answer = answer.replace(key,value)
|
||||
|
||||
return question, answers, correctAnswer
|
||||
else:
|
||||
@ -50,10 +63,6 @@ def triviaOtherThing(user : str, channel : str, command : str):
|
||||
return user+" has already answered this question"
|
||||
else:
|
||||
return "There's no question right now"
|
||||
elif command == "p":
|
||||
items = {k: v for k, v in sorted(data["users"].items(), key=lambda item: item[1])}
|
||||
|
||||
return "\n".join(['%s: %s' % (key, value) for (key, value) in items.items()])
|
||||
else:
|
||||
return "I didn't quite understand that"
|
||||
|
||||
@ -66,14 +75,8 @@ def triviaCountPoints(channel : str):
|
||||
if channel in data["trivia questions"]:
|
||||
for player, answer in data["trivia questions"][channel]["players"].items():
|
||||
if answer == data["trivia questions"][channel]["answer"]:
|
||||
if player in data["users"]:
|
||||
points = data["users"][player]
|
||||
data["users"][player] = points + 1
|
||||
else:
|
||||
data["users"][player] = 1
|
||||
money.addMoney(player,1)
|
||||
|
||||
with open("resources/games.json", "w") as f:
|
||||
json.dump(data,f,indent=4)
|
||||
|
||||
else:
|
||||
logThis("Couldn't find the question")
|
||||
|
Reference in New Issue
Block a user