Compare commits
30 changed files with 1815 additions and 1516 deletions
|
|
@ -7,19 +7,16 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ${{ vars.RUNNER_LABEL }}
|
runs-on: debian-bookworm
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: install docker???
|
- name: install docker???
|
||||||
run: |
|
run: apt update && apt install wget -y && wget "https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce-cli_29.2.1-1~debian.12~bookworm_amd64.deb" && dpkg --force-confold -i "docker-ce-cli_29.2.1-1~debian.12~bookworm_amd64.deb"
|
||||||
apt update && apt install wget cmake -y && \
|
|
||||||
wget "https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce-cli_29.2.1-1~debian.12~bookworm_amd64.deb" && \
|
|
||||||
dpkg --force-confold -i "docker-ce-cli_29.2.1-1~debian.12~bookworm_amd64.deb"
|
|
||||||
|
|
||||||
- name: set up Docker Buildx
|
- name: set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: login
|
- name: login
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
|
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -1,9 +1,6 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
.env
|
.env
|
||||||
boss.yaml
|
boss.yaml
|
||||||
fes_boss.yaml
|
|
||||||
node_modules
|
node_modules
|
||||||
build
|
build
|
||||||
splatnet_backend.egg-info
|
splatnet_backend.egg-info
|
||||||
venv/*
|
|
||||||
.venv/*
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
3.14
|
3.11
|
||||||
|
|
|
||||||
38
README.md
38
README.md
|
|
@ -3,8 +3,9 @@
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<img src="https://git.crafterpika.cc/kittentm/splatnet-backend/raw/branch/main/currentprogress.png" height=50px>
|
<img src="https://git.crafterpika.cc/kittentm/splatnet-backend/raw/branch/main/currentprogress.png" height=50px>
|
||||||
<img src="https://progress-bar.xyz/65?title=&height=20&show_text=false" width="100%" height=20px>
|
<img src="https://progress-bar.xyz/40?title=&height=20&show_text=false" width="100%" height=20px>
|
||||||
<br>
|
<br>
|
||||||
|
<strong>Basically 0% lol</strong>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -12,43 +13,33 @@
|
||||||
|
|
||||||
# SplatNet
|
# SplatNet
|
||||||
|
|
||||||

|
[](https://git.crafterpika.cc/kittentm/splatnet-backend/commits/branch/main)
|
||||||
[](https://git.crafterpika.cc/kittentm/splatnet-backend/actions)
|
[](https://git.crafterpika.cc/kittentm/splatnet-backend/actions)
|
||||||
[](https://git.crafterpika.cc/kittentm/splatnet-backend)
|
[](https://git.crafterpika.cc/kittentm/splatnet-backend)
|
||||||
[](https://git.crafterpika.cc/kittentm/splatnet-backend/src/branch/main/LICENSE)
|
[](https://git.crafterpika.cc/kittentm/splatnet-backend/src/branch/main/LICENSE)
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
This is the backend for the [SplatNet](https://git.crafterpika.cc/kittentm/splatnet) Revival frontend.
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
This is the backend for the [SplatNet](https://git.crafterpika.cc/kittentm/splatnet) Revival frontend. It is a combination of Python & JS.
|
||||||
|
|
||||||
## Self-hosting
|
## Self-hosting
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> This project is not easy to self host!! Please please please read the console logs before asking for help.
|
> This project is not easy to self host!! Please please please read the console logs before asking for help.
|
||||||
|
|
||||||
### Installing from source
|
### Running from source
|
||||||
|
|
||||||
|
To start, install Python `3.11+`. While newer versions aren't tested they should work fine. Dependencies are installed using
|
||||||
|
```
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
Telemetry is technically not required for the server to run, however it is required for most functions on the website. Judd is run via Node `/judd`. First change directories to Judd, and install the node modules.
|
Telemetry is technically not required for the server to run, however it is required for most functions on the website. Judd is run via Node `/judd`. First change directories to Judd, and install the node modules.
|
||||||
```
|
```
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
To start, install either Python `3.11` or `3.12`. While newer versions aren't tested they should work fine. Note that anything **ABOVE** 3.12 will require building oead from source, as it is a required dependency. View their documentation [here](https://oead.readthedocs.io/en/stable/about.html#building-from-source). Then install using:
|
|
||||||
```
|
|
||||||
pip install . -v
|
|
||||||
```
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> It is not required to run in verbose, however is reccomended as otherwise it looks like it has hung. The installation progress will take awhile as it copies all Node modules.
|
|
||||||
|
|
||||||
Now you must configure your `.env` A example `.env` is included for you. For a full explanation, jump to [.env configuration](https://git.crafterpika.cc/kittentm/splatnet-backend#env-configuration).
|
Now you must configure your `.env` A example `.env` is included for you. For a full explanation, jump to [.env configuration](https://git.crafterpika.cc/kittentm/splatnet-backend#env-configuration).
|
||||||
Once done, run:
|
Once done, run `/main.py`. This will launch both the frontend api & telemetry.
|
||||||
```
|
|
||||||
splatnet
|
|
||||||
```
|
|
||||||
This uses the `.env` found in your current directory.
|
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
Alternatively, this is available as a Docker image.
|
Alternatively, this is available as a Docker image.
|
||||||
|
|
@ -87,9 +78,6 @@ The .env file is used for server setup. A example one with the fields already th
|
||||||
| `cookie_secure` | `bool` | `True` | Primarily for debugging, controls the flag in cookies |
|
| `cookie_secure` | `bool` | `True` | Primarily for debugging, controls the flag in cookies |
|
||||||
| `judd_port` | `int` | `4000` | The port the Judd (telemetry) server will listen on |
|
| `judd_port` | `int` | `4000` | The port the Judd (telemetry) server will listen on |
|
||||||
| `webhook_url` | str | *Required* | Where logging of blacklist.json will be sent to |
|
| `webhook_url` | str | *Required* | Where logging of blacklist.json will be sent to |
|
||||||
| `twitter_client_id` | `str` | *Required* | Twitter API client id |
|
|
||||||
| `twitter_client_secret` | `str` | *Required* | Twitter API Client secret |
|
|
||||||
| `twitter_redirect_uri` | `str` | *Required* | Where twitter redirects after logging in. Must match whats set in the API key. |
|
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> For dumping your boss keys, see [this](https://github.com/PretendoNetwork/BetterKeyDumper/releases/tag/v1.0.0) HBL app. Note that the keys shown on the screen are garbage, I reccomend using a hex editor on the files it dumps.
|
> For dumping your boss keys, see [this](https://github.com/PretendoNetwork/BetterKeyDumper/releases/tag/v1.0.0) HBL app. Note that the keys shown on the screen are garbage, I reccomend using a hex editor on the files it dumps.
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
# Spacebar Network Code of Conduct
|
|
||||||
|
|
||||||
This repository adheres to the official Spacebar Network Code of Conduct ("COC.") These regulations extend to the entire Spacebar network, our official Discord community, and all Git repositories. By choosing to interact with our community, you are entering into a social contract designed to protect the integrity of the project and the well-being of its members.
|
|
||||||
|
|
||||||
> **Note:** If you wish to propose changes or simply view the COC, the primary residence and master copy of this Code of Conduct can be found [here](https://git.spbr.net/spacebar/policy).
|
|
||||||
|
|
||||||
If you intend to contribute code, participate in community discussions, or experience any element of the Spacebar ecosystem, you must strictly abide by the standards and expectations set forth in this Covenant. We believe that a healthy community is built on mutual respect and shared responsibility. Our goal is to foster a space that is welcoming, inclusive, and free from harassment for everyone, regardless of their background or level of experience. Failure to adhere to these principles may result in removal from the network, as we prioritize maintaining a safe and productive environment for all participants.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
We pledge to make the Spacebar community welcoming, safe, and equitable for all.
|
|
||||||
|
|
||||||
We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant.
|
|
||||||
|
|
||||||
## Encouraged Behaviors
|
|
||||||
|
|
||||||
While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language.
|
|
||||||
|
|
||||||
With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including:
|
|
||||||
|
|
||||||
1. Respecting the **purpose of our community**, our activities, and our ways of gathering.
|
|
||||||
2. Engaging **kindly and honestly** with others.
|
|
||||||
3. Respecting **different viewpoints** and experiences.
|
|
||||||
4. **Taking responsibility** for our actions and contributions.
|
|
||||||
5. Gracefully giving and accepting **constructive feedback**.
|
|
||||||
6. Committing to **repairing harm** when it occurs.
|
|
||||||
7. Behaving in other ways that promote and sustain the **well-being of our community**.
|
|
||||||
|
|
||||||
## Restricted Behaviors
|
|
||||||
|
|
||||||
We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct.
|
|
||||||
|
|
||||||
1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop.
|
|
||||||
2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people.
|
|
||||||
3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits.
|
|
||||||
4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community.
|
|
||||||
5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission.
|
|
||||||
6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group.
|
|
||||||
7. Behaving in other ways that **threaten the well-being** of our community.
|
|
||||||
|
|
||||||
### Other Restrictions
|
|
||||||
|
|
||||||
1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions.
|
|
||||||
2. **Failing to credit sources.** Not properly crediting the sources of content you contribute. If you are found to be using SDK material, all of your content commited towards Spacebar will be removed. No exceptions.
|
|
||||||
3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community.
|
|
||||||
4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors.
|
|
||||||
5. **Discussion of Piracy, or anything relating.**
|
|
||||||
|
|
||||||
## Reporting an Issue
|
|
||||||
|
|
||||||
When an incident occurs, it is important to report it promptly. To report a possible violation, please contact the Spacebar Maintainers via contacting a SPFN or SPBR developer on the discord server found [here](https://discord.gg/grMSxZf).
|
|
||||||
|
|
||||||
Spacebar moderators take reports seriously and will respond in a timely manner. They will investigate all reports by reviewing logs, messages, or interviewing participants. We aim to keep enforcement actions transparent while prioritizing the safety and confidentiality of those involved.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/).
|
|
||||||
|
|
||||||
Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/)
|
|
||||||
|
|
||||||
For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources).
|
|
||||||
|
|
@ -18,7 +18,6 @@ class Settings(BaseSettings):
|
||||||
twitter_client_id: str
|
twitter_client_id: str
|
||||||
twitter_client_secret: str
|
twitter_client_secret: str
|
||||||
twitter_redirect_uri: str
|
twitter_redirect_uri: str
|
||||||
account_client_secret: str
|
|
||||||
|
|
||||||
model_config = SettingsConfigDict(
|
model_config = SettingsConfigDict(
|
||||||
env_file=[
|
env_file=[
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
FROM python:3.14-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y curl build-essential cmake \
|
RUN apt-get update && apt-get install -y curl build-essential \
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||||
&& apt-get install -y nodejs \
|
&& apt-get install -y nodejs \
|
||||||
&& npm install -g npm@latest \
|
&& npm install -g npm@latest \
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,14 @@
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
function validateBOSSDigestMiddleware(request, response, next) {
|
function validateBOSSDigestMiddleware(request, response, next) {
|
||||||
// prevents viewing it in a browser to fucking up the process lmfao
|
const calculatedHash = crypto.createHash('sha1').update(request.rawBody).digest('hex');
|
||||||
if (request.method === 'GET') {
|
const expectedHash = request.headers['x-boss-digest'];
|
||||||
return response.status(404).send('Not Found');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
if (calculatedHash !== expectedHash) {
|
||||||
// try to catch undefined, previously was making everything die
|
return next('Provided BOSS digest does not match the calculated hash');
|
||||||
if (!request.rawBody) {
|
}
|
||||||
throw new Error('rawBody is undefined');
|
|
||||||
}
|
|
||||||
|
|
||||||
const calculatedHash = crypto.createHash('sha1').update(request.rawBody).digest('hex');
|
next();
|
||||||
const expectedHash = request.headers['x-boss-digest'];
|
|
||||||
|
|
||||||
//catch all other errors
|
|
||||||
if (calculatedHash !== expectedHash) {
|
|
||||||
console.warn(`[Digest Mismatch] Expected: ${expectedHash}, Calculated: ${calculatedHash}`);
|
|
||||||
return response.status(403).send('Provided BOSS digest does not match the calculated hash');
|
|
||||||
}
|
|
||||||
|
|
||||||
next();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('[Digest Middleware Error]:', error.message);
|
|
||||||
return response.status(500).send('Internal Server Error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = validateBOSSDigestMiddleware;
|
module.exports = validateBOSSDigestMiddleware;
|
||||||
|
|
@ -64,8 +64,6 @@ const SplatfestResult = connection.define('SplatfestResult', {
|
||||||
MemoryHash: { type: DataTypes.BIGINT },
|
MemoryHash: { type: DataTypes.BIGINT },
|
||||||
Paint_Alpha: { type: DataTypes.INTEGER },
|
Paint_Alpha: { type: DataTypes.INTEGER },
|
||||||
Paint_Bravo: { type: DataTypes.INTEGER },
|
Paint_Bravo: { type: DataTypes.INTEGER },
|
||||||
RemainCount_Alpha: { type: DataTypes.INTEGER },
|
|
||||||
RemainCount_Bravo: { type: DataTypes.INTEGER },
|
|
||||||
FaceImg: { type: DataTypes.BLOB }
|
FaceImg: { type: DataTypes.BLOB }
|
||||||
}, {
|
}, {
|
||||||
tableName: 'results',
|
tableName: 'results',
|
||||||
|
|
|
||||||
1237
judd/package-lock.json
generated
1237
judd/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,16 +11,15 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.15.2",
|
"discord.js": "^14.25.1",
|
||||||
"discord.js": "^14.26.3",
|
"express": "^4.18.2",
|
||||||
"express": "^5.2.1",
|
"express-rate-limit": "^8.3.1",
|
||||||
"express-rate-limit": "^8.3.2",
|
"express-subdomain": "^1.0.5",
|
||||||
"express-subdomain": "^1.0.6",
|
"joi": "^17.7.0",
|
||||||
"joi": "^18.1.2",
|
"morgan": "^1.10.0",
|
||||||
"morgan": "^1.10.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"multer": "^2.1.1",
|
"pg": "^8.18.0",
|
||||||
"pg": "^8.20.0",
|
|
||||||
"pg-hstore": "^2.3.4",
|
"pg-hstore": "^2.3.4",
|
||||||
"sequelize": "^6.37.8"
|
"sequelize": "^6.37.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"weapons": [],
|
"weapons": [1000, 1001, 1002, 1003, 1100, 1200, 1800, 1801, 2000, 2001, 2002, 2003, 5000],
|
||||||
"clothes": [26061, 26062, 26063, 26064, 26065, 26066, 26067, 26068, 26069, 26070, 26071, 26072, 26073, 26074, 26075, 26076, 26077, 26078, 26079, 26080, 26081, 26082, 26083, 26084, 26085, 26086, 26087, 26088, 26089, 26090, 26091, 26092, 26093, 26094, 26095, 26096, 26097, 26098, 26099, 26100, 26101, 26102, 26103, 26104, 26105, 26106, 26107, 26108, 26109, 26110, 26111, 26112, 26113, 26114, 26115, 26116, 26117, 26118, 26119, 26120, 26121, 26122, 26123, 26124, 26125, 26126, 26127, 26128, 26129, 26130, 26131, 26132, 26133, 26134, 26135, 26136],
|
"clothes": [26061, 26062, 26063, 26064, 26065, 26066, 26067, 26068, 26069, 26070, 26071, 26072, 26073, 26074, 26075, 26076, 26077, 26078, 26079, 26080, 26081, 26082, 26083, 26084, 26085, 26086, 26087, 26088, 26089, 26090, 26091, 26092, 26093, 26094, 26095, 26096, 26097, 26098, 26099, 26100, 26101, 26102, 26103, 26104, 26105, 26106, 26107, 26108, 26109, 26110, 26111, 26112, 26113, 26114, 26115, 26116, 26117, 26118, 26119, 26120, 26121, 26122, 26123, 26124, 26125, 26126, 26127, 26128, 26129, 26130, 26131, 26132, 26133, 26134, 26135, 26136],
|
||||||
"rules": [-1]
|
"rules": [-1]
|
||||||
}
|
}
|
||||||
|
|
@ -32,97 +32,110 @@
|
||||||
"15": "Mahi-Mahi Resort (ID=15)"
|
"15": "Mahi-Mahi Resort (ID=15)"
|
||||||
},
|
},
|
||||||
"weapons_main": {
|
"weapons_main": {
|
||||||
"1000": "Sploosh-o-matic (ID=1000)",
|
"100": "Sploosh-o-matic (ID=100)",
|
||||||
"1001": "Neo Sploosh-o-matic (ID=1001)",
|
"101": "Neo Sploosh-o-matic (ID=101)",
|
||||||
"1002": "Sploosh-o-matic 7 (ID=1002)",
|
"102": "Splattershot Jr. (ID=102)",
|
||||||
"1010": "Splattershot Jr. (ID=1010)",
|
"103": "Custom Splattershot Jr. (ID=103)",
|
||||||
"1011": "Custom Splattershot Jr. (ID=1011)",
|
"104": "Splash-o-matic (ID=104)",
|
||||||
"1020": "Splash-o-matic (ID=1020)",
|
"105": "Neo Splash-o-matic (ID=105)",
|
||||||
"1021": "Neo Splash-o-matic (ID=1021)",
|
"106": "Aerospray MG (ID=106)",
|
||||||
"1030": "Aerospray MG (ID=1030)",
|
"107": "Aerospray RG (ID=107)",
|
||||||
"1031": "Aerospray RG (ID=1031)",
|
"108": "Splattershot (ID=108)",
|
||||||
"1032": "Aerospray PG (ID=1032)",
|
"109": "Tentatek Splattershot (ID=109)",
|
||||||
"1040": "Splattershot (ID=1040)",
|
"110": "Hero Shot Replica (ID=110)",
|
||||||
"1041": "Tentatek Splattershot (ID=1041)",
|
"111": "Octoshot Replica (ID=111)",
|
||||||
"1042": "Wasabi Splattershot (ID=1042)",
|
"112": ".52 Gal (ID=112)",
|
||||||
"1045": "Hero Shot Replica (ID=1045)",
|
"113": ".52 Gal Deco (ID=113)",
|
||||||
"1046": "Octoshot Replica (ID=1046)",
|
"114": "N-ZAP '85 (ID=114)",
|
||||||
"1050": ".52 Gal (ID=1050)",
|
"115": "N-ZAP '89 (ID=115)",
|
||||||
"1051": ".52 Gal Deco (ID=1051)",
|
"116": "Splattershot Pro (ID=116)",
|
||||||
"1060": "N-ZAP '85 (ID=1060)",
|
"117": "Forge Splattershot Pro (ID=117)",
|
||||||
"1061": "N-ZAP '89 (ID=1061)",
|
"118": ".96 Gal (ID=118)",
|
||||||
"1062": "N-ZAP '83 (ID=1062)",
|
"119": ".96 Gal Deco (ID=119)",
|
||||||
"1070": "Splattershot Pro (ID=1070)",
|
"120": "Dual Squelcher (ID=120)",
|
||||||
"1071": "Forge Splattershot Pro (ID=1071)",
|
"121": "Custom Dual Squelcher (ID=121)",
|
||||||
"1072": "Berry Splattershot Pro (ID=1072)",
|
"122": "Jet Squelcher (ID=122)",
|
||||||
"1080": ".96 Gal (ID=1080)",
|
"123": "Custom Jet Squelcher (ID=123)",
|
||||||
"1081": ".96 Gal Deco (ID=1081)",
|
"124": "Luna Blaster (ID=124)",
|
||||||
"1090": "Dual Squelcher (ID=1090)",
|
"125": "Luna Blaster Neo (ID=125)",
|
||||||
"1091": "Custom Dual Squelcher (ID=1091)",
|
"126": "Blaster (ID=126)",
|
||||||
"1100": "Jet Squelcher (ID=1100)",
|
"127": "Custom Blaster (ID=127)",
|
||||||
"1101": "Custom Jet Squelcher (ID=1101)",
|
"128": "Range Blaster (ID=128)",
|
||||||
"1110": "Luna Blaster (ID=1110)",
|
"129": "Custom Range Blaster (ID=129)",
|
||||||
"1111": "Luna Blaster Neo (ID=1111)",
|
"130": "Rapid Blaster (ID=130)",
|
||||||
"1120": "Blaster (ID=1120)",
|
"131": "Rapid Blaster Deco (ID=131)",
|
||||||
"1121": "Custom Blaster (ID=1121)",
|
"132": "Rapid Blaster Pro (ID=132)",
|
||||||
"1130": "Range Blaster (ID=1130)",
|
"133": "Rapid Blaster Pro Deco (ID=133)",
|
||||||
"1131": "Custom Range Blaster (ID=1131)",
|
"134": "L-3 Nozzlenose (ID=134)",
|
||||||
"1132": "Grim Range Blaster (ID=1132)",
|
"135": "L-3 Nozzlenose D (ID=135)",
|
||||||
"1140": "Rapid Blaster (ID=1140)",
|
"136": "H-3 Nozzlenose (ID=136)",
|
||||||
"1141": "Rapid Blaster Deco (ID=1141)",
|
"137": "H-3 Nozzlenose D (ID=137)",
|
||||||
"1150": "Rapid Blaster Pro (ID=1150)",
|
"138": "Wasabi Splattershot (ID=138)",
|
||||||
"1151": "Rapid Blaster Pro Deco (ID=1151)",
|
"139": "Berry Splattershot Pro (ID=139)",
|
||||||
"1160": "L-3 Nozzlenose (ID=1160)",
|
"140": "Sploosh-o-matic 7 (ID=140)",
|
||||||
"1161": "L-3 Nozzlenose D (ID=1161)",
|
"141": "Aerospray PG (ID=141)",
|
||||||
"1170": "H-3 Nozzlenose (ID=1170)",
|
"142": "N-ZAP '83 (ID=142)",
|
||||||
"1171": "H-3 Nozzlenose D (ID=1171)",
|
"143": "Grim Range Blaster (ID=143)",
|
||||||
"1172": "Cherry H-3 Nozzlenose (ID=1172)",
|
"144": "Cherry H-3 Nozzlenose (ID=144)",
|
||||||
"2000": "Carbon Roller (ID=2000)",
|
"200": "Carbon Roller (ID=200)",
|
||||||
"2001": "Carbon Roller Deco (ID=2001)",
|
"201": "Carbon Roller Deco (ID=201)",
|
||||||
"2010": "Splat Roller (ID=2010)",
|
"202": "Splat Roller (ID=202)",
|
||||||
"2011": "Krak-On Splat Roller (ID=2011)",
|
"203": "Krak-On Splat Roller (ID=203)",
|
||||||
"2012": "CoroCoro Splat Roller (ID=2012)",
|
"204": "Hero Roller Replica (ID=204)",
|
||||||
"2015": "Hero Roller Replica (ID=2015)",
|
"205": "Dynamo Roller (ID=205)",
|
||||||
"2020": "Dynamo Roller (ID=2020)",
|
"206": "Gold Dynamo Roller (ID=206)",
|
||||||
"2021": "Gold Dynamo Roller (ID=2021)",
|
"207": "Inkbrush (ID=207)",
|
||||||
"2022": "Tempered Dynamo Roller (ID=2022)",
|
"208": "Inkbrush Nouveau (ID=208)",
|
||||||
"2030": "Inkbrush (ID=2030)",
|
"209": "Octobrush (ID=209)",
|
||||||
"2031": "Inkbrush Nouveau (ID=2031)",
|
"210": "Octobrush Nouveau (ID=210)",
|
||||||
"2032": "Permanent Inkbrush (ID=2032)",
|
"211": "Tempered Dynamo Roller (ID=211)",
|
||||||
"2040": "Octobrush (ID=2040)",
|
"212": "Permanent Inkbrush (ID=212)",
|
||||||
"2041": "Octobrush Nouveau (ID=2041)",
|
"213": "CoroCoro Splat Roller (ID=213)",
|
||||||
"4000": "Classic Squiffer (ID=4000)",
|
"300": "Classic Squiffer (ID=300)",
|
||||||
"4001": "New Squiffer (ID=4001)",
|
"301": "New Squiffer (ID=301)",
|
||||||
"4002": "Fresh Squiffer (ID=4002)",
|
"302": "Splat Charger (ID=302)",
|
||||||
"4010": "Splat Charger (ID=4010)",
|
"303": "Kelp Splat Charger (ID=303)",
|
||||||
"4011": "Kelp Splat Charger (ID=4011)",
|
"304": "Hero Charger Replica (ID=304)",
|
||||||
"4012": "Bento Splat Charger (ID=4012)",
|
"305": "Splatterscope (ID=305)",
|
||||||
"4015": "Hero Charger Replica (ID=4015)",
|
"306": "Kelp Splatterscope (ID=306)",
|
||||||
"4020": "Splatterscope (ID=4020)",
|
"307": "E-liter 3K (ID=307)",
|
||||||
"4021": "Kelp Splatterscope (ID=4021)",
|
"308": "Custom E-liter 3K (ID=308)",
|
||||||
"4022": "Bento Splatterscope (ID=4022)",
|
"309": "E-liter 3K Scope (ID=309)",
|
||||||
"4030": "E-liter 3K (ID=4030)",
|
"310": "Custom E-liter 3K Scope (ID=310)",
|
||||||
"4031": "Custom E-liter 3K (ID=4031)",
|
"311": "Bamboozler 14 Mk I (ID=311)",
|
||||||
"4040": "E-liter 3K Scope (ID=4040)",
|
"312": "Bamboozler 14 Mk II (ID=312)",
|
||||||
"4041": "Custom E-liter 3K Scope (ID=4041)",
|
"313": "Fresh Squiffer (ID=313)",
|
||||||
"4050": "Bamboozler 14 Mk I (ID=4050)",
|
"314": "Bamboozler 14 Mk III (ID=314)",
|
||||||
"4051": "Bamboozler 14 Mk II (ID=4051)",
|
"315": "Bento Splat Charger (ID=315)",
|
||||||
"4052": "Bamboozler 14 Mk III (ID=4052)",
|
"316": "Bento Splatterscope (ID=316)",
|
||||||
"3000": "Slosher (ID=3000)",
|
"400": "Slosher (ID=400)",
|
||||||
"3001": "Slosher Deco (ID=3001)",
|
"401": "Slosher Deco (ID=401)",
|
||||||
"3002": "Soda Slosher (ID=3002)",
|
"402": "Tri-Slosher (ID=402)",
|
||||||
"3010": "Tri-Slosher (ID=3010)",
|
"403": "Tri-Slosher Nouveau (ID=403)",
|
||||||
"3011": "Tri-Slosher Nouveau (ID=3011)",
|
"404": "Sloshing Machine (ID=404)",
|
||||||
"3020": "Sloshing Machine (ID=3020)",
|
"405": "Sloshing Machine Neo (ID=405)",
|
||||||
"3021": "Sloshing Machine Neo (ID=3021)",
|
"406": "Soda Slosher (ID=406)",
|
||||||
"5000": "Mini Splatling (ID=5000)",
|
"500": "Mini Splatling (ID=500)",
|
||||||
"5001": "Zink Mini Splatling (ID=5001)",
|
"501": "Zink Mini Splatling (ID=501)",
|
||||||
"5002": "Refurbished Mini Splatling (ID=5002)",
|
"502": "Heavy Splatling (ID=502)",
|
||||||
"5010": "Heavy Splatling (ID=5010)",
|
"503": "Heavy Splatling Deco (ID=503)",
|
||||||
"5011": "Heavy Splatling Deco (ID=5011)",
|
"504": "Hydra Splatling (ID=504)",
|
||||||
"5012": "Heavy Splatling Remix (ID=5012)",
|
"505": "Custom Hydra Splatling (ID=505)",
|
||||||
"5020": "Hydra Splatling (ID=5020)",
|
"506": "Refurbished Mini Splatling (ID=506)",
|
||||||
"5021": "Custom Hydra Splatling (ID=5021)"
|
"507": "Heavy Splatling Remix (ID=507)",
|
||||||
|
"1000": "?Shot_Msn0Lv0 (ID=1000)",
|
||||||
|
"1001": "?Shot_Msn0Lv1 (ID=1001)",
|
||||||
|
"1002": "?Shot_Msn0Lv2 (ID=1002)",
|
||||||
|
"1003": "?Shot_Msn0Lv3 (ID=1003)",
|
||||||
|
"1100": "?Roller_Mission (ID=1100)",
|
||||||
|
"1200": "?Charge_Mission (ID=1200)",
|
||||||
|
"1800": "?BigBall_SpecAdjust01 (ID=1800)",
|
||||||
|
"1801": "?BigBall_SpecAdjust02 (ID=1801)",
|
||||||
|
"2000": "?Shot_Rvl0Lv0 (ID=2000)",
|
||||||
|
"2001": "?Shot_Rvl0Lv1 (ID=2001)",
|
||||||
|
"2002": "?Shot_Rvl0Lv2 (ID=2002)",
|
||||||
|
"2003": "?Shot_Rvl0Lv3 (ID=2003)",
|
||||||
|
"5000": "?Roller_KingSquid (ID=5000)"
|
||||||
},
|
},
|
||||||
"sub_weapons": {
|
"sub_weapons": {
|
||||||
"0": "Splat Bomb (ID=0)",
|
"0": "Splat Bomb (ID=0)",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ const router = require('express').Router();
|
||||||
const rateLimit = require('express-rate-limit');
|
const rateLimit = require('express-rate-limit');
|
||||||
const titles = require('../titles');
|
const titles = require('../titles');
|
||||||
const { WebhookClient, EmbedBuilder } = require('discord.js');
|
const { WebhookClient, EmbedBuilder } = require('discord.js');
|
||||||
const axios = require('axios');
|
|
||||||
const lookup = require('./ids.json');
|
const lookup = require('./ids.json');
|
||||||
const blacklist = require('./blacklist.json');
|
const blacklist = require('./blacklist.json');
|
||||||
|
|
||||||
|
|
@ -28,35 +27,8 @@ router.post('/post', postLimiter, async (request, response, next) => {
|
||||||
|
|
||||||
const ResultTypeModel = title.result_model;
|
const ResultTypeModel = title.result_model;
|
||||||
const data = request.resultData || {};
|
const data = request.resultData || {};
|
||||||
const pid = data.PId || 'N/A';
|
|
||||||
const miiName = data.MiiName || 'N/A';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let isPidValid = true;
|
|
||||||
try {
|
|
||||||
const spfnCheck = await axios.get(`https://account.spbr.net/api/v2/users/${pid}/mii`);
|
|
||||||
if (typeof spfnCheck.data === 'string' && spfnCheck.data.includes('<code>0008</code>')) {
|
|
||||||
isPidValid = false;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Caught error when validating ${pid}:`, err.message || err);
|
|
||||||
isPidValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isPidValid) {
|
|
||||||
const invalidPidEmbed = new EmbedBuilder()
|
|
||||||
.setTitle(":warning: | Invalid Telemetry received")
|
|
||||||
.setDescription("## PID is not a valid SPFN ID\nThis submission has been BLOCKED!")
|
|
||||||
.setColor(15158332)
|
|
||||||
.addFields(
|
|
||||||
{ name: "PID", value: `${pid}`, inline: true },
|
|
||||||
{ name: "Mii Name", value: `${miiName}`, inline: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
await webhookClient.send({ embeds: [invalidPidEmbed] });
|
|
||||||
return response.status(500).send('Invalid PID... fuck off mate stop sending it');
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await ResultTypeModel.create({
|
const result = await ResultTypeModel.create({
|
||||||
type: title.type,
|
type: title.type,
|
||||||
bossUniqueId: request.headers['x-boss-uniqueid'],
|
bossUniqueId: request.headers['x-boss-uniqueid'],
|
||||||
|
|
@ -64,20 +36,17 @@ router.post('/post', postLimiter, async (request, response, next) => {
|
||||||
...request.resultData
|
...request.resultData
|
||||||
});
|
});
|
||||||
const offenses = [];
|
const offenses = [];
|
||||||
const weaponExists = Object.prototype.hasOwnProperty.call(lookup.weapons_main, String(data.Weapon));
|
|
||||||
if (!weaponExists && data.Weapon !== undefined) offenses.push("Invalid Weapon ID");
|
|
||||||
if ((blacklist.weapons || []).includes(Number(data.Weapon))) offenses.push("weapon");
|
if ((blacklist.weapons || []).includes(Number(data.Weapon))) offenses.push("weapon");
|
||||||
if ((blacklist.clothes || []).includes(Number(data.Gear_Clothes))) offenses.push("clothes");
|
if ((blacklist.clothes || []).includes(Number(data.Gear_Clothes))) offenses.push("clothes");
|
||||||
if ((blacklist.rules || []).includes(Number(data.Rule))) offenses.push("rule");
|
if ((blacklist.rules || []).includes(Number(data.Rule))) offenses.push("rule");
|
||||||
if (offenses.length > 0) {
|
if (offenses.length > 0) {
|
||||||
const sWep = (offenses.includes("weapon") || offenses.includes("Invalid Weapon ID")) ? "⭐ " : "";
|
const sWep = offenses.includes("weapon") ? "⭐ " : "";
|
||||||
const sClt = offenses.includes("clothes") ? "⭐ " : "";
|
const sClt = offenses.includes("clothes") ? "⭐ " : "";
|
||||||
const sRul = offenses.includes("rule") ? "⭐ " : "";
|
const sRul = offenses.includes("rule") ? "⭐ " : "";
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(":warning: | Invalid Telemetry received")
|
.setTitle(":warning: | Invalid Telemetry received")
|
||||||
.setDescription(`## Offending information detected in: ${offenses.join(', ')}`)
|
.setDescription(`## Offending information detected in: ${offenses.join(', ')}`)
|
||||||
.setColor(offenses.includes("Invalid Weapon ID") ? 0xFF9900 : 15158332)
|
|
||||||
.setFields(
|
.setFields(
|
||||||
{
|
{
|
||||||
name: "User Information:",
|
name: "User Information:",
|
||||||
|
|
@ -86,11 +55,7 @@ router.post('/post', postLimiter, async (request, response, next) => {
|
||||||
},
|
},
|
||||||
{ name: "PID", value: `${data.PId || 'N/A'}`, inline: true },
|
{ name: "PID", value: `${data.PId || 'N/A'}`, inline: true },
|
||||||
{ name: "Mii Name", value: `${data.MiiName || 'N/A'}`, inline: true },
|
{ name: "Mii Name", value: `${data.MiiName || 'N/A'}`, inline: true },
|
||||||
{
|
{ name: "Weapon", value: `${sWep}${lookup.weapons_main[data.Weapon] || data.Weapon || 'N/A'}`, inline: true },
|
||||||
name: "Weapon",
|
|
||||||
value: `${sWep}${lookup.weapons_main[data.Weapon] || `UNKNOWN ID: ${data.Weapon}`}`,
|
|
||||||
inline: true
|
|
||||||
},
|
|
||||||
{ name: "Headgear", value: `${lookup.headgear[data.Gear_Head] || data.Gear_Head || 'N/A'}`, inline: true },
|
{ name: "Headgear", value: `${lookup.headgear[data.Gear_Head] || data.Gear_Head || 'N/A'}`, inline: true },
|
||||||
{ name: "Clothes", value: `${sClt}${lookup.clothes[data.Gear_Clothes] || data.Gear_Clothes || 'N/A'}`, inline: true },
|
{ name: "Clothes", value: `${sClt}${lookup.clothes[data.Gear_Clothes] || data.Gear_Clothes || 'N/A'}`, inline: true },
|
||||||
{ name: "Shoes", value: `${lookup.shoes[data.Gear_Shoes] || data.Gear_Shoes || 'N/A'}`, inline: true },
|
{ name: "Shoes", value: `${lookup.shoes[data.Gear_Shoes] || data.Gear_Shoes || 'N/A'}`, inline: true },
|
||||||
|
|
@ -116,4 +81,4 @@ router.post('/post', postLimiter, async (request, response, next) => {
|
||||||
return response.send('success');
|
return response.send('success');
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
@ -4,61 +4,50 @@ const { SplatfestResult } = require('../models/splatfest_result');
|
||||||
const { Equipment } = require('../models/equipment');
|
const { Equipment } = require('../models/equipment');
|
||||||
const { EquipmentLast } = require('../models/equipmentLast');
|
const { EquipmentLast } = require('../models/equipmentLast');
|
||||||
const { PlayerRank } = require('../models/playerRank');
|
const { PlayerRank } = require('../models/playerRank');
|
||||||
const MAX_INT32 = 2147483647;
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
type: 'telemetry',
|
type: 'telemetry',
|
||||||
result_model: {
|
result_model: {
|
||||||
create: async (data) => {
|
create: async (data) => {
|
||||||
const sanitizedData = { ...data };
|
const result = await SplatfestResult.create(data);
|
||||||
|
|
||||||
const rankValue = parseInt(data.Rank);
|
|
||||||
if (isNaN(rankValue) || rankValue > MAX_INT32 || rankValue < 0) {
|
|
||||||
sanitizedData.Rank = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseInt(data.SessionID) > MAX_INT32) sanitizedData.SessionID = 0;
|
|
||||||
|
|
||||||
const result = await SplatfestResult.create(sanitizedData, { ordering: false, ignoreDuplicates: false });
|
|
||||||
|
|
||||||
await Equipment.upsert({
|
await Equipment.upsert({
|
||||||
PId: sanitizedData.PId,
|
PId: data.PId,
|
||||||
weapon: sanitizedData.Weapon,
|
weapon: data.Weapon,
|
||||||
sumpaint: sanitizedData.SumPaint
|
sumpaint: data.SumPaint
|
||||||
});
|
});
|
||||||
|
|
||||||
await EquipmentLast.upsert({
|
await EquipmentLast.upsert({
|
||||||
PId: sanitizedData.PId,
|
PId: data.PId,
|
||||||
weapon: sanitizedData.Weapon,
|
weapon: data.Weapon,
|
||||||
Gear_Shoes: sanitizedData.Gear_Shoes,
|
Gear_Shoes: data.Gear_Shoes,
|
||||||
Gear_Shoes_Skill0: sanitizedData.Gear_Shoes_Skill0,
|
Gear_Shoes_Skill0: data.Gear_Shoes_Skill0,
|
||||||
Gear_Shoes_Skill1: sanitizedData.Gear_Shoes_Skill1,
|
Gear_Shoes_Skill1: data.Gear_Shoes_Skill1,
|
||||||
Gear_Shoes_Skill2: sanitizedData.Gear_Shoes_Skill2,
|
Gear_Shoes_Skill2: data.Gear_Shoes_Skill2,
|
||||||
Gear_Clothes: sanitizedData.Gear_Clothes,
|
Gear_Clothes: data.Gear_Clothes,
|
||||||
Gear_Clothes_Skill0: sanitizedData.Gear_Clothes_Skill0,
|
Gear_Clothes_Skill0: data.Gear_Clothes_Skill0,
|
||||||
Gear_Clothes_Skill1: sanitizedData.Gear_Clothes_Skill1,
|
Gear_Clothes_Skill1: data.Gear_Clothes_Skill1,
|
||||||
Gear_Clothes_Skill2: sanitizedData.Gear_Clothes_Skill2,
|
Gear_Clothes_Skill2: data.Gear_Clothes_Skill2,
|
||||||
Gear_Head: sanitizedData.Gear_Head,
|
Gear_Head: data.Gear_Head,
|
||||||
Gear_Head_Skill0: sanitizedData.Gear_Head_Skill0,
|
Gear_Head_Skill0: data.Gear_Head_Skill0,
|
||||||
Gear_Head_Skill1: sanitizedData.Gear_Head_Skill1,
|
Gear_Head_Skill1: data.Gear_Head_Skill1,
|
||||||
Gear_Head_Skill2: sanitizedData.Gear_Head_Skill2,
|
Gear_Head_Skill2: data.Gear_Head_Skill2,
|
||||||
Rank: sanitizedData.Rank,
|
Rank: data.Rank,
|
||||||
Udemae: sanitizedData.Udemae
|
Udemae: data.Udemae
|
||||||
});
|
});
|
||||||
|
const gameMode = parseInt(data.GameMode);
|
||||||
const gameMode = parseInt(sanitizedData.GameMode);
|
|
||||||
|
|
||||||
if (gameMode !== 3 && gameMode !== 4) {
|
if (gameMode !== 3 && gameMode !== 4) {
|
||||||
const isWin = Number(sanitizedData.IsWinGame) === 1;
|
const isWin = Number(data.IsWinGame) === 1;
|
||||||
const [stats, created] = await PlayerRank.findOrCreate({
|
const [stats, created] = await PlayerRank.findOrCreate({
|
||||||
where: {
|
where: {
|
||||||
PId: sanitizedData.PId,
|
PId: data.PId,
|
||||||
GameMode: sanitizedData.GameMode
|
GameMode: data.GameMode
|
||||||
},
|
},
|
||||||
defaults: {
|
defaults: {
|
||||||
MiiName: sanitizedData.MiiName,
|
MiiName: data.MiiName,
|
||||||
Rank: sanitizedData.Rank,
|
Rank: data.Rank,
|
||||||
FesPower: parseFloat(sanitizedData.FesPower) || 0,
|
FesPower: parseFloat(data.FesPower) || 0,
|
||||||
WinSum: 0,
|
WinSum: 0,
|
||||||
LoseSum: 0,
|
LoseSum: 0,
|
||||||
RankingScore: 0
|
RankingScore: 0
|
||||||
|
|
@ -79,9 +68,9 @@ module.exports = {
|
||||||
const newRankingScore = currentWins * winRate * 10;
|
const newRankingScore = currentWins * winRate * 10;
|
||||||
|
|
||||||
await stats.update({
|
await stats.update({
|
||||||
MiiName: sanitizedData.MiiName,
|
MiiName: data.MiiName,
|
||||||
Rank: sanitizedData.Rank,
|
Rank: data.Rank,
|
||||||
FesPower: parseFloat(sanitizedData.FesPower) || 0,
|
FesPower: parseFloat(data.FesPower) || 0,
|
||||||
WinSum: currentWins,
|
WinSum: currentWins,
|
||||||
LoseSum: currentLosses,
|
LoseSum: currentLosses,
|
||||||
RankingScore: newRankingScore
|
RankingScore: newRankingScore
|
||||||
|
|
@ -149,12 +138,8 @@ module.exports = {
|
||||||
BottleneckPlayerNum: joi.numberstring(),
|
BottleneckPlayerNum: joi.numberstring(),
|
||||||
MaxSilenceFrame: joi.numberstring(),
|
MaxSilenceFrame: joi.numberstring(),
|
||||||
MemoryHash: joi.numberstring(),
|
MemoryHash: joi.numberstring(),
|
||||||
//swaps Paint_TEAM for RemainCount_TEAM.
|
|
||||||
//Paint_TEAM is used in turf, RemainCount is used in Ranked
|
|
||||||
Paint_Alpha: joi.numberstring(),
|
Paint_Alpha: joi.numberstring(),
|
||||||
Paint_Bravo: joi.numberstring(),
|
Paint_Bravo: joi.numberstring(),
|
||||||
RemainCount_Alpha: joi.numberstring(),
|
|
||||||
RemainCount_Bravo: joi.numberstring(),
|
|
||||||
FaceImg: joi.binary()
|
FaceImg: joi.binary()
|
||||||
}).unknown(true).options({ presence: 'optional' }).required(),
|
}).unknown(true).options({ presence: 'optional' }).required(),
|
||||||
multipart_validator: multer().any()
|
multipart_validator: multer().any()
|
||||||
|
|
|
||||||
113
main.py
113
main.py
|
|
@ -14,13 +14,11 @@ from routes.equipment import equipment_history
|
||||||
from routes.equipment import equipment
|
from routes.equipment import equipment
|
||||||
from services.boss_retrieval import process_boss_file
|
from services.boss_retrieval import process_boss_file
|
||||||
from routes import Ranking
|
from routes import Ranking
|
||||||
from routes import ranking_grabstats
|
|
||||||
from routes import twitter_link
|
from routes import twitter_link
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta
|
||||||
from sqlalchemy import delete
|
from sqlalchemy import delete
|
||||||
from config import BASE_DIR
|
from config import BASE_DIR
|
||||||
import yaml
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
|
|
@ -33,7 +31,6 @@ JUDD_SERVER_JS = os.path.join(JUDD_CWD, "server.js")
|
||||||
JUDD_CMD = ["node", JUDD_SERVER_JS]
|
JUDD_CMD = ["node", JUDD_SERVER_JS]
|
||||||
|
|
||||||
judd_process = None
|
judd_process = None
|
||||||
skip_upcoming_reset = False
|
|
||||||
|
|
||||||
async def boss_worker_loop():
|
async def boss_worker_loop():
|
||||||
print("background worker started")
|
print("background worker started")
|
||||||
|
|
@ -46,79 +43,30 @@ async def boss_worker_loop():
|
||||||
await asyncio.sleep(3600)
|
await asyncio.sleep(3600)
|
||||||
|
|
||||||
async def weekly_rank_reset_loop():
|
async def weekly_rank_reset_loop():
|
||||||
global skip_upcoming_reset
|
|
||||||
print("weekly_rank_reset worker started")
|
print("weekly_rank_reset worker started")
|
||||||
|
while True:
|
||||||
FES_BOSS_PATH = os.path.join(BASE_DIR, "fes_boss.yaml")
|
now = datetime.now()
|
||||||
|
days_ahead = 6 - now.weekday()
|
||||||
def get_next_sunday_reset_time_utc():
|
|
||||||
now_utc = datetime.now(timezone.utc)
|
|
||||||
days_ahead = 6 - now_utc.weekday()
|
|
||||||
if days_ahead <= 0:
|
if days_ahead <= 0:
|
||||||
days_ahead += 7
|
days_ahead += 7
|
||||||
next_sunday_utc = now_utc + timedelta(days=days_ahead)
|
|
||||||
return next_sunday_utc.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
|
|
||||||
async def check_splatfest_schedule_loop():
|
|
||||||
global skip_upcoming_reset
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
target_reset_utc = get_next_sunday_reset_time_utc()
|
|
||||||
print(f"checking if a splatfest will be active at: {target_reset_utc.isoformat()}")
|
|
||||||
|
|
||||||
if os.path.exists(FES_BOSS_PATH):
|
|
||||||
with open(FES_BOSS_PATH, "r", encoding="utf-8") as f:
|
|
||||||
fes_data = yaml.safe_load(f)
|
|
||||||
|
|
||||||
if fes_data and "Time" in fes_data:
|
|
||||||
start_time = datetime.fromisoformat(fes_data["Time"]["Start"])
|
|
||||||
end_time = datetime.fromisoformat(fes_data["Time"]["End"])
|
|
||||||
|
|
||||||
start_time_utc = start_time.astimezone(timezone.utc)
|
|
||||||
end_time_utc = end_time.astimezone(timezone.utc)
|
|
||||||
|
|
||||||
print(f"detected splatfest schedule: {start_time_utc.isoformat()} to {end_time_utc.isoformat()}")
|
|
||||||
|
|
||||||
if start_time_utc <= target_reset_utc <= end_time_utc:
|
|
||||||
skip_upcoming_reset = True
|
|
||||||
print("Splatfest detected in reset window")
|
|
||||||
else:
|
|
||||||
skip_upcoming_reset = False
|
|
||||||
print("No splatfest active in reset window, yay!!!")
|
|
||||||
else:
|
|
||||||
print("could not find yaml, defaulted to no fest")
|
|
||||||
skip_upcoming_reset = False
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"failed to check fest schedule: {e}")
|
|
||||||
|
|
||||||
await asyncio.sleep(7200)
|
next_sunday = now + timedelta(days=days_ahead)
|
||||||
|
next_run = next_sunday.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
asyncio.create_task(check_splatfest_schedule_loop())
|
|
||||||
|
|
||||||
while True:
|
|
||||||
now_utc = datetime.now(timezone.utc)
|
|
||||||
next_run_utc = get_next_sunday_reset_time_utc()
|
|
||||||
wait_seconds = (next_run_utc - now_utc).total_seconds()
|
|
||||||
|
|
||||||
print(f"Next ranking reset scheduled for: {next_run_utc.isoformat()} (in {wait_seconds:.0f} seconds)")
|
wait_seconds = (next_run - now).total_seconds()
|
||||||
|
print(f"Next ranking reset scheduled for: {next_run} (in {wait_seconds:.0f} seconds)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await asyncio.sleep(wait_seconds)
|
await asyncio.sleep(wait_seconds)
|
||||||
|
|
||||||
print("ranking reset triggerred!")
|
print("Executing weekly ranking reset...")
|
||||||
|
with SessionLocal() as db:
|
||||||
|
db.execute(delete(PlayerRank))
|
||||||
|
db.commit()
|
||||||
|
print("Ranking table cleared successfully.")
|
||||||
|
await FastAPICache.clear()
|
||||||
|
print("Cache cleared")
|
||||||
|
|
||||||
if skip_upcoming_reset:
|
|
||||||
print("Reset skipped due to active splatfest")
|
|
||||||
else:
|
|
||||||
print("Executing weekly ranking reset...")
|
|
||||||
with SessionLocal() as db:
|
|
||||||
db.execute(delete(PlayerRank))
|
|
||||||
db.commit()
|
|
||||||
print("Ranking table cleared successfully.")
|
|
||||||
await FastAPICache.clear()
|
|
||||||
print("Cache cleared")
|
|
||||||
|
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
|
|
@ -173,6 +121,34 @@ app.add_middleware(
|
||||||
async def proxy_fallback(request: Request, call_next):
|
async def proxy_fallback(request: Request, call_next):
|
||||||
response = await call_next(request)
|
response = await call_next(request)
|
||||||
|
|
||||||
|
if response.status_code != 404:
|
||||||
|
return response
|
||||||
|
|
||||||
|
url = f"http://127.0.0.1:{settings.judd_port}{request.url.path}"
|
||||||
|
body = await request.body()
|
||||||
|
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
judd_resp = await client.request(
|
||||||
|
request.method,
|
||||||
|
url,
|
||||||
|
headers={k: v for k, v in request.headers.items() if k.lower() != "host"},
|
||||||
|
params=request.query_params,
|
||||||
|
content=body,
|
||||||
|
)
|
||||||
|
except httpx.RequestError:
|
||||||
|
return response
|
||||||
|
|
||||||
|
return Response(
|
||||||
|
content=judd_resp.content,
|
||||||
|
status_code=judd_resp.status_code,
|
||||||
|
headers=dict(judd_resp.headers),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.middleware("http")
|
||||||
|
async def force_cors_on_errors(request: Request, call_next):
|
||||||
|
response = await call_next(request)
|
||||||
origin = request.headers.get("origin")
|
origin = request.headers.get("origin")
|
||||||
if origin == settings.frontend_url:
|
if origin == settings.frontend_url:
|
||||||
response.headers["Access-Control-Allow-Origin"] = origin
|
response.headers["Access-Control-Allow-Origin"] = origin
|
||||||
|
|
@ -188,10 +164,9 @@ app.include_router(equipment_history.router, prefix="/api/v1")
|
||||||
app.include_router(equipment.router, prefix="/api/v1")
|
app.include_router(equipment.router, prefix="/api/v1")
|
||||||
app.include_router(Ranking.router, prefix="/api/v1")
|
app.include_router(Ranking.router, prefix="/api/v1")
|
||||||
app.include_router(twitter_link.router, prefix="/api/v1")
|
app.include_router(twitter_link.router, prefix="/api/v1")
|
||||||
app.include_router(ranking_grabstats.router, prefix="/api/v1")
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
uvicorn.run("main:app", host="0.0.0.0", port=settings.port, reload=False)
|
uvicorn.run("main:app", host="0.0.0.0", port=settings.port, reload=True)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
start()
|
start()
|
||||||
|
|
@ -5,48 +5,47 @@ description = "Backend for SplatNet"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotated-doc==0.0.5",
|
"annotated-doc==0.0.4",
|
||||||
"annotated-types==0.7.0",
|
"annotated-types==0.7.0",
|
||||||
"anyio==4.14.1",
|
"anyio==4.12.1",
|
||||||
"argon2-cffi==25.1.0",
|
"argon2-cffi==25.1.0",
|
||||||
"argon2-cffi-bindings==25.1.0",
|
"argon2-cffi-bindings==25.1.0",
|
||||||
"certifi==2026.7.22",
|
"certifi==2026.2.25",
|
||||||
"cffi==2.1.1",
|
"cffi==2.0.0",
|
||||||
"charset-normalizer==3.4.9",
|
"charset-normalizer==3.4.4",
|
||||||
"click==8.4.2",
|
"click==8.3.1",
|
||||||
"colorama==0.4.6",
|
"colorama==0.4.6",
|
||||||
"cryptography==50.0.0",
|
"cryptography==46.0.5",
|
||||||
"fastapi==0.141.1",
|
"fastapi==0.134.0",
|
||||||
"fastapi-cache2==0.2.2",
|
"fastapi-cache2==0.2.2",
|
||||||
"greenlet==3.5.5",
|
"greenlet==3.3.2",
|
||||||
"h11==0.16.0",
|
"h11==0.16.0",
|
||||||
"httpcore==1.0.9",
|
"httpcore==1.0.9",
|
||||||
"httpx==0.28.1",
|
"httpx==0.28.1",
|
||||||
"idna==3.18",
|
"idna==3.11",
|
||||||
"oauthlib==3.3.1",
|
"oauthlib==3.3.1",
|
||||||
"oead==1.2.9.post4",
|
"oead==1.2.9.post4",
|
||||||
"pendulum==3.2.0",
|
"pendulum==3.2.0",
|
||||||
"psycopg2-binary==2.9.12",
|
"psycopg2-binary==2.9.11",
|
||||||
"pycparser==3.0",
|
"pycparser==3.0",
|
||||||
"pydantic==2.13.4",
|
"pydantic==2.12.5",
|
||||||
"pydantic-core==2.46.4",
|
"pydantic-core==2.41.5",
|
||||||
"pydantic-settings==2.15.0",
|
"pydantic-settings==2.13.1",
|
||||||
"python-dateutil==2.9.0.post0",
|
"python-dateutil==2.9.0.post0",
|
||||||
"python-dotenv==1.2.2",
|
"python-dotenv==1.2.1",
|
||||||
"python-multipart==0.0.32",
|
"python-multipart==0.0.22",
|
||||||
"pyyaml==6.0.3",
|
"pyyaml==6.0.3",
|
||||||
"requests==2.34.2",
|
"requests==2.32.5",
|
||||||
"requests-oauthlib==2.0.0",
|
"requests-oauthlib==2.0.0",
|
||||||
"six==1.17.0",
|
"six==1.17.0",
|
||||||
"sqlalchemy==2.0.51",
|
"sqlalchemy==2.0.48",
|
||||||
"starlette==1.6.0",
|
"starlette==0.52.1",
|
||||||
"tweepy==4.17.0",
|
"tweepy==4.16.0",
|
||||||
"typing-extensions==4.16.0",
|
"typing-extensions==4.15.0",
|
||||||
"typing-inspection==0.4.3",
|
"typing-inspection==0.4.2",
|
||||||
"tzdata==2026.3",
|
"tzdata==2025.3",
|
||||||
"urllib3==2.7.0",
|
"urllib3==2.6.3",
|
||||||
"uvicorn==0.52.1",
|
"uvicorn==0.41.0",
|
||||||
"jinja2==3.1.6",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,3 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
"extends": ["config:recommended"],
|
}
|
||||||
"packageRules": [
|
|
||||||
{
|
|
||||||
"matchUpdateTypes": ["minor", "patch"],
|
|
||||||
"automerge": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"matchUpdateTypes": ["major"],
|
|
||||||
"automerge": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -37,31 +37,7 @@ RULE_NAMES = {
|
||||||
@cache(expire=3660)
|
@cache(expire=3660)
|
||||||
async def boss_rotation(request: Request):
|
async def boss_rotation(request: Request):
|
||||||
try:
|
try:
|
||||||
def format_stages(stage_list):
|
with open("boss.yaml", "r") as f:
|
||||||
formatted = []
|
|
||||||
for s in stage_list:
|
|
||||||
mid = s.get("MapID")
|
|
||||||
formatted.append({
|
|
||||||
"mapID": mid,
|
|
||||||
"translatedNames": MAP_DATA.get(mid, {"en-US": "Unknown Stage"})
|
|
||||||
})
|
|
||||||
return formatted
|
|
||||||
|
|
||||||
def nintydevsuranidiotforusingrgb(color_val):
|
|
||||||
if not color_val:
|
|
||||||
return "#000000"
|
|
||||||
if isinstance(color_val, str):
|
|
||||||
parts = [float(p.strip()) for p in color_val.split(",") if p.strip()]
|
|
||||||
elif isinstance(color_val, (list, tuple)):
|
|
||||||
parts = [float(p) for p in color_val]
|
|
||||||
else:
|
|
||||||
return "#000000"
|
|
||||||
|
|
||||||
# trash 4th val
|
|
||||||
rgb = [round(c * 255) for c in parts[:3]]
|
|
||||||
return f"#{rgb[0]:02X}{rgb[1]:02X}{rgb[2]:02X}"
|
|
||||||
|
|
||||||
with open("boss.yaml", "r", encoding='utf-8') as f:
|
|
||||||
yaml_data = yaml.safe_load(f)
|
yaml_data = yaml.safe_load(f)
|
||||||
|
|
||||||
start_time = yaml_data.get("DateTime")
|
start_time = yaml_data.get("DateTime")
|
||||||
|
|
@ -74,6 +50,16 @@ async def boss_rotation(request: Request):
|
||||||
for phase in yaml_data.get("Phases", []):
|
for phase in yaml_data.get("Phases", []):
|
||||||
ts_ms = str(int(current_rotation_start.timestamp() * 1000))
|
ts_ms = str(int(current_rotation_start.timestamp() * 1000))
|
||||||
|
|
||||||
|
def format_stages(stage_list):
|
||||||
|
formatted = []
|
||||||
|
for s in stage_list:
|
||||||
|
mid = s.get("MapID")
|
||||||
|
formatted.append({
|
||||||
|
"mapID": mid,
|
||||||
|
"translatedNames": MAP_DATA.get(mid, {"en-US": "Unknown Stage"})
|
||||||
|
})
|
||||||
|
return formatted
|
||||||
|
|
||||||
duration = phase.get("Time", 4)
|
duration = phase.get("Time", 4)
|
||||||
rotations[ts_ms] = {
|
rotations[ts_ms] = {
|
||||||
"startTime": current_rotation_start.isoformat(),
|
"startTime": current_rotation_start.isoformat(),
|
||||||
|
|
@ -93,47 +79,6 @@ async def boss_rotation(request: Request):
|
||||||
"rotations": rotations
|
"rotations": rotations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
|
||||||
with open("fes_boss.yaml", "r", encoding='utf-8') as f:
|
|
||||||
fes_yaml = yaml.safe_load(f)
|
|
||||||
|
|
||||||
if fes_yaml:
|
|
||||||
time_cfg = fes_yaml.get("Time", {})
|
|
||||||
|
|
||||||
def parse_iso(iso_str):
|
|
||||||
if not iso_str: return None
|
|
||||||
return int(datetime.fromisoformat(iso_str.replace('Z', '+00:00')).timestamp())
|
|
||||||
|
|
||||||
fest_start = parse_iso(time_cfg.get("Start"))
|
|
||||||
fest_end = parse_iso(time_cfg.get("End"))
|
|
||||||
fest_announce = parse_iso(time_cfg.get("Announce"))
|
|
||||||
fest_result = parse_iso(time_cfg.get("Result"))
|
|
||||||
|
|
||||||
teams = fes_yaml.get("Teams", [])
|
|
||||||
formatted_teams = []
|
|
||||||
for team in teams:
|
|
||||||
raw_color = team.get("Color")
|
|
||||||
formatted_teams.append({
|
|
||||||
"shortName": team.get("ShortName", {}),
|
|
||||||
"color": nintydevsuranidiotforusingrgb(raw_color)
|
|
||||||
})
|
|
||||||
|
|
||||||
response_data["splatfestivalSplatfest"] = {
|
|
||||||
"stages": format_stages(fes_yaml.get("Stages", [])),
|
|
||||||
"mode": RULE_NAMES.get(fes_yaml.get("Rule"), "TurfWar"),
|
|
||||||
"teams": formatted_teams,
|
|
||||||
"battleResultRate": fes_yaml.get("BattleResultRate", {}),
|
|
||||||
"time": {
|
|
||||||
"start": fest_start,
|
|
||||||
"end": fest_end,
|
|
||||||
"annoucement": fest_announce,
|
|
||||||
"results": fest_result
|
|
||||||
},
|
|
||||||
"festivalID": fes_yaml.get("FestivalId", 0)
|
|
||||||
}
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return response_data
|
return response_data
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ async def get_equipment_composite(request: Request, db: DBSession = Depends(get_
|
||||||
try:
|
try:
|
||||||
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
||||||
token_data = auth.get_token(user.username, decrypted_pass)
|
token_data = auth.get_token(user.username, decrypted_pass)
|
||||||
profile = auth.get_profile(token_data["access_token"])
|
profile = json.loads(auth.get_profile(token_data["token"]))
|
||||||
pid_val = int(profile.get("pid"))
|
pid_val = int(profile.get("pid"))
|
||||||
mii_name = profile.get("name", user.username)
|
mii_name = profile.get("name", user.username)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ async def get_history(request: Request, db: DBSession = Depends(get_db)):
|
||||||
try:
|
try:
|
||||||
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
||||||
token_data = auth.get_token(user.username, decrypted_pass)
|
token_data = auth.get_token(user.username, decrypted_pass)
|
||||||
profile = auth.get_profile(token_data["access_token"])
|
profile = json.loads(auth.get_profile(token_data["token"]))
|
||||||
pid_val = int(profile.get("pid"))
|
pid_val = int(profile.get("pid"))
|
||||||
print(f"Fetching History for PID: {pid_val}")
|
print(f"Fetching History for PID: {pid_val}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,10 @@ async def get_my_profile(request: Request, db: DBSession = Depends(get_db)):
|
||||||
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
||||||
|
|
||||||
token_data = auth.get_token(user.username, decrypted_pass)
|
token_data = auth.get_token(user.username, decrypted_pass)
|
||||||
if not token_data or "access_token" not in token_data:
|
if not token_data or "token" not in token_data:
|
||||||
return RedirectResponse(url="/sign_in/")
|
return RedirectResponse(url="/sign_in/")
|
||||||
|
|
||||||
profile_data = auth.get_profile(token_data["access_token"])
|
profile_data = auth.get_profile(token_data["token"])
|
||||||
if not profile_data:
|
if not profile_data:
|
||||||
raise HTTPException(status_code=404, detail="Profile not found")
|
raise HTTPException(status_code=404, detail="Profile not found")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
|
||||||
from sqlalchemy.orm import Session as DBSession
|
|
||||||
from sqlalchemy import desc
|
|
||||||
from database import SessionLocal, PlayerRank, EquipmentLast
|
|
||||||
from fastapi_cache.decorator import cache
|
|
||||||
|
|
||||||
router = APIRouter()
|
|
||||||
|
|
||||||
def get_db():
|
|
||||||
db = SessionLocal()
|
|
||||||
try:
|
|
||||||
yield db
|
|
||||||
finally:
|
|
||||||
db.close()
|
|
||||||
|
|
||||||
@router.get("/leaderboard/getplayerstats/{pid}")
|
|
||||||
@cache(expire=60)
|
|
||||||
async def get_player_stats(pid: int, mode: int | None = None, db: DBSession = Depends(get_db)):
|
|
||||||
try:
|
|
||||||
query = (
|
|
||||||
db.query(PlayerRank, EquipmentLast)
|
|
||||||
.outerjoin(EquipmentLast, PlayerRank.PId == EquipmentLast.PId)
|
|
||||||
.filter(PlayerRank.PId == pid)
|
|
||||||
)
|
|
||||||
|
|
||||||
if mode is not None:
|
|
||||||
query = query.filter(PlayerRank.GameMode == mode)
|
|
||||||
|
|
||||||
result = query.first()
|
|
||||||
|
|
||||||
if not result:
|
|
||||||
raise HTTPException(status_code=404, detail="Player not found")
|
|
||||||
|
|
||||||
player, gear = result
|
|
||||||
|
|
||||||
player_data = {
|
|
||||||
"PId": player.PId,
|
|
||||||
"MiiName": player.MiiName,
|
|
||||||
"Rank": player.Rank,
|
|
||||||
"GameMode": player.GameMode,
|
|
||||||
"WinSum": player.WinSum,
|
|
||||||
"LoseSum": player.LoseSum,
|
|
||||||
"RankingScore": round(player.RankingScore, 2),
|
|
||||||
"weapon": gear.weapon if gear else None,
|
|
||||||
"headgear": gear.Gear_Head if gear else None,
|
|
||||||
"clothes": gear.Gear_Clothes if gear else None,
|
|
||||||
"shoes": gear.Gear_Shoes if gear else None,
|
|
||||||
}
|
|
||||||
|
|
||||||
if player.GameMode == 2:
|
|
||||||
top_100_query = (
|
|
||||||
db.query(PlayerRank.PId)
|
|
||||||
.order_by(desc(PlayerRank.FesPower))
|
|
||||||
.limit(100)
|
|
||||||
.all()
|
|
||||||
)
|
|
||||||
top_100_tuples = set(top_100_query)
|
|
||||||
|
|
||||||
is_top_100 = (player.PId,) in top_100_tuples
|
|
||||||
player_data["FesPower"] = player.FesPower
|
|
||||||
player_data["is_top_100_fes"] = is_top_100
|
|
||||||
else:
|
|
||||||
player_data["FesPower"] = None
|
|
||||||
player_data["is_top_100_fes"] = False
|
|
||||||
|
|
||||||
return player_data
|
|
||||||
|
|
||||||
except HTTPException as http_ex:
|
|
||||||
raise http_ex
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error fetching stats for player {pid}: {e}")
|
|
||||||
return {"error": str(e)}
|
|
||||||
|
|
@ -37,26 +37,27 @@ async def login(
|
||||||
try:
|
try:
|
||||||
print("fetching spfn token")
|
print("fetching spfn token")
|
||||||
data = auth.get_token(username, password)
|
data = auth.get_token(username, password)
|
||||||
if not data or "access_token" not in data:
|
if not data or "token" not in data:
|
||||||
print("auth failed")
|
print("auth failed")
|
||||||
return RedirectResponse(f"{auth_path}{sep}error=auth&username={username}", 303)
|
return RedirectResponse(f"{auth_path}{sep}error=auth&username={username}", 303)
|
||||||
|
|
||||||
print(f"checking user {username}")
|
print(f"checking user {username}")
|
||||||
user = db.query(User).filter(User.username == username).first()
|
user = db.query(User).filter(User.username == username).first()
|
||||||
|
|
||||||
enc_pass = cipher.encrypt(password.encode()).decode()
|
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
print("creating new user with argon2id")
|
print("creating new user with argon2id")
|
||||||
|
enc_pass = cipher.encrypt(password.encode()).decode() if rememberMe else ""
|
||||||
user = User(
|
user = User(
|
||||||
username=username,
|
username=username,
|
||||||
local_hash=auth.hash_password(password),
|
local_hash=auth.hash_password(password),
|
||||||
spfn_pass_enc=enc_pass
|
spfn_pass_enc=enc_pass
|
||||||
)
|
)
|
||||||
db.add(user)
|
db.add(user)
|
||||||
else:
|
elif rememberMe:
|
||||||
print("updating encrypted pass for client")
|
print("updating encrypted pass for client")
|
||||||
user.spfn_pass_enc = enc_pass
|
user.spfn_pass_enc = cipher.encrypt(password.encode()).decode()
|
||||||
|
else:
|
||||||
|
print("client requested no password storage, skipping update")
|
||||||
|
|
||||||
db.flush()
|
db.flush()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ async def confirm_twitter(state: str, code: str, db: DBSession = Depends(get_db)
|
||||||
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
||||||
profile_auth = auth.get_token(user.username, decrypted_pass)
|
profile_auth = auth.get_token(user.username, decrypted_pass)
|
||||||
|
|
||||||
profile_response = auth.get_profile(profile_auth["access_token"])
|
profile_response = auth.get_profile(profile_auth["token"])
|
||||||
|
|
||||||
if isinstance(profile_response, str):
|
if isinstance(profile_response, str):
|
||||||
try:
|
try:
|
||||||
|
|
@ -149,7 +149,7 @@ async def get_twitter_status(request: Request, db: DBSession = Depends(get_db)):
|
||||||
try:
|
try:
|
||||||
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
||||||
profile_auth = auth.get_token(user.username, decrypted_pass)
|
profile_auth = auth.get_token(user.username, decrypted_pass)
|
||||||
profile_res = auth.get_profile(profile_auth["access_token"])
|
profile_res = auth.get_profile(profile_auth["token"])
|
||||||
|
|
||||||
if isinstance(profile_res, str):
|
if isinstance(profile_res, str):
|
||||||
profile_data = json.loads(profile_res)
|
profile_data = json.loads(profile_res)
|
||||||
|
|
@ -183,7 +183,7 @@ async def unlink_twitter(request: Request, db: DBSession = Depends(get_db)):
|
||||||
user = db.query(User).filter(User.username == db_session.username).first()
|
user = db.query(User).filter(User.username == db_session.username).first()
|
||||||
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
decrypted_pass = cipher.decrypt(user.spfn_pass_enc.encode()).decode()
|
||||||
profile_auth = auth.get_token(user.username, decrypted_pass)
|
profile_auth = auth.get_token(user.username, decrypted_pass)
|
||||||
profile_data = auth.get_profile(profile_auth["access_token"])
|
profile_data = auth.get_profile(profile_auth["token"])
|
||||||
|
|
||||||
if isinstance(profile_data, str):
|
if isinstance(profile_data, str):
|
||||||
profile_data = json.loads(profile_data)
|
profile_data = json.loads(profile_data)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# Security Policy
|
|
||||||
|
|
||||||
Report security vulnerabilities through the security tab on this repo. Only vulnerabilities on the latest commit of any branch will be considered.
|
|
||||||
|
|
@ -1,41 +1,35 @@
|
||||||
import requests
|
import requests
|
||||||
from config import settings
|
import base64
|
||||||
from argon2 import PasswordHasher
|
from argon2 import PasswordHasher
|
||||||
|
|
||||||
API_URL = "https://account.spbr.net/api/v2"
|
API_URL = "https://account.spfn.net/api/v2"
|
||||||
CLIENT_ID = "splatnet"
|
|
||||||
CLIENT_SECRET = settings.account_client_secret
|
|
||||||
ph = PasswordHasher()
|
ph = PasswordHasher()
|
||||||
|
|
||||||
def hash_password(password: str):
|
def hash_password(password: str):
|
||||||
return ph.hash(password)
|
return ph.hash(password)
|
||||||
|
|
||||||
|
def verify_password(hashed: str, password: str):
|
||||||
|
try:
|
||||||
|
return ph.verify(hashed, password)
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
def get_token(username, password):
|
def get_token(username, password):
|
||||||
url = f"{API_URL}/oauth2/generate_token"
|
creds = f"{username} {password}"
|
||||||
|
encoded = base64.b64encode(creds.encode()).decode()
|
||||||
payload = {
|
|
||||||
"grant_type": "password",
|
|
||||||
"username": username,
|
|
||||||
"password": password,
|
|
||||||
"client_id": CLIENT_ID,
|
|
||||||
"client_secret": CLIENT_SECRET
|
|
||||||
}
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "chiyo & eri should lwk kiss..."
|
"Authorization": f"Basic {encoded}",
|
||||||
|
"User-Agent": "saturday & allison should lwk kiss..."
|
||||||
}
|
}
|
||||||
|
|
||||||
response = requests.post(url, data=payload, headers=headers, timeout=10)
|
response = requests.get(f"{API_URL}/oauth2/generate_token", headers=headers, timeout=10)
|
||||||
return response.json() if response.ok else None
|
return response.json() if response.ok else None
|
||||||
|
|
||||||
def get_profile(token):
|
def get_profile(token):
|
||||||
url = f"{API_URL}/users/@me/profile"
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {token}",
|
"Authorization": f"Bearer {token}",
|
||||||
"User-Agent": "lets make the most of the night like were gonna die young!!"
|
"User-Agent": "every update im going to change this user agent because im bored!!"
|
||||||
}
|
}
|
||||||
|
response = requests.get(f"{API_URL}/users/@me/profile", headers=headers, timeout=10)
|
||||||
response = requests.get(url, headers=headers, timeout=10)
|
return response.text if response.ok else None
|
||||||
|
|
||||||
return response.json() if response.ok else None
|
|
||||||
|
|
@ -7,85 +7,54 @@ from config import settings, BASE_DIR
|
||||||
|
|
||||||
def process_boss_file():
|
def process_boss_file():
|
||||||
temp_boss = "bosstemp.bin"
|
temp_boss = "bosstemp.bin"
|
||||||
|
output_yaml = "boss.yaml"
|
||||||
decrypt_script = os.path.join(BASE_DIR, "services", "decrypt.js")
|
decrypt_script = os.path.join(BASE_DIR, "services", "decrypt.js")
|
||||||
|
|
||||||
if not os.path.exists(decrypt_script):
|
if not os.path.exists(decrypt_script):
|
||||||
print(f"{decrypt_script} is missing!")
|
print(f"{decrypt_script} is missing!")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
base_url = settings.boss_url.rstrip('/')
|
|
||||||
tasks = [
|
|
||||||
{
|
|
||||||
"url": f"{base_url}/zvGSM4kOrXpkKnpT/schdat2?c=JP&l=en",
|
|
||||||
"filename": "VSSetting.byaml",
|
|
||||||
"output": "boss.yaml"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": f"{base_url}/zvGSM4kOrXpkKnpT/optdat2?c=US&l=en",
|
|
||||||
"filename": "Festival.byaml",
|
|
||||||
"output": "fes_boss.yaml"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
success_all = True
|
master_url = settings.boss_url
|
||||||
for task in tasks:
|
print(f"data get: {master_url}")
|
||||||
master_url = task["url"]
|
meta_res = requests.get(master_url, timeout=10)
|
||||||
target_filename = task["filename"]
|
meta_res.raise_for_status()
|
||||||
output_yaml = task["output"]
|
root = ET.fromstring(meta_res.content)
|
||||||
|
data_url_element = root.find(".//Url")
|
||||||
|
if data_url_element is None or not data_url_element.text:
|
||||||
|
print("woops! no <Url> tag found in the XML response")
|
||||||
|
return False
|
||||||
|
real_data_url = data_url_element.text.strip()
|
||||||
|
print(f"parsed data url: {real_data_url}")
|
||||||
|
res = requests.get(real_data_url, timeout=10)
|
||||||
|
res.raise_for_status()
|
||||||
|
|
||||||
|
with open(temp_boss, "wb") as f:
|
||||||
|
f.write(res.content)
|
||||||
|
|
||||||
print(f"data get: {master_url}")
|
node_env = os.environ.copy()
|
||||||
meta_res = requests.get(master_url, timeout=10)
|
node_env["BOSS_AES_KEY"] = settings.boss_aes_key
|
||||||
meta_res.raise_for_status()
|
node_env["BOSS_HMAC_KEY"] = settings.boss_hmac_key
|
||||||
root = ET.fromstring(meta_res.content)
|
|
||||||
|
|
||||||
# LMFAO HOW DID THIS FLY UNDER THE RADAR FOR SO LONG
|
|
||||||
real_data_url = None
|
|
||||||
for file_element in root.findall(".//File"):
|
|
||||||
filename_elem = file_element.find("Filename")
|
|
||||||
if filename_elem is not None and filename_elem.text == target_filename:
|
|
||||||
url_elem = file_element.find("Url")
|
|
||||||
if url_elem is not None and url_elem.text:
|
|
||||||
real_data_url = url_elem.text.strip()
|
|
||||||
break
|
|
||||||
|
|
||||||
if not real_data_url:
|
|
||||||
print(f"woops! could not find URL for file '{target_filename}' in the XML response")
|
|
||||||
success_all = False
|
|
||||||
continue
|
|
||||||
|
|
||||||
print(f"parsed data url for {target_filename}: {real_data_url}")
|
result = subprocess.run(
|
||||||
res = requests.get(real_data_url, timeout=10)
|
['node', decrypt_script, temp_boss],
|
||||||
res.raise_for_status()
|
capture_output=True,
|
||||||
|
text=False,
|
||||||
with open(temp_boss, "wb") as f:
|
env=node_env
|
||||||
f.write(res.content)
|
)
|
||||||
|
|
||||||
|
if result.returncode != 0:
|
||||||
|
print(f"decrypt fail! {result.stderr.decode()}")
|
||||||
|
return False
|
||||||
|
|
||||||
node_env = os.environ.copy()
|
byml_obj = oead.byml.from_binary(result.stdout)
|
||||||
node_env["BOSS_AES_KEY"] = settings.boss_aes_key
|
yaml_content = oead.byml.to_text(byml_obj)
|
||||||
node_env["BOSS_HMAC_KEY"] = settings.boss_hmac_key
|
|
||||||
|
with open(output_yaml, "w", encoding="utf-8") as f:
|
||||||
result = subprocess.run(
|
f.write(yaml_content)
|
||||||
['node', decrypt_script, temp_boss],
|
|
||||||
capture_output=True,
|
|
||||||
text=False,
|
|
||||||
env=node_env
|
|
||||||
)
|
|
||||||
|
|
||||||
if result.returncode != 0:
|
print(f"yay! success: {output_yaml}")
|
||||||
print(f"decrypt fail! {result.stderr.decode()}")
|
return True
|
||||||
success_all = False
|
|
||||||
continue
|
|
||||||
|
|
||||||
byml_obj = oead.byml.from_binary(result.stdout)
|
|
||||||
yaml_content = oead.byml.to_text(byml_obj)
|
|
||||||
|
|
||||||
with open(output_yaml, "w", encoding="utf-8") as f:
|
|
||||||
f.write(yaml_content)
|
|
||||||
|
|
||||||
print(f"yay! success: {output_yaml}")
|
|
||||||
|
|
||||||
return success_all
|
|
||||||
|
|
||||||
except ET.ParseError:
|
except ET.ParseError:
|
||||||
print("woops! the url returned non xml... we're hanging here")
|
print("woops! the url returned non xml... we're hanging here")
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# Support
|
|
||||||
|
|
||||||
For support, join [our discord](https://discord.gg/splatfestival).
|
|
||||||
Loading…
Reference in a new issue