Exemple #1
0
    def is_user_registered(self, discord_id, random_string):
        conn = DB(data_dir=self.bot.data_dir).connection

        if conn is None:
            return False

        cursor = conn.cursor()

        cursor.execute("SELECT * FROM github_users WHERE discord_id={}".format(
            discord_id))

        rows = cursor.fetchone()

        if rows is not None:
            conn.close()
            return True

        cursor.execute(
            "SELECT * FROM pending_users WHERE discord_id={}".format(
                discord_id))

        row = cursor.fetchone()

        if row is not None:
            cursor.execute(
                "DELETE FROM pending_users WHERE discord_id={}".format(
                    discord_id))

        cursor.execute(
            "INSERT INTO pending_users(discord_id, verification) VALUES(?, ?);",
            (discord_id, random_string))

        conn.commit()
        conn.close()
        return False
Exemple #2
0
def insert_user(discord_id, auth_token, github_username):
    conn = DB(data_dir=app.config['data_dir']).connection

    if conn is None:
        return False

    cursor = conn.cursor()

    params = (discord_id, auth_token, github_username)

    cursor.execute("INSERT OR REPLACE INTO github_users(discord_id, auth_token, github_username) VALUES(?, ?, ?);", params)
    conn.commit()

    conn.close()
    return True