aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2016-03-05 00:15:39 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2016-04-22 16:41:10 +0200
commit339ccaff398bfc959b20c61faa1dc1ca09590164 (patch)
tree027f102e97df90d1c9205c28c452cffcda09d9b8
parentcb2f046ff82f6fe339a8a7d541eca61de7844958 (diff)
downloadwee-slack-339ccaff398bfc959b20c61faa1dc1ca09590164.tar.gz
Remove count item from reactions
Since we now store and show the users for each reaction, we don't need to store count as well. Each user can only react with a specific reaction to a specific message once, so to get the count we can check the length of the list of users.
-rw-r--r--wee_slack.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/wee_slack.py b/wee_slack.py
index a39f494..5f2be1d 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -938,19 +938,17 @@ class Message(object):
found = False
for r in self.message_json["reactions"]:
if r["name"] == reaction:
- r["count"] += 1
r["users"].append(user)
found = True
if not found:
- self.message_json["reactions"].append({u"count": 1, u"name": reaction, u"users": [user]})
+ self.message_json["reactions"].append({u"name": reaction, u"users": [user]})
else:
- self.message_json["reactions"] = [{u"count": 1, u"name": reaction, u"users": [user]}]
+ self.message_json["reactions"] = [{u"name": reaction, u"users": [user]}]
def remove_reaction(self, reaction, user):
if "reactions" in self.message_json:
for r in self.message_json["reactions"]:
if r["name"] == reaction:
- r["count"] -= 1
r["users"].remove(user)
else:
pass
@@ -1575,7 +1573,7 @@ def create_reaction_string(reactions):
else:
reaction_string = ' ['
for r in reactions:
- if r["count"] > 0:
+ if len(r["users"]) > 0:
count += 1
users = ",".join(resolve_ref("@{}".format(user)) for user in r["users"])
reaction_string += ":{}:({}) ".format(r["name"], users)