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
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()
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()
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
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
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
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
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
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.")
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.")
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