diff --git a/.gitignore b/.gitignore index 225083f..8cb82a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.py +questable.db __pycache__/ diff --git a/bot.py b/bot.py index 2f6c461..94ba970 100644 --- a/bot.py +++ b/bot.py @@ -2,6 +2,7 @@ import logging import telegram +import sqlite3 from telegram.ext import Updater, CommandHandler try: @@ -29,6 +30,30 @@ def start(bot, update): bot.send_message(chat_id=chat_id, text=text, reply_markup=reply_markup) +db = sqlite3.connect("questable.db") +cursor = db.cursor() +# Set up tables +queries = [ + ("CREATE TABLE IF NOT EXISTS quests(user_id int NOT NULL, qid int NOT" + " NULL, name varchar(255) NOT NULL, difficulty int NOT NULL, " + "importance int NOT NULL, completed int NOT NULL, date int NOT NULL" + ", state int NOT NULL DEFAULT 0, UNIQUE(user_id, qid));"), + + ("CREATE TABLE IF NOT EXISTS side_quests(user_id int NOT NULL, qid int" + " NOT NULL, name varchar(255) NOT NULL, difficulty int NOT NULL, " + "importance int NOT NULL, completed int NOT NULL, date int NOT NULL" + ", state int NOT NULL DEFAULT 0, UNIQUE(user_id, qid));"), + + ("CREATE TABLE IF NOT EXISTS points(user_id int PRIMARY KEY, points " + "int);"), + + ("CREATE TABLE IF NOT EXISTS state(user_id int PRIMARY KEY, state " + "varchar(10));"), + ] +for query in queries: + cursor.execute(query) +db.commit() + updater = Updater(token=config.api_key) dispatcher = updater.dispatcher