def add_points(message):
"""
Every time someone sends a message, they gain one point.
This is because any time based ones would result in mobile users having
the same amount of each, due to idling.
"""
split_message = message.content.split()
message.author.name = message.author.name.lower()
points = load_points(message, message.author.name)
message_amount = messages.load_messages(message, message.author.name)
non_trigger = ["!points","!roulette","!userpoints","!givepoints","!barryroulette","!rps","!rockpaperscissors"]
non_message_trigger = ["!usermessages","!messages"]
if message.author.name not in message_amount:
message_amount[message.author.name] = 0
elif len(split_message) == 0 or split_message[0] not in non_message_trigger:
message_amount[message.author.name] += 1
if message.author.name not in points:
points[message.author.name] = 0
elif len(split_message) == 0 or split_message[0] not in non_trigger:
points[message.author.name] += 1
try:
pickle.dump(points, open("{0}/{0}_points.txt".format(str(message.server)),"wb"))
except FileNotFoundError:
try:
os.makedir("{}".format(message.server))
except FileExistsError:
temp_points = open("{0}/{0}_points.txt".format(str(message.server)),"w")
temp_points.close()
pickle.dump(points, open("{0}/{0}_points.txt".format(str(message.server)),"wb"))
pickle.dump(message_amount, open("{0}/{0}_messages.txt".format(str(message.server)),"wb"))
return True
#Sets emotes in points, is its own function due to me using it twice.
评论列表
文章目录