Help Creating Whitelist!

Hey everybody! I’m currently experimenting with something new for me which will be the HTTP service. I’m trying to create a whitelist that communicates between Roblox and GitHub. Basically, what I want to do is make it so that the script can check to see if someone is listed in the git repository, and also add/remove them from it.

The questions I have are how do I set up and code the repository to hold that data, how do I make those pull requests, and how do I make those push requests? I have no code to show cause I got no idea what I’m doing and Roblox Dev Hub isn’t too helpful on this one.

1 Like

Using GitHub doesn’t really make sense in this case. If you’d like a secure, easy to read and write text field, I recommend pastebin.com. It has extensive docs, and the developer hub even has a small tutorial area about it on this page (scroll to the bottom): HttpService | Roblox Creator Documentation

(swear I’m not advertising here)

1 Like

Okay well, how would I do this with pastebin? I’m not familiar at all with any of this and the Dev Hub is telling me that when you use post async it creates a brand new paste. I want to update the whitelist but Idk how to structure the paste, and how to update and pull data from it without creating new pastes every time.

So in the HttpService article we have this script:

local HttpService = game:GetService("HttpService")
 
local URL_PASTEBIN_NEW_PASTE = "https://pastebin.com/api/api_post.php"
local dataFields = {
	["api_dev_key"] = "FILL THIS WITH YOUR API DEVELOPER KEY";    
	["api_option"] = "paste";                             
	["api_paste_name"] = "HttpService:PostAsync";           
	["api_paste_code"] = "Hello, world";                   
	["api_paste_format"] = "text";                           
	["api_paste_expire_date"] = "10M";                           
	["api_paste_private"] = "0";                            
	["api_user_key"] = "";                               
}

local data = ""
for k, v in pairs(dataFields) do
	data = data .. ("&%s=%s"):format(
		HttpService:UrlEncode(k),
		HttpService:UrlEncode(v)
	)
end

data = data:sub(2)

local response = HttpService:PostAsync(URL_PASTEBIN_NEW_PASTE, data, Enum.HttpContentType.ApplicationUrlEncoded, false)

print(response)

I deleted the comments for readability.

If you go to Pastebin.com - Developers API, you’ll see there’s docs on how to use the API names as shown in the dictionary in the above script.

Just follow that and you’ll be able to post, edit, delete, make public or unlist, etc. your paste. I recommend creating one first and following the API on how to edit the paste.

Note you must have an account to edit your pastes.

Edit: link fixed @TridentXR

The api link doesn’t work. It says that it is not found.

It doesn’t explain editing pastes, nor do I understand api calls :joy: I honestly know nothing about networking as such so I need a full break down and teaching here. I would also appreciate some functioning code examples that do what I need so I can study them to reapply them.

I made this system for a Roblox browser (using its own URLs). I removed my dev and user keys but you can read to the pastebin with your own if you’d like:

local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local Rep = game:GetService("ReplicatedStorage")

local URL_PASTEBIN_READ = "https://pastebin.com/api/api_raw.php"
local dataFields = {
	["api_dev_key"] = "your_dev_key_here";
	["api_user_key"] = "your_user_key_here";
	["api_paste_key"] = "pQrJPmgx";
	["api_option"] = "show_paste"
}

local data = ""
for k, v in pairs(dataFields) do
	data = data .. ("&%s=%s"):format(
		HttpService:UrlEncode(k),
		HttpService:UrlEncode(v)
	)
end

data = data:sub(2)
local content = {}
local response = HttpService:PostAsync(URL_PASTEBIN_READ, data, Enum.HttpContentType.ApplicationUrlEncoded, false)
print(response)

It’s also not a very teachable concept, it’s kind of just one of those thigns where you have to learn the API of the website individually. The main things to remember are :PostAsync(0 and read the website’s API.

Wouldn’t you also use getasync for reading data?

Good question. I’m not actually sure if GetAsync does or not, but PostAsync does work here. You can try it if you’d like.

Where do I find a list of all the possible options for the postasync? I see show_paste. What else is there?

According to the docs, there’s:

  • show_paste
  • userdetails
  • delete
  • list

So there isn’t one for editing the paste?

Nope. Looks like we’re going to have to do a hacky way.

Whenever you want to “edit” a paste, retrieve all the contents of the existing paste, create a new one, transfer the contents of the old paste into the new one, and delete the old one.

This will probably only work if the size of this list is relatively small.

That won’t really work for a whitelisting system though. So inevitably this won’t work :joy:

What’s your exact use case, or rather, how many times do you figure you’ll be writing to the system a day?

So I’m whitelisting a product I’ve created. It’s a weapon system and I want to whitelist people. If they meet certain criteria determined in game, they can add the product to their games and if they are whitelisted (via the external database) they will have access and be able to use it in game. So the product itself will check to ensure that the user is whitelisted, and a game of my creation is where you can register a whitelist. So it needs to read and write to a database.

1 Like

In that case, you might want to go with a spreadsheet software or something similar. I’m not sure how to use any of those, so I can’t help much from here.

Why does this gotta be so complicated :joy:

2 Likes