first version POC of python/flask port of server

master
Michael Murtaugh 3 years ago
parent cd76893f23
commit 8a8ca31c2c

File diff suppressed because one or more lines are too long

@ -0,0 +1,10 @@
const fs = require("fs");
const DATA = require("./data");
fs.writeFile('data.json', JSON.stringify(DATA), err => {
if (err) {
console.error(err)
return
}
//file written successfully
})

986
package-lock.json generated

@ -1,8 +1,992 @@
{
"name": "chat",
"version": "0.0.1",
"lockfileVersion": 1,
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "chat",
"version": "0.0.1",
"dependencies": {
"bad-words": "^3.0.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"rita": "^1.3.94",
"socket.io": "^2.3.0"
}
},
"node_modules/accepts": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
"integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
"dependencies": {
"mime-types": "~2.1.24",
"negotiator": "0.6.2"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/after": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
"integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8="
},
"node_modules/argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"optional": true,
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"node_modules/arraybuffer.slice": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz",
"integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog=="
},
"node_modules/async-limiter": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
},
"node_modules/backo2": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
"integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc="
},
"node_modules/bad-words": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/bad-words/-/bad-words-3.0.3.tgz",
"integrity": "sha512-To+nGz+U8SpEQieZ2kSadY/1hVO88UXAslCJuTgLjDOuGrs/tNW2BYwl0fctxcRLooe0nzYN1pGzgvRIrd0BeA==",
"dependencies": {
"badwords-list": "^1.0.0"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/badwords-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/badwords-list/-/badwords-list-1.0.0.tgz",
"integrity": "sha1-XphW2/E0gqKVw7CzBK+51M/FxXk="
},
"node_modules/balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"optional": true
},
"node_modules/base64-arraybuffer": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=",
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/base64id": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
"integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
"engines": {
"node": "^4.5.0 || >= 5.9"
}
},
"node_modules/better-assert": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz",
"integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=",
"dependencies": {
"callsite": "1.0.0"
},
"engines": {
"node": "*"
}
},
"node_modules/blob": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
"integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig=="
},
"node_modules/body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
"integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
"dependencies": {
"bytes": "3.1.0",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "~1.1.2",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"on-finished": "~2.3.0",
"qs": "6.7.0",
"raw-body": "2.4.0",
"type-is": "~1.6.17"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"optional": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/callsite": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
"integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=",
"engines": {
"node": "*"
}
},
"node_modules/component-bind": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
"integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E="
},
"node_modules/component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"node_modules/component-inherit": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz",
"integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM="
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"optional": true
},
"node_modules/content-disposition": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
"integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
"dependencies": {
"safe-buffer": "5.1.2"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
"integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/destroy": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"node_modules/dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==",
"engines": {
"node": ">=8"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/engine.io": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.4.0.tgz",
"integrity": "sha512-XCyYVWzcHnK5cMz7G4VTu2W7zJS7SM1QkcelghyIk/FmobWBtXE7fwhBusEKvCSqc3bMh8fNFMlUkCKTFRxH2w==",
"dependencies": {
"accepts": "~1.3.4",
"base64id": "2.0.0",
"cookie": "0.3.1",
"debug": "~4.1.0",
"engine.io-parser": "~2.2.0",
"ws": "^7.1.2"
}
},
"node_modules/engine.io-client": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.0.tgz",
"integrity": "sha512-a4J5QO2k99CM2a0b12IznnyQndoEvtA4UAldhGzKqnHf42I3Qs2W5SPnDvatZRcMaNZs4IevVicBPayxYt6FwA==",
"dependencies": {
"component-emitter": "1.2.1",
"component-inherit": "0.0.3",
"debug": "~4.1.0",
"engine.io-parser": "~2.2.0",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"ws": "~6.1.0",
"xmlhttprequest-ssl": "~1.5.4",
"yeast": "0.1.2"
}
},
"node_modules/engine.io-client/node_modules/debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/engine.io-client/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/engine.io-client/node_modules/ws": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz",
"integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==",
"dependencies": {
"async-limiter": "~1.0.0"
}
},
"node_modules/engine.io-parser": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.0.tgz",
"integrity": "sha512-6I3qD9iUxotsC5HEMuuGsKA0cXerGz+4uGcXQEkfBidgKf0amsjrrtwcbwK/nzpZBxclXlV7gGl9dgWvu4LF6w==",
"dependencies": {
"after": "0.8.2",
"arraybuffer.slice": "~0.0.7",
"base64-arraybuffer": "0.1.5",
"blob": "0.0.5",
"has-binary2": "~1.0.2"
}
},
"node_modules/engine.io/node_modules/cookie": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/engine.io/node_modules/debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/engine.io/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
"integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
"dependencies": {
"accepts": "~1.3.7",
"array-flatten": "1.1.1",
"body-parser": "1.19.0",
"content-disposition": "0.5.3",
"content-type": "~1.0.4",
"cookie": "0.4.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "~1.1.2",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.1.2",
"fresh": "0.5.2",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.5",
"qs": "6.7.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.1.2",
"send": "0.17.1",
"serve-static": "1.14.1",
"setprototypeof": "1.1.1",
"statuses": "~1.5.0",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/finalhandler": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
"integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"statuses": "~1.5.0",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"optional": true
},
"node_modules/glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"optional": true,
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": "*"
}
},
"node_modules/has-binary2": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz",
"integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==",
"dependencies": {
"isarray": "2.0.1"
}
},
"node_modules/has-cors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
"integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk="
},
"node_modules/http-errors": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
"integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
"dependencies": {
"depd": "~1.1.2",
"inherits": "2.0.3",
"setprototypeof": "1.1.1",
"statuses": ">= 1.5.0 < 2",
"toidentifier": "1.0.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10="
},
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"optional": true,
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"node_modules/inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.43.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
"integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.26",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
"integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
"dependencies": {
"mime-db": "1.43.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"optional": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node_modules/negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/object-component": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz",
"integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE="
},
"node_modules/on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
"integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"optional": true,
"dependencies": {
"wrappy": "1"
}
},
"node_modules/parseqs": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz",
"integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=",
"dependencies": {
"better-assert": "~1.0.0"
}
},
"node_modules/parseuri": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz",
"integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=",
"dependencies": {
"better-assert": "~1.0.0"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"optional": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"node_modules/proxy-addr": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
"integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==",
"dependencies": {
"forwarded": "~0.1.2",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==",
"engines": {
"node": ">=0.6"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
"integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
"dependencies": {
"bytes": "3.1.0",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/rita": {
"version": "1.3.94",
"resolved": "https://registry.npmjs.org/rita/-/rita-1.3.94.tgz",
"integrity": "sha512-/E8foRjE+uCZpe35pt1BlyYnWnLB/sw1BN711paLYLl+ebU8k0AXwteKwJlqviyrFlItGtGJOuc6mUMuIUELvQ==",
"engines": {
"node": ">= 0.6"
},
"optionalDependencies": {
"yamljs": "^0.2.10"
}
},
"node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/send": {
"version": "0.17.1",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
"integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
"dependencies": {
"debug": "2.6.9",
"depd": "~1.1.2",
"destroy": "~1.0.4",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "~1.7.2",
"mime": "1.6.0",
"ms": "2.1.1",
"on-finished": "~2.3.0",
"range-parser": "~1.2.1",
"statuses": "~1.5.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
},
"node_modules/serve-static": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
"integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
"dependencies": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.17.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
},
"node_modules/socket.io": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.3.0.tgz",
"integrity": "sha512-2A892lrj0GcgR/9Qk81EaY2gYhCBxurV0PfmmESO6p27QPrUK1J3zdns+5QPqvUYK2q657nSj0guoIil9+7eFg==",
"dependencies": {
"debug": "~4.1.0",
"engine.io": "~3.4.0",
"has-binary2": "~1.0.2",
"socket.io-adapter": "~1.1.0",
"socket.io-client": "2.3.0",
"socket.io-parser": "~3.4.0"
}
},
"node_modules/socket.io-adapter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz",
"integrity": "sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g=="
},
"node_modules/socket.io-client": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.3.0.tgz",
"integrity": "sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA==",
"dependencies": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
"debug": "~4.1.0",
"engine.io-client": "~3.4.0",
"has-binary2": "~1.0.2",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"socket.io-parser": "~3.3.0",
"to-array": "0.1.4"
}
},
"node_modules/socket.io-client/node_modules/debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/socket.io-client/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/socket.io-client/node_modules/socket.io-parser": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz",
"integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==",
"dependencies": {
"component-emitter": "1.2.1",
"debug": "~3.1.0",
"isarray": "2.0.1"
}
},
"node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node_modules/socket.io-parser": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.4.0.tgz",
"integrity": "sha512-/G/VOI+3DBp0+DJKW4KesGnQkQPFmUCbA/oO2QGT6CWxU7hLGWqU3tyuzeSK/dqcyeHsQg1vTe9jiZI8GU9SCQ==",
"dependencies": {
"component-emitter": "1.2.1",
"debug": "~4.1.0",
"isarray": "2.0.1"
}
},
"node_modules/socket.io-parser/node_modules/debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/socket.io-parser/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/socket.io/node_modules/debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/socket.io/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"optional": true
},
"node_modules/statuses": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/to-array": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz",
"integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA="
},
"node_modules/toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"optional": true
},
"node_modules/ws": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz",
"integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==",
"engines": {
"node": ">=8.3.0"
}
},
"node_modules/xmlhttprequest-ssl": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",
"integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/yamljs": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.2.10.tgz",
"integrity": "sha1-SBzHwlynOvWfWR8MluPOVsdXpA8=",
"optional": true,
"dependencies": {
"argparse": "^1.0.7",
"glob": "^7.0.5"
},
"bin": {
"json2yaml": "bin/json2yaml",
"yaml2json": "bin/yaml2json"
}
},
"node_modules/yeast": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
"integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
}
},
"dependencies": {
"accepts": {
"version": "1.3.7",

@ -427,7 +427,8 @@ function setup() {
document.body.innerHTML = errorMessage;
socket.disconnect();
}
// MM2021HACKING
window.DATA = DATA;
ROOMS = DATA.ROOMS;
SETTINGS = DATA.SETTINGS;
@ -798,7 +799,7 @@ function newGame() {
//
players[p.id] = new Player(p);
//console.log("I shall introduce myself to " + p.id);
// console.log("I shall introduce myself to " + p.id);
//If I"m not the new player send an introduction to the new player
socket.emit("intro", p.id, {

@ -0,0 +1,4 @@
python-socketio==4.6.0
python-engineio==3.13.2
Flask-SocketIO==4.3.1

@ -120,7 +120,7 @@ io.on("connection", function (socket) {
//wait for the player to send their name and info, then broadcast them
socket.on("join", function (playerInfo) {
// console.log("join", playerInfo)
//console.log("Number of sockets " + Object.keys(io.sockets.connected).length);
try {
@ -301,6 +301,7 @@ io.on("connection", function (socket) {
//when I receive an intro send it to the recipient
socket.on("intro", function (newComer, obj) {
//verify the id to make sure a hacked client can"t fake players
// console.log("intro", newComer, obj);
if (obj != null) {
if (obj.id == socket.id) {

@ -0,0 +1,582 @@
import flask
from flask import Flask, render_template
from flask_socketio import SocketIO, send, emit, join_room, leave_room, has_request_context, disconnect
import datetime, time, json, re
PACKETS_PER_SECONDS = 30
"""
The client and server version strings MUST be the same!
They can be used to force clients to hard refresh to load the latest client.
If the server gets updated it can be restarted, but if there are active clients (users' open browsers) they could be outdated and create issues.
If the VERSION vars are mismatched they will send all clients in an infinite refresh loop. Make sure you update sketch.js before restarting server.js
"""
VERSION = "1.0"
# TODO...
with open("data.json") as datafile:
DATA = json.load(datafile)
# time before disconnecting (forgot the tab open?)
ACTIVITY_TIMEOUT = 10 * 60 * 1000
# should be the same as index maxlength="16"
MAX_NAME_LENGTH = 16
# cap the overall players
MAX_PLAYERS = -1
# refuse people when a room is full
MAX_PLAYERS_PER_ROOM = 200
# views since the server started counts relogs
visits = 0
admins = []
# We want the server to keep track of the whole game state
# in this case the game state are the attributes of each player
gameState = {
'players': {},
'NPCs': {}
}
# save the server startup time and send it in case the clients need to syncronize something
START_TIME = datetime.datetime.now()
# a collection of banned IPs
# not permanent, it lasts until the server restarts
banned = []
app = Flask(__name__, static_url_path='', static_folder='public')
# self.add_url_rule(f"{self.static_url_path}/<path:filename>", endpoint="static", host=static_host, view_func=lambda **kw: self_ref().send_static_file(**kw), # type: ignore # noqa: B950)
app.add_url_rule("/", view_func=lambda **kw: app.send_static_file("index.html", **kw))
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
connections = 0
@socketio.on('connect')
def connect(sid=None, environ=None, auth=None):
global connections
connections += 1
print (f"A user connected ({connections} connections)")
emit('serverWelcome', (VERSION, DATA, START_TIME.isoformat()))
@socketio.on('disconnect')
def disconnect(auth=None):
global connections
connections -= 1
# print ("disconnect")
print(f'Client disconnected ({connections} connections)')
# when a client disconnects I have to delete its player object
# or I would end up with ghost players
try:
print(f"Player disconnected {flask.request.sid}")
playerObject = gameState['players'].get(flask.request.sid);
emit("playerLeft", { 'id': flask.request.sid, 'disconnect': True }, broadcast=True)
# check if there is a custom function in the MOD to call at this point
if playerObject is not None:
if playerObject['room']:
if (playerObject['room']+"Leave" in MOD):
# call it!
MOD[playerObject.room+"Leave"](playerObject, playerObject['room'])
# send the disconnect
# delete the player object
if flask.request.sid in gameState['players']:
del gameState['players'][flask.request.sid]
print(f"There are now {len(gameState['players'])} players on this server")
except Exception as e:
print(f"Error on disconnect, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
@socketio.on('join')
def join (playerInfo):
global visits
# print ("join", playerInfo)
try:
# if running locally it's not gonna work
IP = ""
if (has_request_context() and flask.request.headers):
if (flask.request.headers.get("x-forwarded-for") is not None):
IP = flask.request.headers.get("x-forwarded-for").split(",")[0]
if (playerInfo['nickName'] == ""):
print(f"New user joined the server in lurking mode {flask.request.sid} {IP}")
else:
print(f"New user joined the game: {playerInfo['nickName']} avatar# {playerInfo['avatar']} colors# {playerInfo['colors']} {flask.request.sid}")
roomPlayers = 1
# from https://github.com/miguelgrinberg/python-socketio/blob/main/src/socketio/base_manager.py
# manager.rooms = {} # self.rooms[namespace][room][sio_sid] = eio_sid
# io.sockets.adapter (js) == socketio.server.manager (python)
# print ("rooms", socketio.server.manager.rooms)
myRoom = socketio.server.manager.rooms['/'].get(playerInfo['room'])
if myRoom is not None:
roomPlayers = len(myRoom.keys()) + 1
# roomPlayers = len(list(socketio.server.manager.get_participants('/', playerInfo['room'])))
print (f"There are now {roomPlayers} users in {playerInfo['room']}")
# serverPlayers = Object.keys(io.sockets.connected).length + 1
serverPlayers = connections + 1
isBanned = False
# prevent banned IPs from joining
if (IP != ""):
try:
index = banned.index(IP);
print(f"ATTENTION: banned {IP} is trying to log in again")
isBanned = True
emit("errorMessage", "You have been banned")
disconnect()
except ValueError:
pass
# prevent secret rooms to be joined through URL
if playerInfo['room'] in DATA['ROOMS']:
if DATA['ROOMS'][playerInfo['room']].get('secret'):
playerInfo['room'] = DATA['SETTINGS']['defaultRoom']
if isBanned:
pass
elif flask.request.sid in gameState['players']:
# prevent a hacked client from duplicating players
print(f"ATTENTION: there is already a player associated to the socket {flask.request.sid}")
elif ((serverPlayers > MAX_PLAYERS and MAX_PLAYERS != -1) or (roomPlayers > MAX_PLAYERS_PER_ROOM and MAX_PLAYERS_PER_ROOM != -1)):
# limit the number of players
print(f"ATTENTION: {playerInfo['room']} reached maximum capacity")
emit("errorMessage", "The server is full, please try again later.")
disconnect()
else:
# if client hacked truncate
playerInfo['nickName'] = playerInfo['nickName'][:MAX_NAME_LENGTH]
# the first validation was to give the player feedback, this one is for real
val = 1
# always validate lurkers, they can't do anything
if playerInfo['nickName'] != "":
val = validateName(playerInfo['nickName'])
if (val == 0 or val == 3):
print(f"ATTENTION: {flask.request.sid} tried to bypass username validation")
else:
#if there is an | strip the after so the password remains in the admin client
combo = playerInfo['nickName'].split("|")
playerInfo['nickName'] = combo[0]
if (val == 2):
print(f"{playerInfo['nickName']} joins as admin")
#the player objects on the client will keep track of the room
newPlayer = { 'id': flask.request.sid, 'nickName': filter.clean(playerInfo['nickName']), 'colors': playerInfo['colors'], 'room': playerInfo['room'], 'avatar': playerInfo['avatar'], 'x': playerInfo['x'], 'y': playerInfo['y']}
# save the same information in my game state
sid = flask.request.sid
gameState['players'][sid] = newPlayer
# set last message at the beginning of time, the SEVENTIES
gameState['players'][sid]['lastMessage'] = 0;
# is it admin?
gameState['players'][sid]['admin'] = (val == 2)
gameState['players'][sid]['spam'] = 0;
gameState['players'][sid]['lastActivity'] = int(time.time()*1000)
gameState['players'][sid]['muted'] = False
gameState['players'][sid]['IP'] = IP
gameState['players'][sid]['floodCount'] = 0
gameState['players'][sid]['room'] = playerInfo['room']
# send the user to the default room
join_room(playerInfo['room'])
newPlayer['new'] = True
# let's not count lurkers
if playerInfo['nickName'] != "":
visits += 1
#send all players information about the new player
#upon creation destination and position are the same
# print (f"playerJoined {newPlayer} {playerInfo['room']}")
emit("playerJoined", newPlayer, room=playerInfo['room'])
# check if there are NPCs in this room and make them send info to the player
for NPCId in gameState['NPCs']:
npc = gameState['NPCs'][NPCId]
if npc['room'] == playerInfo['room']:
npc.sendIntroTo(flask.request.sid)
#check if there is a custom function in the MOD to call at this point
if playerInfo['room']+"Join" in MOD:
# call it!
MOD[playerInfo['room']+"Join"](newPlayer, playerInfo['room'])
print(f"There are now {len(gameState['players'])} players on this server. Total visits {visits}")
except Exception as e:
print(f"Error on join, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
@socketio.on('intro')
def intro (newComer, obj):
""" when I receive an intro send it to the recipient """
# print (f"intro {newComer} {obj}")
# verify the id to make sure a hacked client can"t fake players
if (obj is not None):
if obj['id'] == flask.request.sid:
emit("onIntro", obj, room=newComer)
if (obj['room'] + "Intro" in MOD):
MOD[obj.room + "Intro"](newComer, obj)
else:
print(f"ATTENTION: Illegitimate intro from {flask.request.sid}")
@socketio.on('talk')
def talk (obj):
""" when I receive a talk send it to everybody in the room """
try:
mtime = int(time.time()*1000)
# block if spamming
if (mtime - gameState['players'][flask.request.sid]['lastMessage'] > DATA['SETTINGS']['ANTI_SPAM'] and not gameState['players'][flask.request.sid]['muted']):
# Admin commands can be typed as messages
# is this an admin
if (gameState['players'][flask.request.sid].get("admin") and obj['message'][0] == "/"):
print(f"Admin {gameState['players'][flask.request.sid]['nickName']} attempts command {obj['message']}")
adminCommand(socket, obj['message'])
else:
# normal talk stuff
# aphostrophe
obj['message'] = obj['message'].replace("", "'")
# replace unmapped characters
# obj.message = obj.message.replace(/[^A-Za-z0-9_!$%*()@./#&+-|]*$/g, "");
obj['message'] = re.sub(r'[^A-Za-z0-9_!$%*()@./#&+-|]*$', "", obj['message'])
# remove leading and trailing whitespaces
obj['message'] = obj['message'].strip()
# filter bad words
obj['message'] = filter.clean(obj['message'])
# advanced cleaning
# f u c k
test = re.sub('\s', "", obj['message'])
# fffffuuuuck
test2 = re.sub('(.)(?=.*\1)', "", obj['message'])
# f*u*c*k
test3 = re.sub('\W', "", obj['message'])
# spaces
test4 = re.sub('\s', "", obj['message']);
if (filter.isProfane(test) or filter.isProfane(test2) or filter.isProfane(test3) or test4 == ""):
print(f"{flask.request.sid} is problematic")
else:
# check if there is a custom function in the MOD to call at this point
if obj['room']+"TalkFilter" in MOD:
# call it!
obj.message = MOD[obj.room + "TalkFilter"](gameState['players'][flask.request.sid], obj['message'])
if obj['message'] is not None:
print("MOD: Warning - TalkFilter should return a message ")
obj['message'] = ""
if obj['message']:
emit("playerTalked", { 'id': flask.request.sid, 'color': obj['color'], 'message': obj['message'], 'x': obj['x'], 'y': obj['y'] }, room=obj['room'])
# update the last message time
# if (gameState['players'][flask.request.sid]:
gameState['players'][flask.request.sid]['lastMessage'] = mtime
gameState['players'][flask.request.sid]['lastActivity'] = mtime
except Exception as e:
print(f"Error on talk, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
@socketio.on('changeRoom')
def changeRoom (obj):
""" when I receive a move sent it to everybody"""
try:
roomPlayers = 1
# myRoom = io.sockets.adapter.rooms[obj.to];
# if myRoom is not None:
# roomPlayers = myRoom.length + 1;
myRoom = socketio.server.manager.rooms['/'].get(obj['to'])
if myRoom is not None:
roomPlayers = len(myRoom.keys()) + 1
if roomPlayers > MAX_PLAYERS_PER_ROOM and MAX_PLAYERS_PER_ROOM != -1:
# limit the number of players
print(f"ATTENTION: {obj['to']} reached maximum capacity")
# keep the player in game, send a message
emit("godMessage", "The room looks full")
else:
print(f"Player {flask.request.sid} moved from {obj['from']} to {obj['to']}")
leave_room(obj['from'])
join_room(obj['to'])
# broadcast the change to everybody in the current room
# from the client perspective leaving the room is the same as disconnecting
emit("playerLeft", { 'id': flask.request.sid, 'room': obj['from'], 'disconnect': False }, room=obj['from'])
# same for joining, sending everybody in the room the player state
playerObject = gameState['players'][flask.request.sid]
playerObject['room'] = obj['to']
playerObject['x'] = playerObject['destinationX'] = obj['x']
playerObject['y'] = playerObject['destinationY'] = obj['y']
playerObject['new'] = False
# check if there is a custom function in the MOD to call at this point
if obj['from']+"Leave" in MOD:
# call it!
MOD[obj['from'] + "Leave"](playerObject, obj['from'])
emit("playerJoined", playerObject, room=obj['to'])
# check if there is a custom function in the MOD to call at this point
if obj['to']+"Join" in MOD:
# call it!
MOD[obj['to']+"Join"](playerObject, obj['to'])
# check if there are NPCs in this room and make them send info to the player
for NPCId in gameState['NPCs']:
npc = gameState['NPCs'][NPCId]
if (npc.room == obj['to']):
npc.sendIntroTo(flask.request.sid)
except Exception as e:
print(f"Error on changeRoom, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
# when I receive a move sent it to everybody
@socketio.on('move')
def move(obj):
try:
gameState['players'][flask.request.sid]['lastActivity'] = int(time.time()*1000)
# broadcast the movement to everybody
# print (f"emit playerMoved to everybody in {obj['room']}")
emit("playerMoved", { 'id': flask.request.sid, 'x': obj['x'], 'y': obj['y'], 'destinationX': obj['destinationX'], 'destinationY': obj['destinationY'] }, room=obj['room'])
except Exception as e:
print(f"Error on move, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
# when I receive a user name validate it
@socketio.on('sendName')
def sendName(nn):
try:
res = validateName(nn)
# send the code 0 no - 1 ok - 2 admin
emit("nameValidation", res)
except Exception as e:
print(f"Error on sendName, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
@socketio.on('emote')
def emote(obj):
"""when a character emote animation changes"""
try:
emit("playerEmoted", (flask.request.sid, obj['em']), room=obj['room'])
except Exception as e:
print(f"Error on emote, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
@socketio.on('focus')
def focus(obj):
"""user afk """
try:
# print(f"{flask.request.sid} back from AFK")
emit("playerFocused", flask.request.sid, room=obj['room']);
except Exception as e:
print(f"Error on focus, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
@socketio.on('blur')
def blur(obj):
try:
# print(f"{flask.request.sid} is AFK")
emit("playerBlurred", flask.request.sid, room=obj['room'])
except Exception as e:
print(f"Error on blur, object malformed from {flask.request.sid}?")
print(f"Exception: {e}")
@socketio.on('action')
def action(aId):
""" generic action listener, looks for a function with that id in the mod """
if "on"+aId in MOD:
# call it!
# print(f"on {aId} exists in the mod, call it")
MOD["on"+aId](flask.request.sid);
def validateName(nn):
admin = False
duplicate = False
reserved = False
#check if the nickname is a name + password combo
combo = nn.split("|")
#it may be
if len(combo) > 1:
n = combo[0]
p = combo[1]
for admin in admins:
if admin.upper() == nn.upper():
#it is an admin name! check if the password is correct, case insensitive
envCombo = admin.split("|")
if (p == envCombo[1]):
admin = True
# if there is an | just strip the after
nn = n
#if not admin check if the nickname is reserved (case insensitive)
if not admin:
for admin in admins:
combo = admin.split("|");
if combo[0].upper() == nn.upper():
#it is! kill it. Yes, it should be done at login and communicated
#but hey I don't have to be nice to users who steal my name
reserved = True
id = idByName(nn)
if (id is not None):
duplicate = True
print(f"There is already a player named {nn}")
#i hate this double negative logic but I hate learning regex more
res = re.match(r'^([a-zA-Z0-9 !@#$%&*(),._-]+)$', nn)
if (res is None):
return 3
elif duplicate or reserved:
return 0
elif admin:
print(f"{nn} logging as admin")
return 2
else:
return 1
def adminCommand(adminSocket, str):
try:
# remove /
str = str[1:]
cmd = str.split(" ")
if cmd[0] == "kick":
sid = socketIDByName(cmd[1])
if sid:
# shadow disconnect
disconnect(sid)
else:
# popup to admin
emit("popup", f"I can't find a user named {cmd[1]}")
elif cmd[0] == "mute":
s = idByName(cmd[1])
if s:
gameState['players'][s]['muted'] = True
else:
# popup to admin
emit("popup", f"I can't find a user named {cmd[1]}")
elif cmd[0] == "unmute":
s = idByName(cmd[1]);
if s:
gameState['players'][s]['muted'] = False
else:
# popup to admin
emit("popup", f"I can't find a user named {cmd[1]}")
# trigger a direct popup
elif cmd[0] == "popup":
s = socketIDByName(cmd[1])
if s:
msg = cmd[2:].join(" ");
emit("popup", msg, room=s)
else:
# popup to admin
emit("popup", f"I can't find a user named {cmd[1]}")
# send fullscreen message to everybody
elif cmd[0] == "god":
msg = cmd[1:].join(" ");
emit("godMessage", msg, broadcast=True)
# disconnect all sockets
elif cmd[0] == "nuke":
emit("errorMessage", "Server Restarted\nPlease Refresh", broadcast=True)
for sid in gameState['players']:
disconnect(sid)
# add to the list of banned IPs
elif cmd[0] == "ban":
IP = IPByName(cmd[1])
s = socketByName(cmd[1])
if IP:
banned.append(IP)
if s:
s.emit("errorMessage", "You have been banned")
s.disconnect()
else:
# popup to admin
emit("popup", f"I can't find a user named {cmd[1]}")
elif cmd[0] == "unban":
# releases the ban
banned = []
# forces a hard refresh - all players disconnect
# used to load a new version of the client
elif cmd[0] == "refresh":
io.sockets.emit("refresh");
except Exception as e:
print ("Error admin command")
print (f"Exception: {e}")
# admin functions, the admin exists in the client frontend so they don't have access to ip and id of other users
def socketIDByName(nick):
s = None
for sid in gameState['players']:
if gameState['players'][sid]['nickName'].upper() == nick.upper():
s = sid
return s
def idByName(nick):
i = None
for sid in gameState['players']:
if gameState['players'][sid]['nickName'].upper() == nick.upper():
i = sid
return i
def IPByName(nick):
IP = ""
for sid in gameState['players']:
if gameState['players'][sid]['nickName'].upper() == nick.upper():
IP = gameState['players'][sid]['IP']
return IP
class BadWordsFilter (object):
def __init__(self, initial_data=None):
pass
def clean (self, text):
return text
def isProfane(self, text):
return False
filter = BadWordsFilter()
# modding
MOD = {}
# try:
# import serverMod as MOD
# MOD.initMod(gameState, DATA)
# except ImportError:
# pass
if __name__ == '__main__':
socketio.run(app)
Loading…
Cancel
Save