From b650b0e1db59e1782b2e594c794c0c24c05228f2 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 30 Oct 2018 20:03:43 +0530 Subject: [PATCH] Add get_quests to player --- questable.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/questable.py b/questable.py index c6b60f7..c26295a 100644 --- a/questable.py +++ b/questable.py @@ -124,3 +124,18 @@ class player(): query = 'UPDATE points SET points=? WHERE chat_id=?' cursor.execute(query, (new_points, self.CHAT_ID)) self.DB.commit() + + def get_quests(self, state=1): + cursor = self.DB.cursor() + query = ('SELECT chat_id, qid, name, importance, difficulty, date, ' + 'state FROM quests WHERE chat_id = ?') + if state is not None: + query += ' AND state = ?' + cursor.execute(query, state) + else: + cursor.execute(query) + quests = [] + for row in cursor: + q = quest(self.DB, *row) + quests.append(q) + return quests