This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def createUserFile(user, message): | |
permissions = ["Superuser", "Party Editor", "Verifier", "Bit 4", "Bit 5", "Bit 6", "Bit 7", "Bit 8"] | |
await client.send_message(message.channel, "Please send a series of numbers, separated by spaces, corresponding to the permissions to be set. Each bit of the permission field is as follows:") | |
await client.send_message(message.channel, "Bit 1: If set to 1, this user is a superuser and has all permissions." + "\r\n" + "Bit 2: If set to 1, this user can edit party information." + "\r\n" + "Bit 3: If set to 1, this user can manually verify people." + "\r\n" + "Bits 4 through 8 are unimplemented at this time.") | |
msg = await client.wait_for_message(timeout=30, author=message.author) | |
if(msg is not None): | |
with codecs.open(user + ".txt", "a") as file: | |
for x in range(0, 8): | |
file.write(permissions[x] + ": " + str(bool(msg.content.split(" ")[x])) + "\r\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def checkPermissions(user, permrequired): | |
with open(user + ".txt", "r") as file: | |
return (yaml.load(file)[permrequired] == True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def countVotes(submission, message, viewRawVotes): | |
embed=discord.Embed(title="CMHOC Clerk") | |
votedict = {"Bills": [x[0].replace(": Y", "") for x in re.findall("([CSM]\-\d\d(\s\w\d:|:)\sY)", submission.selftext)], "Unknown Votes": {}, "Raw Votes": {}} | |
for x in votedict["Bills"]: | |
votedict[x] = {"Yea": 0, "Nay": 0, "Abstain": 0} | |
for x in re.findall("((C|S|M)-(\d+:|\d+\s\w\d:)\s)([Yy]ea|[Nn]ay|[Aa]bstain|[Oo]ui|[Nn]on|[Aa]bstention)", "".join([y for y in [x.body.replace("\n", "") for x in submission.comments] if not re.match("^P", y)])): | |
print(x[0]) | |
if(x[0].replace(": ", "") in votedict["Bills"]): | |
if(x[3] in ["Yea", "yea", "Oui", "oui"]): | |
votedict[x[0].replace(": ", "")]["Yea"] += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countVotes(link): | |
submission = reddit.submission(url=link) | |
votedict = {"Bills": [x.replace("Y", "").replace(": ", "") for x in re.findall("([CSM]\-\d\d:\sY)", submission.selftext)]} | |
for x in [x.replace("Y", "").replace(": ", "") for x in re.findall("([CSM]\-\d\d:\sY)", submission.selftext)]: | |
votedict[x] = {"Yea": 0, "Nay": 0, "Abstain": 0} | |
for x in re.findall("((C|S|M)-(\d+):\s)([Yy]ea|[Nn]ay|[Aa]bstain|[Oo]ui|[Nn]on|[Aa]bstention)", "".join([y for y in [x.body.replace("\n", "") for x in submission.comments] if not re.match("^P", y)])): | |
if(x[0].replace(": ", "") in votedict["Bills"]): | |
if(x[3] in ["Yea", "yea", "Oui", "oui"]): | |
votedict[x[0].replace(": ", "")]["Yea"] += 1 | |
elif(x[3] in ["Nay", "nay", "Non", "non"]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def checkPermissions(user, permrequired): | |
if(permrequired == "777"): | |
if(user in superusers.readlines()): | |
return True | |
else: | |
return False | |
else: | |
with codecs.open("users.txt", "r") as file: | |
if(user in superusers.readlines()): | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def checkPermissions(user, permrequired): | |
with codecs.open("users.txt", "r") as file: | |
if(user in superusers.readlines()): | |
return True | |
else: | |
userperms = [line for line in file.readlines() if user in line] | |
perms = userperms.split("=")[3] | |
if(int(perms, 2) & int(permrequired, 2) >= int(permrequired, 2)): | |
return True | |
else: |