From c2496d212640bcdc439e39725f2e26c658a2bc63 Mon Sep 17 00:00:00 2001 From: jwansek Date: Mon, 27 Jul 2020 15:12:58 +0100 Subject: fixed a small bug --- subreddit.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'subreddit.py') diff --git a/subreddit.py b/subreddit.py index 6a398f2..5632b82 100755 --- a/subreddit.py +++ b/subreddit.py @@ -69,7 +69,8 @@ def update_users_flair(username): if username in get_mods(): newflair = "[馃弳 鈭炍籡 %s" % (flairtext) else: - actualscore = db.get_lambda(username)[0] + with database.Database() as db: + actualscore = db.get_lambda(username)[0] newflair = "[%s%i位] %s" % (get_medal(actualscore), actualscore, flairtext) logging.info("/u/%s had their flair updated" % username) @@ -187,7 +188,7 @@ def handle_givelambda(comment): elif str(comment.author) in get_mods(): text = "The moderator /u/%s has given /u/%s 1位. /u/%s now has %i位." % (str(comment.author), parentauthour, parentauthour, db.get_lambda(parentauthour)[0] + 1) db.give_lambda(parentauthour, submission.permalink, timestamp = int(submission.created_utc)) - display(text) + display(text) elif submission.link_flair_text in FREE_FLAIRS: text = "You cannot give lambda in free posts anymore." elif op != str(submission.author): @@ -216,8 +217,8 @@ def handle_takelambda(comment): toremove = int(splitted[2].replace("\\", "")) reason = " ".join(splitted[3:]) - text = "/u/%s has had %i位 taken away from them for the reason '%s'. /u/%s now has %i位" % (user, toremove, reason, user, db.get_lambda(user)[0] - toremove) with database.Database() as db: + text = "/u/%s has had %i位 taken away from them for the reason '%s'. /u/%s now has %i位" % (user, toremove, reason, user, db.get_lambda(user)[0] - toremove) db.change_lambda(user, -toremove) display("A moderator removed %i lambda from /u/%s for the reason '%s'" % (toremove, user, reason)) except Exception as e: @@ -234,8 +235,8 @@ def handle_refundlambda(comment): toadd = int(splitted[2].replace("\\", "")) reason = " ".join(splitted[3:]) - text = "/u/%s has had %i位 refunded for the reason '%s'. /u/%s now has %i位" % (user, toadd, reason, user, db.get_lambda(user)[0] + toadd) with database.Database() as db: + text = "/u/%s has had %i位 refunded for the reason '%s'. /u/%s now has %i位" % (user, toadd, reason, user, db.get_lambda(user)[0] + toadd) db.change_lambda(user, toadd) display("A moderator refunded %i lambda from /u/%s for the reason '%s'" % (toadd, user, reason)) except Exception as e: -- cgit v1.2.3