Handle 404 response when a user with karma no longer exists
When a user which has karma deletes there account on pnut.io a 404 is generated on user lookup. This will handle the error gracefully and allow the !karma command to complete which resolves issue #2. A more complete for this should be to delete the karma entry for the now invalid user, to be done in another commit.
This commit is contained in:
parent
57f591d0a2
commit
b0ad45e935
1 changed files with 17 additions and 13 deletions
|
@ -154,8 +154,12 @@ def karma(room):
|
|||
reply = "Karma standings\n\n"
|
||||
results = Karma.query.filter(Karma.chanid == room).order_by(Karma.karma.desc()).all()
|
||||
for entry in results:
|
||||
user, meta = pnutpy.api.get_user(entry.userid)
|
||||
reply += user.username + ": " + str(entry.karma) + "\n"
|
||||
try:
|
||||
user, meta = pnutpy.api.get_user(entry.userid)
|
||||
reply += user.username + ": " + str(entry.karma) + "\n"
|
||||
|
||||
except pnutpy.errors.PnutMissing:
|
||||
continue
|
||||
send(room, reply)
|
||||
|
||||
def chimpnut(msg):
|
||||
|
|
Loading…
Reference in a new issue