Skip to content

Commit

Permalink
fix celery override
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed May 20, 2023
1 parent 8395486 commit 8a50104
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ytdlbot/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ def check_old_user(self, user_id: int) -> tuple:
return data

def get_pay_token(self, user_id: int) -> int:
self.cur.execute("SELECT token FROM payment WHERE user_id=%s", (user_id,))
data = self.cur.fetchall() or [(0,)]
self.cur.execute("SELECT token, old_user FROM payment WHERE user_id=%s", (user_id,))
data = self.cur.fetchall() or [(0, False)]
number = sum([i[0] for i in data if i[0]])
if number == 0:
logging.info("User %s has no token, set download mode to Celery", user_id)
if number == 0 and data[0][1] != 1:
# not old user, no token
logging.warning("User %s has no token, set download mode to Celery", user_id)
# change download mode to Celery
self.set_user_settings(user_id, "mode", "Celery")
return number
Expand Down

0 comments on commit 8a50104

Please sign in to comment.