Skip to content
Permalink
Browse files
fixed duplicate poll functionality and commented code. updated the re…
…turn type for function getPollID.
  • Loading branch information
masudm6 committed Nov 22, 2020
1 parent 903ee7e commit 16da5c0b843bd7f9b31c54202ecd07488637d644
Showing 1 changed file with 7 additions and 7 deletions.
@@ -289,10 +289,10 @@ def getPollID(message,communityName,polls):

if communityName.upper() in polls.values(): # if there is a poll active already
pollID = list(polls.keys())[list(polls.values()).index(communityName.upper())] # get the ID of the poll
return True, pollID
return [True, pollID]

else: # and if there is not an active poll already...
return False
return [False,0]

def addPoll(poll,communityName):
polls[poll.id] = communityName.upper() # save the pollID and communityName together
@@ -325,7 +325,7 @@ def countPoll(message,communityName,pollReactions):
# add a message to the end of the results depending on the votes for the emojis. DevOps work item 34
# print("[BOT DEBUG] tick cross :",tickCount,crossCount) # this code was used to debug the tick and cross counts.
if tickCount == crossCount:
countDesc = countDesc + "\n This community seems to be equally supportive and salty."
countDesc = countDesc + "\n This community seems to be both supportive and salty."
elif tickCount > crossCount:
countDesc = countDesc + "\n This community seems to be more supportive."
elif tickCount < crossCount:
@@ -389,11 +389,11 @@ async def on_message(message): #checks for a message
# ================ Masud did this ================
if "salt " == (message.content.lower())[:5]: # checks if the input matches "salt "
communityName = (message.content)[5:] # saves the rest of the input as communityName
await message.add_reaction("🆗")
result = getPollID(message, communityName, polls)
if result == True:
if result[0] == True:
await message.channel.send(f'The community: {communityName} already has a poll active. Poll ID:{result[1]}.') # message to discord
elif result == False:
else:
await message.add_reaction("🆗")
poll = await message.channel.send(f'vote here for {communityName}:') # create the vote poll
# print(f'[BOT DEBUG] {communityName} added to list of polls') # print to console for debugging only
addPoll(poll,communityName)
@@ -403,7 +403,7 @@ async def on_message(message): #checks for a message

if "count " == (message.content.lower())[:6]: # checks if the input matches "count ". DevOps work item 33
communityName = (message.content)[6:] # saves the rest of the input as communityName
if getPollID(message, communityName, polls) == False: # checks if the poll does not exist already
if getPollID(message, communityName, polls)[0] == False: # checks if the poll does not exist already
await message.channel.send(f'No poll found for community: {communityName}.') # messages to discord
else:
pollID = getPollID(message, communityName, polls)[1]

0 comments on commit 16da5c0

Please sign in to comment.