Example #1
0
def delete_pending(discord_id):
    conn = DB(data_dir=app.config["data_dir"]).connection

    cursor = conn.cursor()
    cursor.execute(f"DELETE FROM pending_users WHERE discord_id={discord_id}")

    conn.commit()
Example #2
0
def delete_pending(discord_id):
    conn = DB(data_dir=app.config['data_dir']).connection

    cursor = conn.cursor()
    cursor.execute("DELETE FROM pending_users WHERE discord_id={}".format(discord_id))

    conn.commit()
Example #3
0
 async def remover(self, member):
     try:
         conn = DB(data_dir=self.bot.data_dir).connection
         cursor = conn.cursor()
         cursor.execute(f"DELETE FROM github_users WHERE discord_id={member.id}")
         conn.commit()
         self.bot.logger.info("%s left, purged from database", member.name)
     except:
         pass
Example #4
0
def get_user(self, discord_id):
    conn = DB(data_dir=self.bot.data_dir).connection

    cursor = conn.cursor()

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

    row = cursor.fetchone()

    return row
Example #5
0
def get_users(self):
    conn = DB(data_dir=self.bot.data_dir).connection

    cursor = conn.cursor()

    cursor.execute("SELECT * FROM github_users")

    rows = cursor.fetchall()

    return rows
Example #6
0
def get_is_pending(discord_id, random_string):
    conn = DB(data_dir=app.config['data_dir']).connection

    cursor = conn.cursor()

    cursor.execute("SELECT * FROM pending_users WHERE discord_id={} AND verification='{}'".format(discord_id, random_string))

    row = cursor.fetchone()

    return row is not None
Example #7
0
def get_discord_user(self, gh_username):
    conn = DB(data_dir=self.bot.data_dir).connection

    cursor = conn.cursor()

    cursor.execute("SELECT * FROM github_users WHERE github_username='******'" % gh_username)

    row = cursor.fetchone()

    return row
Example #8
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
Example #9
0
    async def remove(self, ctx):
        user_mention = "<@{}>: ".format(ctx.author.id)
        conn = DB(data_dir=self.bot.data_dir).connection

        cursor = conn.cursor()

        cursor.execute("DELETE FROM github_users WHERE discord_id={}".format(
            ctx.author.id))

        conn.commit()

        return await ctx.send(user_mention + "fjernet Githuben din.")
Example #10
0
    async def remove(self, ctx):
        """
        Kommando for å fjerne kobling mellom Github- og Discord-bruker
        """
        conn = DB(data_dir=self.bot.data_dir).connection

        cursor = conn.cursor()

        cursor.execute(f"DELETE FROM github_users WHERE discord_id={ctx.author.id}")

        conn.commit()

        return await ctx.send(ctx.author.mention + "fjernet Githuben din.")
Example #11
0
 def __init__(self):
     super().__init__(command_prefix=_prefix_callable, help_command=None)
     self.voice_hooks = {}
     self.firestore = FireStore(self)
     self.guild_setting = {}
     self.db = DB()
     self.access_token = None
     self.loop.create_task(self.access_token_loop())
Example #12
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
Example #13
0
 def __init__(self, bot):
     self.bot = bot
     database = DB(data_dir=self.bot.data_dir)
     database.populate_tables()
Example #14
0
 def __init__(self, bot):
     self.bot = bot
     cacher = self.Cacher(self)
     self.bot.loop.create_task(cacher.loop())
     database = DB(data_dir=self.bot.data_dir)
     database.populate_tables()