Skip to content

Commit

Permalink
Merge pull request #44 from Thomas-Smyth/beta
Browse files Browse the repository at this point in the history
SquadJS v1.3.0
  • Loading branch information
Thomas-Smyth authored Aug 29, 2020
2 parents dbfa0ec + 47258fa commit 083432c
Show file tree
Hide file tree
Showing 73 changed files with 6,000 additions and 1,691 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2020
},
"extends": [
"standard",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.tmp

index-test.js
config-test.json

# Dependencies
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"printWidth": 100
"printWidth": 100,
"trailingComma": "none"
}
520 changes: 506 additions & 14 deletions README.md

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"server": {
"id": 1,
"host": "xxx.xxx.xxx.xxx",
"queryPort": 27165,
"rconPort": 21114,
"rconPassword": "password",
"logReaderMode": "tail",
"logDir": "C:/path/to/squad/log/folder",
"ftpPort": 21,
"ftpUser": "FTP Username",
"ftpPassword": "FTP Password",
"rconVerbose": true
},
"connectors": {
"discord": "Discord Login Token",
"layerFilter": {
"type": "buildFromFilter",
"filter": {
"whitelistedLayers": null,
"blacklistedLayers": null,
"whitelistedMaps": null,
"blacklistedMaps": null,
"whitelistedGamemodes": null,
"blacklistedGamemodes": [
"Training"
],
"flagCountMin": null,
"flagCountMax": null,
"hasCommander": null,
"hasTanks": null,
"hasHelicopters": null
},
"activeLayerFilter": {
"historyResetTime": 18000000,
"layerHistoryTolerance": 8,
"mapHistoryTolerance": 4,
"gamemodeHistoryTolerance": {
"Invasion": 4
},
"gamemodeRepetitiveTolerance": {
"Invasion": 4
},
"playerCountComplianceEnabled": true,
"factionComplianceEnabled": true,
"factionHistoryTolerance": {
"RUS": 4
},
"factionRepetitiveTolerance": {
"RUS": 4
}
}
},
"mysql": {
"connectionLimit": 10,
"host": "host",
"port": 3306,
"user": "squadjs",
"password": "password",
"database": "squadjs"
}
},
"plugins": [
{
"plugin": "auto-tk-warn",
"enabled": true,
"message": "Please apologise for ALL TKs in ALL chat!"
},
{
"plugin": "discord-admin-broadcast",
"enabled": true,
"discordClient": "discord",
"channelID": "Discord Channel ID",
"color": 16761867
},
{
"plugin": "discord-admin-cam-logs",
"enabled": true,
"discordClient": "discord",
"channelID": "Discord Channel ID",
"color": 16761867
},
{
"plugin": "discord-chat",
"enabled": true,
"discordClient": "discord",
"channelID": "Discord Channel ID",
"ignoreChats": [
"ChatSquad"
],
"chatColors": {},
"color": 16761867
},
{
"plugin": "discord-admin-request",
"enabled": true,
"discordClient": "discord",
"channelID": "Discord Channel ID",
"ignoreChats": [
"ChatSquad"
],
"ignorePhrases": [],
"adminPrefix": "!admin",
"pingGroups": [],
"pingDelay": 60000,
"color": 16761867
},
{
"plugin": "discord-debug",
"enabled": false,
"discordClient": "discord",
"channelID": "Discord Channel ID",
"events": []
},
{
"plugin": "discord-rcon",
"enabled": true,
"discordClient": "discord",
"channelID": "Discord Channel ID",
"prependAdminNameInBroadcast": false
},
{
"plugin": "discord-server-status",
"enabled": true,
"discordClient": "discord",
"color": 16761867,
"colorGradient": true,
"connectLink": true,
"command": "!server",
"disableStatus": false
},
{
"plugin": "discord-teamkill",
"enabled": true,
"discordClient": "discord",
"channelID": "Discord Channel ID",
"teamkillColor": 16761867,
"suicideColor": 16761867,
"ignoreSuicides": false,
"disableSCBL": false
},
{
"plugin": "mapvote-123",
"enabled": false,
"minVoteCount": null
},
{
"plugin": "mapvote-did-you-mean",
"enabled": false,
"layerFilter": "layerFilter",
"alwaysOn": true,
"minPlayerCount": null,
"minVoteCount": null
},
{
"plugin": "mysql-log",
"enabled": false,
"mysqlPool": "mysql",
"overrideServerID": null
},
{
"plugin": "seeding-message",
"enabled": true,
"mode": "interval",
"interval": 150000,
"delay": 45000,
"seedingThreshold": 50,
"seedingMessage": "Seeding Rules Active! Fight only over the middle flags! No FOB Hunting!",
"liveEnabled": true,
"liveThreshold": 2,
"liveMessage": "Live"
},
{
"plugin": "team-randomizer",
"enabled": true,
"command": "!randomize"
}
]
}
14 changes: 0 additions & 14 deletions connectors/package.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 0 additions & 4 deletions core/config.js

This file was deleted.

14 changes: 14 additions & 0 deletions core/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const SQUADJS_VERSION = JSON.parse(
fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')
).version;

/* As set out by the terms of the license, the following should not be modified. */
const COPYRIGHT_MESSAGE = 'SquadJS, Copyright © 2020 Thomas Smyth';

export { SQUADJS_VERSION, COPYRIGHT_MESSAGE };
12 changes: 10 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
"version": "1.0.0",
"type": "module",
"exports": {
"./config": "./config.js",
"./squad-layers": "./squad-layers/index.js",

"./utils/print-logo": "./utils/print-logo.js",
"./utils/sleep": "./utils/sleep.js"
"./utils/scbl": "./utils/scbl.js",
"./utils/sleep": "./utils/sleep.js",

"./constants": "./constants.js"
},
"dependencies": {
"didyoumean": "^1.2.1",
"graphql-request": "^1.8.2"
}
}
4 changes: 4 additions & 0 deletions core/squad-layers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import SquadLayers from './squad-layers.js';
import SquadLayerFilter from './squad-layer-filter.js';

export { SquadLayers, SquadLayerFilter };
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default class SquadLayerFilter extends SquadLayersClass {
return new SquadLayerFilter(layers, activeLayerFilter);
}

static buildFromFile(filename, activeLayerFilter, delimiter = '\n') {
const lines = fs.readFileSync('./connectors/data/layers.json', 'utf8').split(delimiter);
static buildFromFile(path, activeLayerFilter, delimiter = '\n') {
const lines = fs.readFileSync(path, 'utf8').split(delimiter);
const layers = [];

const validLayerNames = SquadLayers.getLayerNames();
Expand Down
16 changes: 10 additions & 6 deletions connectors/squad-layers.js → core/squad-layers/squad-layers.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import fs from 'fs';
import { fileURLToPath } from 'url';
import path from 'path';

import didYouMean from 'didyoumean';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

class SquadLayers {
constructor(layers) {
if (Array.isArray(layers)) {
this.layers = layers;
} else {
this.layers = JSON.parse(fs.readFileSync('./connectors/data/layers.json', 'utf8'));
this.layers = JSON.parse(fs.readFileSync(path.resolve(__dirname, './layers.json'), 'utf8'));
}

for (let i = 0; i < this.layers.length; i++) {
Expand All @@ -23,28 +27,28 @@ class SquadLayers {
}

getLayerNames() {
return this.layers.map(layer => layer.layer);
return this.layers.map((layer) => layer.layer);
}

getLayerByLayerName(layerName) {
const layer = this.layers.filter(layer => layer.layer === layerName);
const layer = this.layers.filter((layer) => layer.layer === layerName);
return layer.length === 1 ? layer[0] : null;
}

getLayerByLayerClassname(layerClassname) {
const layer = this.layers.filter(layer => layer.layerClassname === layerClassname);
const layer = this.layers.filter((layer) => layer.layerClassname === layerClassname);
return layer.length === 1 ? layer[0] : null;
}

getLayerByDidYouMean(layerName) {
layerName = didYouMean(layerName, this.getLayerNames());

const layer = this.layers.filter(layer => layer.layer === layerName);
const layer = this.layers.filter((layer) => layer.layer === layerName);
return layer.length === 1 ? layer[0] : null;
}

getLayerByNumber(number) {
const layer = this.layers.filter(layer => layer.layerNumber === number);
const layer = this.layers.filter((layer) => layer.layerNumber === number);
return layer.length === 1 ? layer[0] : null;
}
}
Expand Down
21 changes: 11 additions & 10 deletions core/utils/print-logo.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { COPYRIGHT_MESSAGE } from '../config.js';
import { SQUADJS_VERSION, COPYRIGHT_MESSAGE } from '../constants.js';

const LOGO = `
_____ ____ _ _ _____ _
/ ____|/ __ \\| | | | /\\ | __ \\ (_)
| (___ | | | | | | | / \\ | | | | _ ___
\\___ \\| | | | | | |/ /\\ \\ | | | || / __|
____) | |__| | |__| / ____ \\| |__| || \\__ \\
|_____/ \\___\\_\\\\____/_/ \\_\\_____(_) |___/
_/ |
|__/
_____ ____ _ _ _____ \x1b[33m_\x1b[0m
/ ____|/ __ \\| | | | /\\ | __ \\ \x1b[33m(_)\x1b[0m
| (___ | | | | | | | / \\ | | | | \x1b[33m_ ___\x1b[0m
\\___ \\| | | | | | |/ /\\ \\ | | | |\x1b[33m| / __|\x1b[0m
____) | |__| | |__| / ____ \\| |__| |\x1b[33m| \\__ \\\x1b[0m
|_____/ \\___\\_\\\\____/_/ \\_\\_____\x1b[33m(_) |___/\x1b[0m
\x1b[33m_/ |\x1b[0m
\x1b[33m|__/\x1b[0m
${COPYRIGHT_MESSAGE}
GitHub: https://github.com/Thomas-Smyth/SquadJS
Version: ${SQUADJS_VERSION}
`;

export default function() {
export default function () {
console.log(LOGO);
}
2 changes: 1 addition & 1 deletion connectors/scbl.js → core/utils/scbl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { request } from 'graphql-request';

const API_ENDPOINT = 'https://squad-community-ban-list.com/graphql';

export default function(query, variables) {
export default function (query, variables) {
return request(API_ENDPOINT, query, variables);
}
4 changes: 2 additions & 2 deletions core/utils/sleep.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default function(time) {
return new Promise(resolve => {
export default function (time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}
Loading

0 comments on commit 083432c

Please sign in to comment.