From 2f2145f73abb0cddd29f40791363f71203e2e916 Mon Sep 17 00:00:00 2001 From: DrBot7 <46543473+DrBot7@users.noreply.github.com> Date: Fri, 15 Jan 2021 05:05:51 -0600 Subject: [PATCH 1/3] Add invite link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d317760..27fe4af 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Botflop +[Click here](https://discord.com/api/oauth2/authorize?client_id=787929894616825867&permissions=0&scope=bot) to invite Botflop to your server # Current abilities ## Analyze timings reports From 4da058ae32a1bfb274c0743bc9c2ede326db9214 Mon Sep 17 00:00:00 2001 From: Purpur <43528123+Pemigrade@users.noreply.github.com> Date: Fri, 15 Jan 2021 05:10:05 -0600 Subject: [PATCH 2/3] Make private ping only displayed in birdflop discord --- bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 7e55c72..c638ae6 100644 --- a/bot.py +++ b/bot.py @@ -133,7 +133,8 @@ async def on_raw_reaction_add(payload): @bot.command() async def ping(ctx): if running_on_panel: - await ctx.send(f'Private bot ping is {round(bot.latency * 1000)}ms') + if guild_id == ctx.guild.id: + await ctx.send(f'Private bot ping is {round(bot.latency * 1000)}ms') if not running_on_panel: await ctx.send(f'Public bot ping is {round(bot.latency * 1000)}ms') From b4d6221c4602540a37eb61e6e34449d14ce56c88 Mon Sep 17 00:00:00 2001 From: Purpur <43528123+Pemigrade@users.noreply.github.com> Date: Fri, 15 Jan 2021 05:10:45 -0600 Subject: [PATCH 3/3] Update linking_panel.py --- cogs/linking_panel.py | 277 +++++++++++++++++++++--------------------- 1 file changed, 140 insertions(+), 137 deletions(-) diff --git a/cogs/linking_panel.py b/cogs/linking_panel.py index 2027e48..6f966b6 100644 --- a/cogs/linking_panel.py +++ b/cogs/linking_panel.py @@ -25,146 +25,149 @@ class Linking(commands.Cog): @commands.Cog.listener() async def on_message(self, message): - if message.author != self.bot.user and message.guild is None: - channel = message.channel - await channel.send("Processing, please wait...") - # Potential API key, so tries it out - if len(message.content) == 48: - url = "https://panel.birdflop.com/api/client/account" - - headers = { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + message.content, - } - - # response = requests.get(url, headers=headers) - - async with aiohttp.ClientSession() as session: - async with session.get(url, headers=headers) as response: - - # If API token is verified to be correct: - if response.status == 200: - - # Formats response of account in JSON format - json_response = await response.json() - - # Loads contents of users.json - file = open('users.json', 'r') - data = json.load(file) - file.close() - - # Checks if user exists. If so, skips adding them to users.json - client_id_already_exists = False - discord_id_already_exists = False - for user in data['users']: - if user['client_id'] == json_response['attributes']['id']: - client_id_already_exists = True - logging.info("Client ID already exists") - if user['discord_id'] == message.author.id: - discord_id_already_exists = True - logging.info("Discord ID already exists") - if not client_id_already_exists and not discord_id_already_exists: - data['users'].append({ - 'discord_id': message.author.id, - 'client_id': json_response['attributes']['id'], - 'client_api_key': message.content - }) - json_dumps = json.dumps(data, indent=2) - # Adds user to users.json - file = open('users.json', 'w') - file.write(json_dumps) + self.guild = self.bot.get_guild(self.guild_id) + if message.author != self.bot.user and message.guild is None and self.guild.get_member(message.author.id) is not None: + if "://" in message.content: + return + if self.guild in message.author.guilds: + channel = message.channel + await channel.send("Processing, please wait...") + # Potential API key, so tries it out + if len(message.content) == 48: + url = "https://panel.birdflop.com/api/client/account" + + headers = { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + message.content, + } + + # response = requests.get(url, headers=headers) + + async with aiohttp.ClientSession() as session: + async with session.get(url, headers=headers) as response: + + # If API token is verified to be correct: + if response.status == 200: + + # Formats response of account in JSON format + json_response = await response.json() + + # Loads contents of users.json + file = open('users.json', 'r') + data = json.load(file) file.close() - guild = self.bot.get_guild(self.guild_id) - member = guild.get_member(message.author.id) - if member: - - url = "https://panel.birdflop.com/api/client" - - headers = { - 'Accept': 'application/json', - 'Authorization': 'Bearer ' + message.content, - } - - async with aiohttp.ClientSession() as session: - async with session.get(url, headers=headers) as response: - - # If API token is verified to be correct, continues - if response.status == 200: - - # Formats response for servers in JSON format - servers_json_response = await response.json() - - user_client = False - user_subuser = False - user_crabwings = False - user_duckfeet = False - user_elktail = False - for server in servers_json_response['data']: - server_owner = server['attributes']['server_owner'] - if server_owner: - user_client = True - elif not server_owner: - user_subuser = True - server_node = server['attributes']['node'] - if server_node == "Crabwings - NYC": - user_crabwings = True - elif server_node == "Duckfeet - EU": - user_duckfeet = True - elif server_node == "Elktail - EU": - user_elktail = True - if user_client: - role = discord.utils.get(guild.roles, id=self.client_role_id) + # Checks if user exists. If so, skips adding them to users.json + client_id_already_exists = False + discord_id_already_exists = False + for user in data['users']: + if user['client_id'] == json_response['attributes']['id']: + client_id_already_exists = True + logging.info("Client ID already exists") + if user['discord_id'] == message.author.id: + discord_id_already_exists = True + logging.info("Discord ID already exists") + if not client_id_already_exists and not discord_id_already_exists: + data['users'].append({ + 'discord_id': message.author.id, + 'client_id': json_response['attributes']['id'], + 'client_api_key': message.content + }) + json_dumps = json.dumps(data, indent=2) + # Adds user to users.json + file = open('users.json', 'w') + file.write(json_dumps) + file.close() + + member = self.guild.get_member(message.author.id) + if member: + + url = "https://panel.birdflop.com/api/client" + + headers = { + 'Accept': 'application/json', + 'Authorization': 'Bearer ' + message.content, + } + + async with aiohttp.ClientSession() as session: + async with session.get(url, headers=headers) as response: + + # If API token is verified to be correct, continues + if response.status == 200: + + # Formats response for servers in JSON format + servers_json_response = await response.json() + + user_client = False + user_subuser = False + user_crabwings = False + user_duckfeet = False + user_elktail = False + for server in servers_json_response['data']: + server_owner = server['attributes']['server_owner'] + if server_owner: + user_client = True + elif not server_owner: + user_subuser = True + server_node = server['attributes']['node'] + if server_node == "Crabwings - NYC": + user_crabwings = True + elif server_node == "Duckfeet - EU": + user_duckfeet = True + elif server_node == "Elktail - EU": + user_elktail = True + if user_client: + role = discord.utils.get(self.guild.roles, id=self.client_role_id) + await member.add_roles(role) + if user_subuser: + role = discord.utils.get(self.guild.roles, id=self.subuser_role_id) + await member.add_roles(role) + if user_crabwings: + role = discord.utils.get(self.guild.roles, id=self.crabwings_role_id) + await member.add_roles(role) + if user_duckfeet: + role = discord.utils.get(self.guild.roles, id=self.duckfeet_role_id) + await member.add_roles(role) + if user_elktail: + role = discord.utils.get(self.guild.roles, id=self.elktail_role_id) + await member.add_roles(role) + role = discord.utils.get(self.guild.roles, id=self.verified_role_id) await member.add_roles(role) - if user_subuser: - role = discord.utils.get(guild.roles, id=self.subuser_role_id) - await member.add_roles(role) - if user_crabwings: - role = discord.utils.get(guild.roles, id=self.crabwings_role_id) - await member.add_roles(role) - if user_duckfeet: - role = discord.utils.get(guild.roles, id=self.duckfeet_role_id) - await member.add_roles(role) - if user_elktail: - role = discord.utils.get(guild.roles, id=self.elktail_role_id) - await member.add_roles(role) - role = discord.utils.get(guild.roles, id=self.verified_role_id) - await member.add_roles(role) - - await channel.send( - 'Your Discord account has been linked to your panel account! You may unlink your Discord and panel accounts by reacting in the #verification channel or by deleting your Verification API key.') - logging.info("Success message sent to " + message.author.name + "#" + str( - message.author.discriminator) + " (" + str( - message.author.id) + ")" + ". User linked to API key " + message.content + " and client_id " + str( - json_response['attributes']['id'])) - elif discord_id_already_exists: - await channel.send( - 'Sorry, your Discord account is already linked to a panel account. If you would like to link your Discord account to a different panel account, please unlink your Discord account first by reacting in the #verification channel.') - logging.info("Duplicate Discord message sent to " + message.author.name + "#" + str( - message.author.discriminator) + " (" + str( - message.author.id) + ")" + " for using API key " + message.content + " linked to client_id " + str( - json_response['attributes']['id'])) - elif client_id_already_exists: - await channel.send( - 'Sorry, your panel account is already linked to a Discord account. If you would like to link your panel account to a different Discord account, please unlink your panel account first by deleting its Verification API key and waiting up to 10 minutes.') - logging.info("Duplicate panel message sent to " + message.author.name + "#" + str( - message.author.discriminator) + " (" + str( - message.author.id) + ")" + " for using API key " + message.content + " linked to client_id " + str( - json_response['attributes']['id'])) - else: - # Says if API key is the corect # of characters but invalid - await channel.send("Sorry, that appears to be an invalid API key.") - logging.info( - 'invalid sent to ' + message.author.name + "#" + str( - message.author.discriminator) + " (" + str( - message.author.id) + ")") - else: - # Says this if API key is incorrect # of characters - await channel.send( - 'Sorry, that doesn\'t appear to be an API token. An API token should be a long string resembling this: ```yQSB12ik6YRcmE4d8tIEj5gkQqDs6jQuZwVOo4ZjSGl28d46```') - logging.info("obvious incorrect sent to " + message.author.name + "#" + str( - message.author.discriminator) + " (" + str(message.author.id) + ")") + + await channel.send( + 'Your Discord account has been linked to your panel account! You may unlink your Discord and panel accounts by reacting in the #verification channel or by deleting your Verification API key.') + logging.info("Success message sent to " + message.author.name + "#" + str( + message.author.discriminator) + " (" + str( + message.author.id) + ")" + ". User linked to API key " + message.content + " and client_id " + str( + json_response['attributes']['id'])) + elif discord_id_already_exists: + await channel.send( + 'Sorry, your Discord account is already linked to a panel account. If you would like to link your Discord account to a different panel account, please unlink your Discord account first by reacting in the #verification channel.') + logging.info("Duplicate Discord message sent to " + message.author.name + "#" + str( + message.author.discriminator) + " (" + str( + message.author.id) + ")" + " for using API key " + message.content + " linked to client_id " + str( + json_response['attributes']['id'])) + elif client_id_already_exists: + await channel.send( + 'Sorry, your panel account is already linked to a Discord account. If you would like to link your panel account to a different Discord account, please unlink your panel account first by deleting its Verification API key and waiting up to 10 minutes.') + logging.info("Duplicate panel message sent to " + message.author.name + "#" + str( + message.author.discriminator) + " (" + str( + message.author.id) + ")" + " for using API key " + message.content + " linked to client_id " + str( + json_response['attributes']['id'])) + else: + # Says if API key is the corect # of characters but invalid + await channel.send("Sorry, that appears to be an invalid API key.") + logging.info( + 'invalid sent to ' + message.author.name + "#" + str( + message.author.discriminator) + " (" + str( + message.author.id) + ")") + else: + # Says this if API key is incorrect # of characters + await channel.send( + 'Sorry, that doesn\'t appear to be an API token. An API token should be a long string resembling this: ```yQSB12ik6YRcmE4d8tIEj5gkQqDs6jQuZwVOo4ZjSGl28d46```') + logging.info("obvious incorrect sent to " + message.author.name + "#" + str( + message.author.discriminator) + " (" + str(message.author.id) + ")") def setup(bot):