From f8f801bcad4174fa66db179758e00b700617145f Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Mon, 28 Nov 2022 10:25:59 -0500 Subject: [PATCH 1/8] the neptunium is REAL!! - brand changes - exporting user data is now possible --- main.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index c80b5b7..5277a32 100644 --- a/main.py +++ b/main.py @@ -34,7 +34,7 @@ intents = discord.Intents.default() intents.message_content = True -prefixes = "u.", "U." +prefixes = "np.", "Np." async def obtainWebhookData(ctx, channelID): # check if channel webhook exists in local database @@ -48,7 +48,7 @@ async def obtainWebhookData(ctx, channelID): # if not, create and store it else: channel = uranium.get_channel(int(channelID)) - webhookID = await channel.create_webhook(name="Uranium Proxy Webhook") + webhookID = await channel.create_webhook(name="Neptunium Proxy Webhook") webhookPath = "./webhook-data/{0}".format(str(channelID)) webhookStore = open(webhookPath, "w") webhookStore.write(str(webhookID)) @@ -69,13 +69,13 @@ async def on_ready(): @uranium.command() async def about(ctx): embedVar = discord.Embed( - title="About Uranium", description="Uranium is a Discord bot that is used for roleplay and for use in systems/plurality.", color=0x20FD00 + title="About Neptunium", description="Neptunium is a Discord bot that is used for roleplay and for use in systems/plurality.", color=0x00fff4 ) if modified == True: embedVar.add_field(name="Warning:", value="*The owner of this bot has enabled the modified variable, which means this bot's code has been modified and put up for public use. A valid respository link for this code will be provided at the bottom.*", inline=False) embedVar.set_footer(text="Created by BurningInfern0.") - embedVar.set_image(url="https://user-images.githubusercontent.com/74492478/203663460-6863d8e6-66d8-4379-8fe9-aba48de15262.png") - embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own Uranium instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.", inline=False) + embedVar.set_image(url="https://user-images.githubusercontent.com/74492478/204309975-8b937ad8-99c1-40f1-a373-ce692873fada.png") + embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own Neptunium instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.", inline=False) embedVar.add_field(name="GNU Affero General Public License v3", value="https://www.gnu.org/licenses/agpl-3.0.html", inline=False) embedVar.add_field(name="Repository Link", value=respositoryLink, inline=False) await ctx.send(embed=embedVar) @@ -228,6 +228,13 @@ async def send(ctx, brackets:str, *, msg): async def execute(ctx, *, com): exec(com) +@uranium.command() +async def export(ctx): + try: + await ctx.send(file=discord.File(r'./user-data/{0}.tsv'.format(ctx.author.id))) + except: + await ctx.send(":x: *I'm sorry, an error occurred, please try again later.*") + f = open("token", "r") token = f.read() uranium.run(token) \ No newline at end of file From 11de4d20e4ccb164e1fc8f0de803c586e5681119 Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Tue, 29 Nov 2022 23:27:56 -0500 Subject: [PATCH 2/8] updated export command - added error messages (no user data file found, blank file, dms are turned off) - sends user data file via dms (unless one of the conditions above are met) - adds checkmark reaction to message if everything went smoothly --- README.md | 4 +++- main.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bbed743..2848e95 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Or to put it bluntly, Uranium is designed to be an open source version of Tupper * `u.proxy send Logan I cast fireball for {{2d6+5}} damage!` * Redirecting proxy messages to different channels * `u.proxy send Logan {{#channel}} hey, i'm being sent into a different channel!` +* Exporting user data + * `u.export` ## What is not possible as of now? * Changing proxy names or brackets @@ -31,7 +33,7 @@ Or to put it bluntly, Uranium is designed to be an open source version of Tupper * Listing your current proxies (with or without groups) and listing specific proxy information * Finding proxies * Proxy groups -* Importing and exporting user data +* Importing user data * Autoproxy * Privacy settings * Multiproxies diff --git a/main.py b/main.py index 5277a32..189f8b4 100644 --- a/main.py +++ b/main.py @@ -61,7 +61,7 @@ async def obtainWebhookData(ctx, channelID): async def on_ready(): print(f'[URANIUM] I have logged in as {uranium.user}!') - game = discord.Game("with proxies! | u.help") + game = discord.Game("with proxies! | np.help") await uranium.change_presence(status=discord.Status.online, activity=game) # await uranium.process_commands(message) @@ -231,9 +231,17 @@ async def execute(ctx, *, com): @uranium.command() async def export(ctx): try: - await ctx.send(file=discord.File(r'./user-data/{0}.tsv'.format(ctx.author.id))) - except: - await ctx.send(":x: *I'm sorry, an error occurred, please try again later.*") + if os.stat('./user-data/{0}.tsv'.format(ctx.author.id)).st_size == 0: + await ctx.send(":x: *Why would I send a blank user data file?*") + else: + dmChannel = await ctx.author.create_dm() + try: + await dmChannel.send("**Hi, {0}!** :wave:\nHere is your user data file you requested.\nOh, and please note: user data importing is not supported at the moment, so all you can really do is view your data. Sorry :(".format(ctx.author.name), file=discord.File(r'./user-data/{0}.tsv'.format(ctx.author.id))) + await ctx.message.add_reaction("✅") + except discord.errors.Forbidden: + await ctx.send(":x: *I was not able to message you, please allow server DMs so that I can send your user data file privately.*") + except FileNotFoundError: + await ctx.send(":x: *I could not find a user data file with your user ID. I think you should create your file first before exporting it.*") f = open("token", "r") token = f.read() From 84aa4b33bb8cba37191d233fc3f4c016161243dd Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Wed, 30 Nov 2022 00:02:11 -0500 Subject: [PATCH 3/8] miscellaneous changes - prefixes are now an array - botName variable created - any mentions of using a command now are formated to use the first specified prefix in the prefixes array - init command has been changed into the reinit command. init was kinda useless since you could create a file by making a proxy anyway. now it only is used to purging your user data file. - attaching an image to the register command for setting the avatar is now possible --- main.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/main.py b/main.py index 189f8b4..2b28007 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,12 @@ modified = False respositoryLink = "https://github.com/BurningInfern0/Uranium" +# please keep this in an array +prefixes = ["np.", "Np."] + +# mainly for the about section +botName = "Neptunium" + # initialization try: f = open("token", "r") @@ -34,8 +40,6 @@ intents = discord.Intents.default() intents.message_content = True -prefixes = "np.", "Np." - async def obtainWebhookData(ctx, channelID): # check if channel webhook exists in local database direc = os.listdir("./webhook-data/") @@ -61,7 +65,7 @@ async def obtainWebhookData(ctx, channelID): async def on_ready(): print(f'[URANIUM] I have logged in as {uranium.user}!') - game = discord.Game("with proxies! | np.help") + game = discord.Game("with proxies! | {0}help".format(prefixes[0])) await uranium.change_presence(status=discord.Status.online, activity=game) # await uranium.process_commands(message) @@ -69,30 +73,27 @@ async def on_ready(): @uranium.command() async def about(ctx): embedVar = discord.Embed( - title="About Neptunium", description="Neptunium is a Discord bot that is used for roleplay and for use in systems/plurality.", color=0x00fff4 + title="About {0}".format(botName), description="{0} is a Discord bot that is used for roleplay and for use in systems/plurality.".format(botName), color=0x00fff4 ) if modified == True: embedVar.add_field(name="Warning:", value="*The owner of this bot has enabled the modified variable, which means this bot's code has been modified and put up for public use. A valid respository link for this code will be provided at the bottom.*", inline=False) embedVar.set_footer(text="Created by BurningInfern0.") embedVar.set_image(url="https://user-images.githubusercontent.com/74492478/204309975-8b937ad8-99c1-40f1-a373-ce692873fada.png") - embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own Neptunium instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.", inline=False) + embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own {0} instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.".format(botName), inline=False) embedVar.add_field(name="GNU Affero General Public License v3", value="https://www.gnu.org/licenses/agpl-3.0.html", inline=False) embedVar.add_field(name="Repository Link", value=respositoryLink, inline=False) await ctx.send(embed=embedVar) -# all this does is create an empty CSV file for storing user proxy information. @uranium.group(invoke_without_command=True) -async def init(ctx): +async def reinit(ctx): databasePath = "./user-data/{0}.tsv".format(ctx.message.author.id) databaseExists = os.path.exists(databasePath) if databaseExists == True: - await ctx.send(":x: *Your database is already initialized, and exists.*\nIf you would like to initialize it again, **deleting all of your proxies and settings**, please do `u.init confirm`.") + await ctx.send(":grey_exclamation: *A database under your user ID has been found.*\nIf you would like to re-initalize it, this will **delete all of your current proxies and settings**.\n*Please note that you can export your user data via `{0}export` if you would like to.*\nIf you are sure you want to do this, please do `{0}reinit confirm`.".format(prefixes[0])) else: - databaseCreation = open(databasePath, "w") - databaseCreation.close() - await ctx.send(":white_check_mark: *Your database has been created and initialized. You can now create proxies.*") + await ctx.send(":x: *There is nothing to re-initialize.*") -@init.command() +@reinit.command() async def confirm(ctx): databasePath = "./user-data/{0}.tsv".format(ctx.message.author.id) os.remove(databasePath) @@ -103,17 +104,24 @@ async def confirm(ctx): @uranium.group(invoke_without_command=True, aliases=["p"]) async def proxy(ctx): - await ctx.send(":x: *Please provide a subcommand.*\nWhat do you want me to do with proxies? See `u.help proxy` for more information.") + await ctx.send(":x: *Please provide a subcommand.*\nWhat do you want me to do with proxies? See `{0}help proxy` for more information.".format(prefixes[0])) @proxy.command(description="register proxy") async def register(ctx, name:str, brackets:str): if len(name) > 80: await ctx.send(":x: *Your proxy's name is too long, please keep it equal to or under 80 characters.*") return + + try: + avatar = ctx.message.attachments[0] + proxyAvatar = avatar.url + except: + proxyAvatar = "*" + appendProxy = open("./user-data/{0}.tsv".format(ctx.message.author.id), "a") - appendProxy.write("{0}\t{1}\t*\n".format(brackets, name)) + appendProxy.write("{0}\t{1}\t{2}\n".format(brackets, name, proxyAvatar)) appendProxy.close() - await ctx.send("Wonderful! `{0}` has been created under your user data using the brackets `{1}`.\nTo send a message via this proxy, send `u.proxy send {1} I'm a proxy!`".format(name, brackets)) + await ctx.send("Wonderful! `{0}` has been created under your user data using the brackets `{1}`.\nTo send a message via this proxy, send `{2}proxy send {1} I'm a proxy!`".format(name, brackets, prefixes[0])) @proxy.command(description="delete a proxy") async def remove(ctx, name:str): From c169b436c014e04a5e102e1cf1c6857d7e68ff07 Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Wed, 30 Nov 2022 00:15:01 -0500 Subject: [PATCH 4/8] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2848e95..f4f13a1 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,8 @@ Or to put it bluntly, Uranium is designed to be an open source version of Tupper * `u.proxy avatar` * Sending proxy messages * `u.proxy send` -* Creating a user database - * `u.init` * Purging all data - * `u.init confirm` + * `u.reinit` * Proxy Dice Rolls * `u.proxy send Logan I cast fireball for {{2d6+5}} damage!` * Redirecting proxy messages to different channels @@ -47,6 +45,7 @@ Or to put it bluntly, Uranium is designed to be an open source version of Tupper * Questiom mark for proxy information * Sending images or files under a proxy * Proxies in Threads or Forums +* Replying using proxies ## Permissions From b346e33acbb0a8bb8a260e912bfcf9ceb058ec6d Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Wed, 30 Nov 2022 00:34:11 -0500 Subject: [PATCH 5/8] privacy policy command --- README.md | 3 +++ main.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index f4f13a1..9631384 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ Or to put it bluntly, Uranium is designed to be an open source version of Tupper * Multiproxies * Slash commands * Server specific settings + * Specific prefixes per server + * Logging + * Channel-specific permissions * Editing proxy messages * Showing information about a proxy message * Reactions on messages diff --git a/main.py b/main.py index 2b28007..bb82157 100644 --- a/main.py +++ b/main.py @@ -251,6 +251,18 @@ async def export(ctx): except FileNotFoundError: await ctx.send(":x: *I could not find a user data file with your user ID. I think you should create your file first before exporting it.*") +@uranium.command() +async def data(ctx): + embedVar = discord.Embed( + title="{0} and your data.".format(botName), description="What does {0} exactly do with data it obtains?".format(botName), color=0x00fff4 + ) + embedVar.set_footer(text="Last updated November 30th, 2022.") + embedVar.add_field(name="User data", value="This bot stores your user ID (this is to help identify which file belongs to who) and the proxies you create via the information you provide.\nThis information is exportable via the bot's export command.", inline=False) + embedVar.add_field(name="Webhook data", value="This bot stores webhook ID data under a channel ID filename, to help keep a local value for comparison to send proxies via webhooks.", inline=False) + embedVar.add_field(name="Channel data", value="This bot stores channel IDs as filenames for help in identifying the webhook ID for the channel you are sending the proxy to.", inline=False) + embedVar.add_field(name="Who can see this data?", value="It depends. All information can only be read by the bot host(s), with the exception of user data, which can be viewed at the user's request.", inline=False) + await ctx.send(embed=embedVar) + f = open("token", "r") token = f.read() uranium.run(token) \ No newline at end of file From 30706787c42f61f6e9f29e1fd3033dc27fc701ca Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Wed, 30 Nov 2022 18:09:26 -0500 Subject: [PATCH 6/8] settings file --- main.py | 31 ++++++++++--------------------- settings.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 settings.py diff --git a/main.py b/main.py index bb82157..c32c6cd 100644 --- a/main.py +++ b/main.py @@ -8,19 +8,8 @@ # import tsv editing commands from tsv import removeProxy, getProxyAvatar, parseProxy, setProxyAvatar -# YOU MUST SET THESE OPTIONS IF YOU ARE MODIFYING THIS CODE AND HOSTING IT!!!! -# As according to the GNU Affero General Public License version 3, network use of this application counts as DISTRIBUTION. -# If distribution occurs, you MUST disclose the source code in a PUBLIC repository where your changes to the code are STATED, and must follow and include the same license as the GNU AGPL v3. -modified = False -respositoryLink = "https://github.com/BurningInfern0/Uranium" - -# please keep this in an array -prefixes = ["np.", "Np."] - -# mainly for the about section -botName = "Neptunium" - # initialization +import settings try: f = open("token", "r") tokenTest = f.read() @@ -59,13 +48,13 @@ async def obtainWebhookData(ctx, channelID): webhookStore.close() return webhookID -uranium = commands.Bot(command_prefix=prefixes, intents=intents) +uranium = commands.Bot(command_prefix=settings.prefixes, intents=intents) @uranium.event async def on_ready(): print(f'[URANIUM] I have logged in as {uranium.user}!') - game = discord.Game("with proxies! | {0}help".format(prefixes[0])) + game = discord.Game("with proxies! | {0}help".format(settings.prefixes[0])) await uranium.change_presence(status=discord.Status.online, activity=game) # await uranium.process_commands(message) @@ -73,15 +62,15 @@ async def on_ready(): @uranium.command() async def about(ctx): embedVar = discord.Embed( - title="About {0}".format(botName), description="{0} is a Discord bot that is used for roleplay and for use in systems/plurality.".format(botName), color=0x00fff4 + title="About {0}".format(settings.botName), description="{0} is a Discord bot that is used for roleplay and for use in systems/plurality.".format(settings.botName), color=0x00fff4 ) - if modified == True: + if settings.modified == True: embedVar.add_field(name="Warning:", value="*The owner of this bot has enabled the modified variable, which means this bot's code has been modified and put up for public use. A valid respository link for this code will be provided at the bottom.*", inline=False) embedVar.set_footer(text="Created by BurningInfern0.") embedVar.set_image(url="https://user-images.githubusercontent.com/74492478/204309975-8b937ad8-99c1-40f1-a373-ce692873fada.png") - embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own {0} instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.".format(botName), inline=False) + embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own {0} instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.".format(settings.botName), inline=False) embedVar.add_field(name="GNU Affero General Public License v3", value="https://www.gnu.org/licenses/agpl-3.0.html", inline=False) - embedVar.add_field(name="Repository Link", value=respositoryLink, inline=False) + embedVar.add_field(name="Repository Link", value=settings.respositoryLink, inline=False) await ctx.send(embed=embedVar) @uranium.group(invoke_without_command=True) @@ -89,7 +78,7 @@ async def reinit(ctx): databasePath = "./user-data/{0}.tsv".format(ctx.message.author.id) databaseExists = os.path.exists(databasePath) if databaseExists == True: - await ctx.send(":grey_exclamation: *A database under your user ID has been found.*\nIf you would like to re-initalize it, this will **delete all of your current proxies and settings**.\n*Please note that you can export your user data via `{0}export` if you would like to.*\nIf you are sure you want to do this, please do `{0}reinit confirm`.".format(prefixes[0])) + await ctx.send(":grey_exclamation: *A database under your user ID has been found.*\nIf you would like to re-initalize it, this will **delete all of your current proxies and settings**.\n*Please note that you can export your user data via `{0}export` if you would like to.*\nIf you are sure you want to do this, please do `{0}reinit confirm`.".format(settings.prefixes[0])) else: await ctx.send(":x: *There is nothing to re-initialize.*") @@ -104,7 +93,7 @@ async def confirm(ctx): @uranium.group(invoke_without_command=True, aliases=["p"]) async def proxy(ctx): - await ctx.send(":x: *Please provide a subcommand.*\nWhat do you want me to do with proxies? See `{0}help proxy` for more information.".format(prefixes[0])) + await ctx.send(":x: *Please provide a subcommand.*\nWhat do you want me to do with proxies? See `{0}help proxy` for more information.".format(settings.prefixes[0])) @proxy.command(description="register proxy") async def register(ctx, name:str, brackets:str): @@ -121,7 +110,7 @@ async def register(ctx, name:str, brackets:str): appendProxy = open("./user-data/{0}.tsv".format(ctx.message.author.id), "a") appendProxy.write("{0}\t{1}\t{2}\n".format(brackets, name, proxyAvatar)) appendProxy.close() - await ctx.send("Wonderful! `{0}` has been created under your user data using the brackets `{1}`.\nTo send a message via this proxy, send `{2}proxy send {1} I'm a proxy!`".format(name, brackets, prefixes[0])) + await ctx.send("Wonderful! `{0}` has been created under your user data using the brackets `{1}`.\nTo send a message via this proxy, send `{2}proxy send {1} I'm a proxy!`".format(name, brackets, settings.prefixes[0])) @proxy.command(description="delete a proxy") async def remove(ctx, name:str): diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..5d7a21a --- /dev/null +++ b/settings.py @@ -0,0 +1,11 @@ +# YOU MUST SET THESE OPTIONS IF YOU ARE MODIFYING THIS CODE AND HOSTING IT!!!! +# As according to the GNU Affero General Public License version 3, network use of this application counts as DISTRIBUTION. +# If distribution occurs, you MUST disclose the source code in a PUBLIC repository where your changes to the code are STATED, and must follow and include the same license as the GNU AGPL v3. +modified = False +respositoryLink = "https://github.com/BurningInfern0/Uranium" + +# please keep this in an array +prefixes = ["u.", "U."] + +# mainly for the about section +botName = "Uranium" \ No newline at end of file From edc1f7bc2f762fd3c570130bef92849665de8b2e Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Wed, 30 Nov 2022 18:10:17 -0500 Subject: [PATCH 7/8] oopsies --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index c32c6cd..3e90588 100644 --- a/main.py +++ b/main.py @@ -41,7 +41,7 @@ async def obtainWebhookData(ctx, channelID): # if not, create and store it else: channel = uranium.get_channel(int(channelID)) - webhookID = await channel.create_webhook(name="Neptunium Proxy Webhook") + webhookID = await channel.create_webhook(name="Uranium Proxy Webhook") webhookPath = "./webhook-data/{0}".format(str(channelID)) webhookStore = open(webhookPath, "w") webhookStore.write(str(webhookID)) From ca84a05cd6312f192d56cf71d5b109db57a19aba Mon Sep 17 00:00:00 2001 From: BurningInfern0 Date: Wed, 30 Nov 2022 18:13:40 -0500 Subject: [PATCH 8/8] silly me, i keep forgetting things --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 3e90588..dae47ca 100644 --- a/main.py +++ b/main.py @@ -67,7 +67,7 @@ async def about(ctx): if settings.modified == True: embedVar.add_field(name="Warning:", value="*The owner of this bot has enabled the modified variable, which means this bot's code has been modified and put up for public use. A valid respository link for this code will be provided at the bottom.*", inline=False) embedVar.set_footer(text="Created by BurningInfern0.") - embedVar.set_image(url="https://user-images.githubusercontent.com/74492478/204309975-8b937ad8-99c1-40f1-a373-ce692873fada.png") + embedVar.set_image(url="https://user-images.githubusercontent.com/74492478/203663460-6863d8e6-66d8-4379-8fe9-aba48de15262.png") embedVar.add_field(name="Did you know the bot is open source?", value="That means **anyone** can view the source code, or how the bot works. You can change/add/remove what you want, and self host your own {0} instance. But remember, if you distribute your personal code, you **must** follow the terms and conditions of the GNU Affero General Public Licence v3.".format(settings.botName), inline=False) embedVar.add_field(name="GNU Affero General Public License v3", value="https://www.gnu.org/licenses/agpl-3.0.html", inline=False) embedVar.add_field(name="Repository Link", value=settings.respositoryLink, inline=False)