From 9adbef0f27c9a282d717bc00d0abeebdaeb5a769 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 30 Oct 2018 08:50:46 +0530 Subject: [PATCH] Add get_points and add_points --- questable.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/questable.py b/questable.py index 9600aba..c6b60f7 100644 --- a/questable.py +++ b/questable.py @@ -110,3 +110,17 @@ class player(): query = 'UPDATE state SET state=? WHERE chat_id=?' cursor.execute(query, (state, self.CHAT_ID)) 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()