Add get_quests to player

This commit is contained in:
Ceda EI 2018-10-30 20:03:43 +05:30
parent 9adbef0f27
commit b650b0e1db
1 changed files with 15 additions and 0 deletions

View File

@ -124,3 +124,18 @@ class player():
query = 'UPDATE points SET points=? WHERE chat_id=?' query = 'UPDATE points SET points=? WHERE chat_id=?'
cursor.execute(query, (new_points, self.CHAT_ID)) cursor.execute(query, (new_points, self.CHAT_ID))
self.DB.commit() 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