Skip to content

Commit ed440e6

Browse files
committed
fix issue #5
1 parent 1c37367 commit ed440e6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

activity.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#################################
1717
#
1818
USER_DATABSE = 'data/users.csv' #
19+
MAX_SCORE = 250 #
1920
#
2021
#################################
2122

@@ -37,16 +38,20 @@ def __str__(self):
3738

3839

3940
def change_score(self, delta):
40-
if (self.score + delta > 0 and self.score + delta < 250):
41+
if (self.score + delta > MAX_SCORE):
42+
self.score = MAX_SCORE
43+
elif (self.score + delta < 0):
44+
self.score = 0
45+
else:
4146
self.score += delta
47+
4248
write_database()
43-
return self.score
4449

4550

4651
def change_all_scores(delta):
4752
for user in USERS.values():
48-
if (user.score + delta > 0 and user.score + delta < 250):
49-
user.score += delta
53+
user.change_score(delta)
54+
5055

5156
write_database()
5257

protobot.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async def on_message(message):
145145

146146
return
147147

148-
else:
148+
elif message.content[0] != "!":
149149
change_user_score(message.author.id, POINTS_PER_MESSAGE)
150150

151151
if 'happy birthday' in message.content.lower():
@@ -201,9 +201,6 @@ async def check_user_score(ctx):
201201
uuid = ctx.message.author.id
202202
score = get_user_score(uuid)
203203

204-
# Take away the points the user gets for running the command
205-
change_user_score(uuid, -POINTS_PER_MESSAGE)
206-
207204
await ctx.message.channel.send(f"Score for <@{uuid}>: {score}")
208205

209206

0 commit comments

Comments
 (0)