Add get_points and add_points

This commit is contained in:
Ceda EI 2018-10-30 08:50:46 +05:30
parent 84c3e94c0f
commit 9adbef0f27
1 changed files with 14 additions and 0 deletions

View File

@ -110,3 +110,17 @@ class player():
query = 'UPDATE state SET state=? WHERE chat_id=?' query = 'UPDATE state SET state=? WHERE chat_id=?'
cursor.execute(query, (state, self.CHAT_ID)) cursor.execute(query, (state, self.CHAT_ID))
self.DB.commit() self.DB.commit()
def get_points(self):
cursor = self.DB.cursor()
query = 'SELECT points FROM points WHERE chat_id=?'
cursor.execute(query, self.CHAT_ID)
output = cursor.fetchone()
return int(output[0])
def add_points(self, points):
new_points = self.get_points() + points
cursor = self.DB.cursor()
query = 'UPDATE points SET points=? WHERE chat_id=?'
cursor.execute(query, (new_points, self.CHAT_ID))
self.DB.commit()