Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50fae484b8 | ||
|
|
f4b9d942a5 | ||
|
|
9456a61a3d | ||
|
|
3d7cc1a6d1 | ||
|
|
42dc001287 | ||
|
|
219ae5fc35 |
No files matched your search
@@ -1,20 +1,13 @@
|
||||
# Among Us regionInfo.dat creator
|
||||
# among-us-region-info-py
|
||||
|
||||
This is a simple python script to generate the regionInfo file needed for custom servers in Among Us.
|
||||

|
||||

|
||||
[](https://github.com/alvesaren/among-us-region-info-py)
|
||||
[](https://git-nb1x.freeddns.org)
|
||||
|
||||
## Why?
|
||||
|
||||
Compared to most other scripts and programs which all create the same regionInfo file, this program allows you to change the name that shows up in the bottom when in Among Us.
|
||||
A simple Python script to generate the regionInfo.dat file, required to add regions to old versions of Among Us.
|
||||
|
||||
I've also tried to make the code as readable and simple as possible.
|
||||
This is a fork of the original project: https://github.com/alvesvaren/among-us-region-info-py with a simple GUI.
|
||||
|
||||
## Basic usage:
|
||||
|
||||
```sh
|
||||
python main.py "Server name" 127.0.0.1
|
||||
```
|
||||
|
||||
This will generate a file called regionInfo.dat in your current folder, which could then be placed at:
|
||||
`C:\Users\username\AppData\LocalLow\Innersloth\Among Us\regionInfo.dat`
|
||||
|
||||
This could for example be used to create a custom name for the server when using the [Impostor server](https://github.com/AeonLucid/Impostor) for among us
|
||||

|
||||
@@ -1,45 +1,47 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from sys import argv
|
||||
import tkinter as tk
|
||||
from tkinter import ttk, messagebox
|
||||
import socket
|
||||
|
||||
# Currently the only possible value
|
||||
SERVER_SUFFIX = "-Master-1"
|
||||
|
||||
|
||||
def gen_stream(region_name: str, ip_address: str = "127.0.0.1", port: int = 22023) -> bytearray:
|
||||
"""
|
||||
Generates the bytearray with the specified values.
|
||||
Port should currently always be 22023 for it to work
|
||||
"""
|
||||
|
||||
server_name = region_name + SERVER_SUFFIX
|
||||
|
||||
# Make sure all variables are within the correct length range
|
||||
if (len(server_name) > 0xff):
|
||||
if len(server_name) > 0xff:
|
||||
raise ValueError("Region name too long")
|
||||
if (len(ip_address) > 0xff):
|
||||
if len(ip_address) > 0xff:
|
||||
raise ValueError("IP-address too long")
|
||||
if (port > 0x7fff):
|
||||
if port > 0x7fff:
|
||||
raise ValueError("Port too high")
|
||||
|
||||
# Append region name
|
||||
data = bytearray(len(region_name).to_bytes(5, "big"))
|
||||
data += region_name.encode("ascii")
|
||||
|
||||
# Append ip address
|
||||
data.append(len(ip_address))
|
||||
data += ip_address.encode("ascii")
|
||||
data.extend(0x1.to_bytes(4, "little"))
|
||||
|
||||
# Append server name
|
||||
data.append(len(server_name))
|
||||
data += server_name.encode("ascii")
|
||||
|
||||
# Append ip address in byte form
|
||||
try:
|
||||
ip_address_bytes = bytearray()
|
||||
for value in ip_address.split("."):
|
||||
ip_address_bytes.append(int(value))
|
||||
except (ValueError, AttributeError):
|
||||
try:
|
||||
resolved_ip = socket.gethostbyname(ip_address)
|
||||
ip_address_bytes = bytearray()
|
||||
for value in resolved_ip.split("."):
|
||||
ip_address_bytes.append(int(value))
|
||||
except socket.gaierror:
|
||||
raise ValueError(f"Invalid IP address or hostname: {ip_address}")
|
||||
|
||||
data += ip_address_bytes
|
||||
|
||||
data.extend(port.to_bytes(2, "little"))
|
||||
data.extend(0x0.to_bytes(4, "big"))
|
||||
|
||||
@@ -47,49 +49,123 @@ def gen_stream(region_name: str, ip_address: str = "127.0.0.1", port: int = 2202
|
||||
|
||||
|
||||
def write_file(region_name: str, ip_address: str = "127.0.0.1", file_name: str = "regionInfo.dat", port: int = 22023, *, log_bytes=False):
|
||||
"""
|
||||
Creates and writes the among us regionInfo.dat file.
|
||||
Port should currently always be 22023 for it to work
|
||||
|
||||
|
||||
Example:
|
||||
```py
|
||||
try:
|
||||
write_file("Example server", "127.0.0.1", port=12345))
|
||||
print("Success!")
|
||||
except Exception as error:
|
||||
print(error)
|
||||
```
|
||||
"""
|
||||
|
||||
# Generate the file and save to the specified file name
|
||||
data = gen_stream(region_name, ip_address, port)
|
||||
with open(file_name, "wb") as file:
|
||||
file.write(data)
|
||||
|
||||
# Log the bytes to stdout if specified
|
||||
if (log_bytes):
|
||||
if log_bytes:
|
||||
print("Writing", content_from_stream(data), "to", file_name)
|
||||
return content_from_stream(data)
|
||||
return None
|
||||
|
||||
|
||||
def content_from_stream(stream: bytearray) -> str:
|
||||
"""
|
||||
Create a string with the bytes in 'stream'
|
||||
"""
|
||||
hex_array = []
|
||||
for byte in stream:
|
||||
hex_array.append(hex(byte))
|
||||
return "{" + ", ".join(hex_array) + "}"
|
||||
return f"{{{', '.join(hex_array)}}}"
|
||||
|
||||
|
||||
class AmongUsRegionCreator:
|
||||
def __init__(self):
|
||||
self.window = tk.Tk()
|
||||
self.window.title("Among Us Region Creator")
|
||||
self.window.geometry("550x450")
|
||||
self.window.resizable(False, False)
|
||||
|
||||
main_frame = ttk.Frame(self.window, padding="10")
|
||||
main_frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S))
|
||||
|
||||
title_label = ttk.Label(main_frame, text="Among Us Custom Server Creator", font=("Arial", 14, "bold"))
|
||||
title_label.grid(row=0, column=0, columnspan=2, pady=(0, 20))
|
||||
|
||||
ttk.Label(main_frame, text="Region Name:").grid(row=1, column=0, sticky=tk.W, pady=5)
|
||||
self.region_entry = ttk.Entry(main_frame, width=30)
|
||||
self.region_entry.grid(row=1, column=1, pady=5, padx=(10, 0))
|
||||
self.region_entry.insert(0, "EU")
|
||||
|
||||
ttk.Label(main_frame, text="IP / Domain:").grid(row=2, column=0, sticky=tk.W, pady=5)
|
||||
self.ip_entry = ttk.Entry(main_frame, width=30)
|
||||
self.ip_entry.grid(row=2, column=1, pady=5, padx=(10, 0))
|
||||
self.ip_entry.insert(0, "127.0.0.1")
|
||||
|
||||
ttk.Label(main_frame, text="Port:").grid(row=3, column=0, sticky=tk.W, pady=5)
|
||||
self.port_entry = ttk.Entry(main_frame, width=30)
|
||||
self.port_entry.grid(row=3, column=1, pady=5, padx=(10, 0))
|
||||
self.port_entry.insert(0, "22023")
|
||||
|
||||
ttk.Label(main_frame, text="File Name:").grid(row=4, column=0, sticky=tk.W, pady=5)
|
||||
self.file_entry = ttk.Entry(main_frame, width=30)
|
||||
self.file_entry.grid(row=4, column=1, pady=5, padx=(10, 0))
|
||||
self.file_entry.insert(0, "regionInfo.dat")
|
||||
|
||||
self.create_button = ttk.Button(main_frame, text="Create File", command=self.create_file, width=20)
|
||||
self.create_button.grid(row=5, column=0, columnspan=2, pady=20)
|
||||
|
||||
ttk.Label(main_frame, text="Output:").grid(row=6, column=0, sticky=tk.W, pady=5)
|
||||
self.output_text = tk.Text(main_frame, height=10, width=60, font=("Courier", 9))
|
||||
self.output_text.grid(row=7, column=0, columnspan=2, pady=5)
|
||||
self.output_text.config(state=tk.DISABLED)
|
||||
|
||||
self.status_label = ttk.Label(main_frame, text="Ready", foreground="green")
|
||||
self.status_label.grid(row=8, column=0, columnspan=2, pady=10)
|
||||
|
||||
self.window.bind('<Return>', lambda event: self.create_file())
|
||||
|
||||
def create_file(self):
|
||||
try:
|
||||
region_name = self.region_entry.get().strip()
|
||||
ip_address = self.ip_entry.get().strip()
|
||||
port = int(self.port_entry.get().strip())
|
||||
file_name = self.file_entry.get().strip()
|
||||
|
||||
if not region_name:
|
||||
raise ValueError("Region name cannot be empty")
|
||||
if not ip_address:
|
||||
raise ValueError("IP address/Domain cannot be empty")
|
||||
if not file_name:
|
||||
raise ValueError("File name cannot be empty")
|
||||
|
||||
result = write_file(region_name, ip_address, file_name, port, log_bytes=True)
|
||||
|
||||
self.output_text.config(state=tk.NORMAL)
|
||||
self.output_text.delete(1.0, tk.END)
|
||||
self.output_text.insert(1.0, f"File created successfully!\n\nBytes written:\n{result}")
|
||||
self.output_text.config(state=tk.DISABLED)
|
||||
|
||||
self.status_label.config(text=f"File '{file_name}' created successfully!", foreground="green")
|
||||
messagebox.showinfo("Success", f"File '{file_name}' has been created successfully!")
|
||||
|
||||
except ValueError as e:
|
||||
self.output_text.config(state=tk.NORMAL)
|
||||
self.output_text.delete(1.0, tk.END)
|
||||
self.output_text.insert(1.0, f"Error: {str(e)}")
|
||||
self.output_text.config(state=tk.DISABLED)
|
||||
|
||||
self.status_label.config(text="Error occurred", foreground="red")
|
||||
messagebox.showerror("Error", str(e))
|
||||
|
||||
except Exception as e:
|
||||
self.output_text.config(state=tk.NORMAL)
|
||||
self.output_text.delete(1.0, tk.END)
|
||||
self.output_text.insert(1.0, f"Unexpected error: {str(e)}")
|
||||
self.output_text.config(state=tk.DISABLED)
|
||||
|
||||
self.status_label.config(text="Error occurred", foreground="red")
|
||||
messagebox.showerror("Error", f"An unexpected error occurred:\n{str(e)}")
|
||||
|
||||
def run(self):
|
||||
self.window.mainloop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if (len(argv) < 2):
|
||||
print('Usage: python main.py <name> [ip-address] [file-name] [port]')
|
||||
print('Example: python main.py "Server name" 127.0.0.1')
|
||||
exit(1)
|
||||
if len(argv) > 1:
|
||||
print(f"Creating file using arguments '{', '.join(argv[1:])}'")
|
||||
try:
|
||||
write_file(*argv[1:], log_bytes=True)
|
||||
except Exception as error:
|
||||
print("Error:", error)
|
||||
exit(2)
|
||||
exit(1)
|
||||
else:
|
||||
app = AmongUsRegionCreator()
|
||||
app.run()
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in new issue
Block a user