0% found this document useful (0 votes)
36 views6 pages

Roblox Item Purchase Automation Script

The document is a Python script that automates the purchasing of items on the Roblox platform using a Discord bot. It includes functions for retrieving messages, extracting IDs, and handling user authentication, as well as displaying user information and purchase statistics. The script utilizes the requests library for API interactions and employs color formatting for console output.

Uploaded by

angeljay920
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views6 pages

Roblox Item Purchase Automation Script

The document is a Python script that automates the purchasing of items on the Roblox platform using a Discord bot. It includes functions for retrieving messages, extracting IDs, and handling user authentication, as well as displaying user information and purchase statistics. The script utilizes the requests library for API interactions and employs color formatting for console output.

Uploaded by

angeljay920
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import json

import requests
import time
import re
import uuid
from rgbprint import gradient_print
import os
from colorama import Fore, Back, Style

buys = 0
errors = 0
check_count = 0
session = requests.session()
start_time = time.time()
run_time = "0:00" # Placeholder for run time
item_id = 0
current_item_status = "Nothing"

def clear_console():
os.system('cls' if os.name == 'nt' else 'clear')
def load_config():
with open("config.json", "r") as config_file:
return json.load(config_file)

config = load_config()

session.cookies['.ROBLOSECURITY'] = config.get("roblox_token")

watchspeed = 0.75
chanelid = config.get("channel_id")

def retrieve_latest_message(channel_id, bot_token):


headers = {
'authorization': bot_token
}
params = {
'limit': 1
}

try:
r =
requests.get(f'https://discord.com/api/v8/channels/{channel_id}/messages',
headers=headers, params=params)
r.raise_for_status()
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}")
return None
except requests.exceptions.RequestException as req_err:
print(f"Request error occurred: {req_err}")
return None

try:
message = r.json()[0]
except json.JSONDecodeError as json_err:
print("JSON decode error:", json_err)
return None
except IndexError as idx_err:
print("No messages found:", idx_err)
return None

return message

def extract_id_from_url(url, pattern):


id_start = url.find(pattern) + len(pattern)
id_end = url.find('&', id_start)
if id_end == -1:
id_end = len(url)
return ''.join([c for c in url[id_start:id_end] if c.isdigit()])

def extract_game_id(embed):
website_pattern = re.compile(r"Get in-game without captcha!")

possible_fields = [
embed.get('description', '')
]

for field in possible_fields:


if field:
match = website_pattern.search(field)
if match:
return 14056754882

return None

token = None
def _set_auth():
global token, session
try:
conn = session.post("https://auth.roblox.com/v2/logout")
if conn.headers.get("x-csrf-token"):
token = conn.headers["x-csrf-token"]
#print(token)
except:
time.sleep(5)
return _set_auth()

_set_auth()
headersxd = {
'Content-Type': 'application/json',
"x-csrf-token": token
}
def get_user_info():
response = session.get("https://users.roblox.com/v1/users/authenticated")
data = response.json()
if data.get('id') is None or data.get('name') is None:
raise Exception("Couldn't scrape user info. Error:", data)
return {"user_id": data.get('id'), "name": data.get("name")}
player_name = get_user_info()["name"]
player_id = get_user_info()["user_id"]

def print_info():
gradient_print('''

ΓûêΓûêΓûêΓûêΓûêΓûêΓòùΓûæΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓòùΓûêΓûêΓûêΓûêΓûêΓûêΓòùΓûæΓûêΓûêΓûêΓû
êΓûêΓûêΓòùΓûæΓûêΓûêΓòùΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòùΓûæΓûæΓûæΓûêΓûêΓòùΓûêΓûêΓûêΓûêΓûêΓûêΓ
ûêΓòù

ΓûêΓûêΓòöΓòÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòöΓòÉΓòÉΓòÉΓòÉΓò¥ΓûêΓûêΓòöΓòÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòöΓò
ÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòæΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòæΓûæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓòöΓòÉΓòÉΓòÉΓ
òÉΓò¥

ΓûêΓûêΓûêΓûêΓûêΓûêΓòöΓò¥ΓûêΓûêΓûêΓûêΓûêΓòùΓûæΓûæΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓûêΓû
êΓûêΓûêΓòªΓò¥ΓûêΓûêΓòæΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòæΓûæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓûêΓûêΓûêΓòùΓ
ûæΓûæ

ΓûêΓûêΓòöΓòÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòöΓòÉΓòÉΓò¥ΓûæΓûæΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓòöΓò
ÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòæΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòæΓûæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓòöΓòÉΓòÉΓò¥Γ
ûæΓûæ

ΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓòùΓûêΓûêΓûêΓûêΓûêΓûêΓòöΓò¥ΓûêΓûêΓûêΓû
êΓûêΓûêΓòªΓò¥ΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓòùΓòÜΓûêΓûêΓûêΓûêΓûêΓûêΓòöΓò¥ΓûêΓûêΓûêΓûêΓûêΓûêΓ
ûêΓòù

ΓòÜΓòÉΓò¥ΓûæΓûæΓòÜΓòÉΓò¥ΓòÜΓòÉΓòÉΓòÉΓòÉΓòÉΓòÉΓò¥ΓòÜΓòÉΓòÉΓòÉΓòÉΓòÉΓò¥ΓûæΓòÜΓòÉΓòÉΓò
ÉΓòÉΓòÉΓò¥ΓûæΓòÜΓòÉΓòÉΓòÉΓòÉΓòÉΓòÉΓò¥ΓûæΓòÜΓòÉΓòÉΓòÉΓòÉΓòÉΓò¥ΓûæΓòÜΓòÉΓòÉΓòÉΓòÉΓòÉΓ
òÉΓò¥

ΓûêΓûêΓûêΓûêΓûêΓûêΓòùΓûæΓûæΓûêΓûêΓûêΓûêΓûêΓòùΓûæΓûêΓûêΓòùΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòùΓû
êΓûêΓûêΓòùΓûæΓûæΓûæΓûêΓûêΓûêΓòùΓûæΓûêΓûêΓûêΓûêΓûêΓòùΓûæΓûêΓûêΓûêΓòùΓûæΓûæΓûêΓûêΓòùΓ
ûæΓûêΓûêΓûêΓûêΓûêΓûêΓòù

ΓûêΓûêΓòöΓòÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòöΓòÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòæΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòæΓû
êΓûêΓûêΓûêΓòùΓûæΓûêΓûêΓûêΓûêΓòæΓûêΓûêΓòöΓòÉΓòÉΓûêΓûêΓòùΓûêΓûêΓûêΓûêΓòùΓûæΓûêΓûêΓòæΓ
ûêΓûêΓòöΓòÉΓòÉΓòÉΓòÉΓò¥

ΓûêΓûêΓûêΓûêΓûêΓûêΓòöΓò¥ΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓòæΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòæΓû
êΓûêΓòöΓûêΓûêΓûêΓûêΓòöΓûêΓûêΓòæΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓòöΓûêΓûêΓòùΓûêΓûêΓòæΓ
òÜΓûêΓûêΓûêΓûêΓûêΓòùΓûæ

ΓûêΓûêΓòöΓòÉΓòÉΓûêΓûêΓòùΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓòæΓûæΓûæΓûæΓûæΓûæΓûêΓûêΓòæΓû
êΓûêΓòæΓòÜΓûêΓûêΓòöΓò¥ΓûêΓûêΓòæΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓûêΓûêΓòæΓòÜΓûêΓûêΓûêΓûêΓòæΓ
ûæΓòÜΓòÉΓòÉΓòÉΓûêΓûêΓòù

ΓûêΓûêΓòæΓûæΓûæΓûêΓûêΓòæΓòÜΓûêΓûêΓûêΓûêΓûêΓòöΓò¥ΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓòùΓûêΓûêΓòæΓû
êΓûêΓòæΓûæΓòÜΓòÉΓò¥ΓûæΓûêΓûêΓòæΓòÜΓûêΓûêΓûêΓûêΓûêΓòöΓò¥ΓûêΓûêΓòæΓûæΓòÜΓûêΓûêΓûêΓòæΓ
ûêΓûêΓûêΓûêΓûêΓûêΓòöΓò¥

ΓòÜΓòÉΓò¥ΓûæΓûæΓòÜΓòÉΓò¥ΓûæΓòÜΓòÉΓòÉΓòÉΓòÉΓò¥ΓûæΓòÜΓòÉΓòÉΓòÉΓòÉΓòÉΓòÉΓò¥ΓòÜΓòÉΓò¥Γò
ÜΓòÉΓò¥ΓûæΓûæΓûæΓûæΓûæΓòÜΓòÉΓò¥ΓûæΓòÜΓòÉΓòÉΓòÉΓòÉΓò¥ΓûæΓòÜΓòÉΓò¥ΓûæΓûæΓòÜΓòÉΓòÉΓò¥Γ
òÜΓòÉΓòÉΓòÉΓòÉΓòÉΓò¥Γûæ\n''', start_color=(0xFF0000), end_color=(0x0000FF))

gradient_print(" ~------------ [MAIN]


------------~", start_color=(0xFF0000), end_color=(0x0000FF))
print(Style.BRIGHT + f" [ Username:
{Fore.RED}{Style.BRIGHT}{player_name}{Fore.WHITE}{Style.BRIGHT} ]")
print(Style.BRIGHT + f" [ ID: {Fore.BLUE}
{Style.BRIGHT}{player_id}{Fore.WHITE}{Style.BRIGHT} ]")
print(Style.BRIGHT + f" [ Total Checks:
{Fore.RED}{Style.BRIGHT}{check_count}{Fore.WHITE}{Style.BRIGHT} ]")
print(Style.BRIGHT + f" [ Run Time:
{Fore.BLUE}{Style.BRIGHT}{run_time}{Fore.WHITE}{Style.BRIGHT} ]")
gradient_print(" ~----------- [CONFIG]
-----------~", start_color=(0xFF0000), end_color=(0x0000FF))
print(Style.BRIGHT + f" [ Config Speed:
{Fore.RED}{Style.BRIGHT}{str(watchspeed)}{Fore.WHITE}{Style.BRIGHT} ]")
print(Style.BRIGHT + f" [ Discord Channel
ID: {Fore.BLUE}{Style.BRIGHT}{chanelid}{Fore.WHITE}{Style.BRIGHT} ]")

gradient_print(" ~------------ [INFO]


------------~", start_color=(0xFF0000), end_color=(0x0000FF))
print(Style.BRIGHT + f" [ Current Item
ID: {Fore.RED}{Style.BRIGHT}{item_id}{Fore.WHITE}{Style.BRIGHT} ]")
print(Style.BRIGHT + f" [ Item Status:
{Fore.BLUE}{Style.BRIGHT}{current_item_status}{Fore.WHITE}{Style.BRIGHT} ]")
print(Style.BRIGHT + f" [ Total Attempted
Purchases: {Fore.RED}{Style.BRIGHT}{buys}{Fore.WHITE}{Style.BRIGHT} ]")
print(Style.BRIGHT + f" [ Purchase
Errors: {Fore.BLUE}{Style.BRIGHT}{errors}{Fore.WHITE}{Style.BRIGHT} ]")

gradient_print(" ~------------ [LOGS]


------------~", start_color=(0xFF0000), end_color=(0x0000FF))

def buy_item(info):
global buys,errors
cookie_info = get_user_info()
config = load_config()
data = {
"collectibleItemId": info["collectibleItemId"],
"expectedCurrency": 1,
"expectedPrice": info['price'],
"expectedPurchaserId": cookie_info['user_id'],
"expectedPurchaserType": "User",
"expectedSellerId": info["creator"],
"expectedSellerType": info["type"],
"idempotencyKey": str(uuid.uuid4()),
"collectibleProductId": info['productid_data'],
}
print("buy thread started")
buys += 1
for i in range(10):
try:
response = session.post(

f"https://apis.roblox.com/marketplace-sales/v1/item/{info['collectibleItemId']}/
purchase-item",
json=data,
headers={"x-csrf-token": token, 'Accept-Encoding': 'gzip',
'Connection': 'keep-alive'},
cookies={".ROBLOSECURITY": config.get('roblox_token')}
)
response.raise_for_status()
print(f"Attempt {i+1}: Purchasing..")
break
except requests.exceptions.RequestException as e:
errors += 1
print(f"Attempt {i+1}: Purchase failed - {e}")
data["idempotencyKey"] = str(uuid.uuid4())
def extract_item_id(embed):
possible_fields = [embed.get('url', ''), embed.get('description', ''),
embed.get('title', '')]
for field in embed.get('fields', []):
possible_fields.append(field.get('value', ''))
for field in possible_fields:
if "https://www.roblox.com/catalog/" in field:
return extract_id_from_url(field, "https://www.roblox.com/catalog/")
return None

def print_colored_message(message, color_code):


print(f"\033[{color_code}m{message}\033[0m")

def main():
config = load_config()
bot_token = config.get('bot_token')
channel_id = config.get('channel_id')

if not bot_token or not channel_id:


print("Error: bot_token or channel_id not found in config.json")
return

global check_count,current_item_status,run_time,item_id
processed_message_ids = []

try:
while True:

try:
latest_message = retrieve_latest_message(channel_id, bot_token)
if latest_message and latest_message['id'] not in
processed_message_ids:
processed_message_ids.append(latest_message['id'])
print(f"\nNew message found: {latest_message['id']}")

game_found = False
for embed in latest_message.get('embeds', []):
game_id = extract_game_id(embed)
item_id = extract_item_id(embed)

if game_id or item_id:
if game_id == 14056754882:
current_item_status = "Website"
if item_id:
try:
_set_auth()
iteminfoget =
session.get(f"https://economy.roblox.com/v2/assets/{str(item_id)}/details")
if iteminfoget.status_code == 200:
iteminfojson = iteminfoget.json()
iteminfo = {
"collectibleItemId":
iteminfojson["CollectibleItemId"],
"price":
iteminfojson['PriceInRobux'],
"creator": iteminfojson["Creator"]
["CreatorTargetId"],
"type": iteminfojson["Creator"]
["CreatorType"],
"productid_data":
iteminfojson["CollectibleProductId"],
}
buy_item(iteminfo)
print(f"Item ID: {item_id} found!")
except Exception as e:
print(f"Error processing item ID {item_id}:
{e}")
else:
current_item_status = "Not Website"

game_found = True
break

if not game_found:
print("No game found in the message")
except Exception as e:
print(f"Error retrieving or processing message: {e}")
finally:
check_count += 1
clear_console()
elapsed_time = time.time() - start_time
hours, remainder = divmod(elapsed_time, 3600)
minutes, seconds = divmod(remainder, 60)
run_time = f"{int(hours)}:{int(minutes):02d}:{int(seconds):02d}"
print_info()
time.sleep(watchspeed)

except KeyboardInterrupt:
print("Stopping...")

if __name__ == "__main__":
main()

You might also like