aboutsummaryrefslogtreecommitdiffstats
path: root/subreddit.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2020-07-27 15:12:58 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2020-07-27 15:12:58 +0100
commitc2496d212640bcdc439e39725f2e26c658a2bc63 (patch)
tree15867cade067b93e18f1c7545b75dac93cdb1e6d /subreddit.py
parent386b9d9a005178077c9f5c0206e1c6722b580c55 (diff)
downloadSmallYTChannelBot-c2496d212640bcdc439e39725f2e26c658a2bc63.tar.gz
SmallYTChannelBot-c2496d212640bcdc439e39725f2e26c658a2bc63.zip
fixed a small bug
Diffstat (limited to 'subreddit.py')
-rwxr-xr-xsubreddit.py9
1 files changed, 5 insertions, 4 deletions
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: