added speech bubble and profanity filter

This commit is contained in:
gocivici 2023-09-28 18:03:39 +03:00
parent 63ac316959
commit 86ccf93e09
31 changed files with 1342 additions and 53 deletions

View File

@ -11,7 +11,10 @@ const io = new Server(server, {
pingTimeout:5000
})
app.use(requireHTTPS);
var Filter = require('bad-words')
filter = new Filter();
app.use(requireHTTPS); // Set 'SET NODE_ENV=development' in local computer before use
function requireHTTPS(req, res, next) {
// The 'x-forwarded-proto' check is for Heroku
@ -68,7 +71,7 @@ io.on('connection', (socket)=>{
socket.on('message',(message)=>{
let timeoutId;
clearTimeout(bPlayers[socket.id].timeoutId);
bPlayers[socket.id].message = message
bPlayers[socket.id].message = filter.clean(message)
function startTimer() {
timeoutId = setTimeout(() => {

16
node_modules/.package-lock.json generated vendored
View File

@ -43,6 +43,22 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/bad-words": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/bad-words/-/bad-words-3.0.4.tgz",
"integrity": "sha512-v/Q9uRPH4+yzDVLL4vR1+S9KoFgOEUl5s4axd6NIAq8SV2mradgi4E8lma/Y0cw1ltVdvyegCQQKffCPRCp8fg==",
"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": "sha512-oWhaSG67e+HQj3OGHQt2ucP+vAPm1wTbdp2aDHeuh4xlGXBdWwzZ//pfu6swf5gZ8iX0b7JgmSo8BhgybbqszA=="
},
"node_modules/base64id": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",

4
node_modules/bad-words/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,4 @@
language: node_js
node_js:
- "8"
script: npm test

123
node_modules/bad-words/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,123 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [3.0.4](https://github.com/web-mech/badwords/compare/v3.0.3...v3.0.4) (2020-11-16)
<a name="3.0.3"></a>
## [3.0.3](https://github.com/web-mech/badwords/compare/v3.0.2...v3.0.3) (2019-07-25)
<a name="3.0.2"></a>
## [3.0.2](https://github.com/web-mech/badwords/compare/v3.0.1...v3.0.2) (2019-03-14)
### Bug Fixes
* **lang.json:** remove gay from badwords ([88d1aed](https://github.com/web-mech/badwords/commit/88d1aed))
<a name="3.0.1"></a>
## [3.0.1](https://github.com/web-mech/badwords/compare/v3.0.0...v3.0.1) (2019-02-19)
### Bug Fixes
* update removeWords functionality to be case-insensitive ([235121d](https://github.com/web-mech/badwords/commit/235121d))
<a name="3.0.0"></a>
# [3.0.0](https://github.com/web-mech/badwords/compare/v2.0.0...v3.0.0) (2018-10-23)
### Code Refactoring
* utilize es6 spread in addWords/removeWords ([656b87c](https://github.com/web-mech/badwords/commit/656b87c))
### BREAKING CHANGES
* changes the way addWords is used, no longer accepts a single array as a parameter unless used with the spread operator
<a name="2.0.0"></a>
# [2.0.0](https://github.com/web-mech/badwords/compare/v1.6.5...v2.0.0) (2018-10-23)
### Documentation
* update documentation. add requirements for using lib moving forward ([9b2831d](https://github.com/web-mech/badwords/commit/9b2831d))
### Features
* **profane:** support profane phrases and well as words ([995ea1e](https://github.com/web-mech/badwords/commit/995ea1e))
### BREAKING CHANGES
* moving into es2016+ language features
<a name="1.6.5"></a>
## [1.6.5](https://github.com/web-mech/badwords/compare/v1.6.4...v1.6.5) (2018-10-23)
<a name="1.6.4"></a>
## [1.6.4](https://github.com/web-mech/badwords/compare/v1.6.3...v1.6.4) (2018-09-21)
### Bug Fixes
* **isProfane:** Adding regex word boundary for isProfane ([3908f3c](https://github.com/web-mech/badwords/commit/3908f3c))
<a name="1.6.3"></a>
## [1.6.3](https://github.com/web-mech/badwords/compare/v1.6.2...v1.6.3) (2018-08-02)
<a name="1.6.2"></a>
## [1.6.2](https://github.com/web-mech/badwords/compare/v1.6.1...v1.6.2) (2018-08-02)
### Bug Fixes
* **isProfaneLike:** abort trying to match every instance of profane words. ([31126d6](https://github.com/web-mech/badwords/commit/31126d6))
<a name="1.6.1"></a>
## [1.6.1](https://github.com/web-mech/badwords/compare/v1.6.0...v1.6.1) (2017-10-25)
### Bug Fixes
* **isProfaneLike:** fix case sensitive checks within list ([bfa05ce](https://github.com/web-mech/badwords/commit/bfa05ce))
<a name="1.6.0"></a>
# [1.6.0](https://github.com/web-mech/badwords/compare/v1.5.2...v1.6.0) (2017-10-16)
### Features
* fixes and updates ([8049222](https://github.com/web-mech/badwords/commit/8049222))
<a name="1.5.2"></a>
## [1.5.2](https://github.com/web-mech/badwords/compare/v1.5.1...v1.5.2) (2017-10-16)
### Bug Fixes
* support for better filtering ([7c8d0e2](https://github.com/web-mech/badwords/commit/7c8d0e2))

20
node_modules/bad-words/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2015 Michael Price
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4
node_modules/bad-words/Makefile generated vendored Normal file
View File

@ -0,0 +1,4 @@
test:
@./node_modules/mocha/bin/_mocha -R $(REPORTER)
.PHONY: test

175
node_modules/bad-words/README.md generated vendored Normal file
View File

@ -0,0 +1,175 @@
# bad-words
A javascript filter for badwords
[![Build Status](https://travis-ci.org/web-mech/badwords.svg?branch=master)](https://travis-ci.org/web-mech/badwords)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
## Requirements
As of version 2, requires you either have an environment that understands ES2016 and beyond or a transpiler like Babel.
## Installation
npm install bad-words --save
## Usage
```js
var Filter = require('bad-words'),
filter = new Filter();
console.log(filter.clean("Don't be an ash0le")); //Don't be an ******
```
### Placeholder Overrides
```js
var Filter = require('bad-words');
var customFilter = new Filter({ placeHolder: 'x'});
customFilter.clean("Don't be an ash0le"); //Don't be an xxxxxx
```
### Regex Overrides
```js
var filter = new Filter({ regex: /\*|\.|$/gi });
var filter = new Filter({ replaceRegex: /[A-Za-z0-9가-힣_]/g });
//multilingual support for word filtering
```
### Add words to the blacklist
```js
var filter = new Filter();
filter.addWords('some', 'bad', 'word');
filter.clean("some bad word!") //**** *** ****!
//or use an array using the spread operator
var newBadWords = ['some', 'bad', 'word'];
filter.addWords(...newBadWords);
filter.clean("some bad word!") //**** *** ****!
//or
var filter = new Filter({ list: ['some', 'bad', 'word'] });
filter.clean("some bad word!") //**** *** ****!
```
### Instantiate with an empty list
```js
var filter = new Filter({ emptyList: true });
filter.clean('hell this wont clean anything'); //hell this wont clean anything
```
### Remove words from the blacklist
```js
let filter = new Filter();
filter.removeWords('hells', 'sadist');
filter.clean("some hells word!"); //some hells word!
//or use an array using the spread operator
let removeWords = ['hells', 'sadist'];
filter.removeWords(...removeWords);
filter.clean("some sadist hells word!"); //some sadist hells word!
```
### API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
#### constructor
Filter constructor.
**Parameters**
- `options` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Filter instance options (optional, default `{}`)
- `options.emptyList` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Instantiate filter with no blacklist
- `options.list` **[array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** Instantiate filter with custom list
- `options.placeHolder` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Character used to replace profane words.
- `options.regex` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Regular expression used to sanitize words before comparing them to blacklist.
- `options.replaceRegex` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Regular expression used to replace profane words with placeHolder.
#### isProfane
Determine if a string contains profane language.
**Parameters**
- `string` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** String to evaluate for profanity.
#### replaceWord
Replace a word with placeHolder characters;
**Parameters**
- `string` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** String to replace.
#### clean
Evaluate a string for profanity and return an edited version.
**Parameters**
- `string` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Sentence to filter.
#### addWords
Add word(s) to blacklist filter / remove words from whitelist filter
**Parameters**
- `word` **...[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Word(s) to add to blacklist
#### removeWords
Add words to whitelist filter
**Parameters**
- `word` **...[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Word(s) to add to whitelist.
## Testing
npm test
## License
The MIT License (MIT)
Copyright (c) 2013 Michael Price
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

88
node_modules/bad-words/lib/badwords.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
const localList = require('./lang.json').words;
const baseList = require('badwords-list').array;
class Filter {
/**
* Filter constructor.
* @constructor
* @param {object} options - Filter instance options
* @param {boolean} options.emptyList - Instantiate filter with no blacklist
* @param {array} options.list - Instantiate filter with custom list
* @param {string} options.placeHolder - Character used to replace profane words.
* @param {string} options.regex - Regular expression used to sanitize words before comparing them to blacklist.
* @param {string} options.replaceRegex - Regular expression used to replace profane words with placeHolder.
* @param {string} options.splitRegex - Regular expression used to split a string into words.
*/
constructor(options = {}) {
Object.assign(this, {
list: options.emptyList && [] || Array.prototype.concat.apply(localList, [baseList, options.list || []]),
exclude: options.exclude || [],
splitRegex: options.splitRegex || /\b/,
placeHolder: options.placeHolder || '*',
regex: options.regex || /[^a-zA-Z0-9|\$|\@]|\^/g,
replaceRegex: options.replaceRegex || /\w/g
})
}
/**
* Determine if a string contains profane language.
* @param {string} string - String to evaluate for profanity.
*/
isProfane(string) {
return this.list
.filter((word) => {
const wordExp = new RegExp(`\\b${word.replace(/(\W)/g, '\\$1')}\\b`, 'gi');
return !this.exclude.includes(word.toLowerCase()) && wordExp.test(string);
})
.length > 0 || false;
}
/**
* Replace a word with placeHolder characters;
* @param {string} string - String to replace.
*/
replaceWord(string) {
return string
.replace(this.regex, '')
.replace(this.replaceRegex, this.placeHolder);
}
/**
* Evaluate a string for profanity and return an edited version.
* @param {string} string - Sentence to filter.
*/
clean(string) {
return string.split(this.splitRegex).map((word) => {
return this.isProfane(word) ? this.replaceWord(word) : word;
}).join(this.splitRegex.exec(string)[0]);
}
/**
* Add word(s) to blacklist filter / remove words from whitelist filter
* @param {...string} word - Word(s) to add to blacklist
*/
addWords() {
let words = Array.from(arguments);
this.list.push(...words);
words
.map(word => word.toLowerCase())
.forEach((word) => {
if (this.exclude.includes(word)) {
this.exclude.splice(this.exclude.indexOf(word), 1);
}
});
}
/**
* Add words to whitelist filter
* @param {...string} word - Word(s) to add to whitelist.
*/
removeWords() {
this.exclude.push(...Array.from(arguments).map(word => word.toLowerCase()));
}
}
module.exports = Filter;

451
node_modules/bad-words/lib/lang.json generated vendored Normal file
View File

@ -0,0 +1,451 @@
{
"words":[
"ahole",
"anus",
"ash0le",
"ash0les",
"asholes",
"ass",
"Ass Monkey",
"Assface",
"assh0le",
"assh0lez",
"asshole",
"assholes",
"assholz",
"asswipe",
"azzhole",
"bassterds",
"bastard",
"bastards",
"bastardz",
"basterds",
"basterdz",
"Biatch",
"bitch",
"bitches",
"Blow Job",
"boffing",
"butthole",
"buttwipe",
"c0ck",
"c0cks",
"c0k",
"Carpet Muncher",
"cawk",
"cawks",
"Clit",
"cnts",
"cntz",
"cock",
"cockhead",
"cock-head",
"cocks",
"CockSucker",
"cock-sucker",
"crap",
"cum",
"cunt",
"cunts",
"cuntz",
"dick",
"dild0",
"dild0s",
"dildo",
"dildos",
"dilld0",
"dilld0s",
"dominatricks",
"dominatrics",
"dominatrix",
"dyke",
"enema",
"f u c k",
"f u c k e r",
"fag",
"fag1t",
"faget",
"fagg1t",
"faggit",
"faggot",
"fagg0t",
"fagit",
"fags",
"fagz",
"faig",
"faigs",
"fart",
"flipping the bird",
"fuck",
"fucker",
"fuckin",
"fucking",
"fucks",
"Fudge Packer",
"fuk",
"Fukah",
"Fuken",
"fuker",
"Fukin",
"Fukk",
"Fukkah",
"Fukken",
"Fukker",
"Fukkin",
"g00k",
"God-damned",
"h00r",
"h0ar",
"h0re",
"hells",
"hoar",
"hoor",
"hoore",
"jackoff",
"jap",
"japs",
"jerk-off",
"jisim",
"jiss",
"jizm",
"jizz",
"knob",
"knobs",
"knobz",
"kunt",
"kunts",
"kuntz",
"Lezzian",
"Lipshits",
"Lipshitz",
"masochist",
"masokist",
"massterbait",
"masstrbait",
"masstrbate",
"masterbaiter",
"masterbate",
"masterbates",
"Motha Fucker",
"Motha Fuker",
"Motha Fukkah",
"Motha Fukker",
"Mother Fucker",
"Mother Fukah",
"Mother Fuker",
"Mother Fukkah",
"Mother Fukker",
"mother-fucker",
"Mutha Fucker",
"Mutha Fukah",
"Mutha Fuker",
"Mutha Fukkah",
"Mutha Fukker",
"n1gr",
"nastt",
"nigger;",
"nigur;",
"niiger;",
"niigr;",
"orafis",
"orgasim;",
"orgasm",
"orgasum",
"oriface",
"orifice",
"orifiss",
"packi",
"packie",
"packy",
"paki",
"pakie",
"paky",
"pecker",
"peeenus",
"peeenusss",
"peenus",
"peinus",
"pen1s",
"penas",
"penis",
"penis-breath",
"penus",
"penuus",
"Phuc",
"Phuck",
"Phuk",
"Phuker",
"Phukker",
"polac",
"polack",
"polak",
"Poonani",
"pr1c",
"pr1ck",
"pr1k",
"pusse",
"pussee",
"pussy",
"puuke",
"puuker",
"qweir",
"recktum",
"rectum",
"retard",
"sadist",
"scank",
"schlong",
"screwing",
"semen",
"sex",
"sexy",
"Sh!t",
"sh1t",
"sh1ter",
"sh1ts",
"sh1tter",
"sh1tz",
"shit",
"shits",
"shitter",
"Shitty",
"Shity",
"shitz",
"Shyt",
"Shyte",
"Shytty",
"Shyty",
"skanck",
"skank",
"skankee",
"skankey",
"skanks",
"Skanky",
"slag",
"slut",
"sluts",
"Slutty",
"slutz",
"son-of-a-bitch",
"tit",
"turd",
"va1jina",
"vag1na",
"vagiina",
"vagina",
"vaj1na",
"vajina",
"vullva",
"vulva",
"w0p",
"wh00r",
"wh0re",
"whore",
"xrated",
"xxx",
"b!+ch",
"bitch",
"blowjob",
"clit",
"arschloch",
"fuck",
"shit",
"ass",
"asshole",
"b!tch",
"b17ch",
"b1tch",
"bastard",
"bi+ch",
"boiolas",
"buceta",
"c0ck",
"cawk",
"chink",
"cipa",
"clits",
"cock",
"cum",
"cunt",
"dildo",
"dirsa",
"ejakulate",
"fatass",
"fcuk",
"fuk",
"fux0r",
"hoer",
"hore",
"jism",
"kawk",
"l3itch",
"l3i+ch",
"masturbate",
"masterbat*",
"masterbat3",
"motherfucker",
"s.o.b.",
"mofo",
"nazi",
"nigga",
"nigger",
"nutsack",
"phuck",
"pimpis",
"pusse",
"pussy",
"scrotum",
"sh!t",
"shemale",
"shi+",
"sh!+",
"slut",
"smut",
"teets",
"tits",
"boobs",
"b00bs",
"teez",
"testical",
"testicle",
"titt",
"w00se",
"jackoff",
"wank",
"whoar",
"whore",
"*damn",
"*dyke",
"*fuck*",
"*shit*",
"@$$",
"amcik",
"andskota",
"arse*",
"assrammer",
"ayir",
"bi7ch",
"bitch*",
"bollock*",
"breasts",
"butt-pirate",
"cabron",
"cazzo",
"chraa",
"chuj",
"Cock*",
"cunt*",
"d4mn",
"daygo",
"dego",
"dick*",
"dike*",
"dupa",
"dziwka",
"ejackulate",
"Ekrem*",
"Ekto",
"enculer",
"faen",
"fag*",
"fanculo",
"fanny",
"feces",
"feg",
"Felcher",
"ficken",
"fitt*",
"Flikker",
"foreskin",
"Fotze",
"Fu(*",
"fuk*",
"futkretzn",
"gook",
"guiena",
"h0r",
"h4x0r",
"hell",
"helvete",
"hoer*",
"honkey",
"Huevon",
"hui",
"injun",
"jizz",
"kanker*",
"kike",
"klootzak",
"kraut",
"knulle",
"kuk",
"kuksuger",
"Kurac",
"kurwa",
"kusi*",
"kyrpa*",
"lesbo",
"mamhoon",
"masturbat*",
"merd*",
"mibun",
"monkleigh",
"mouliewop",
"muie",
"mulkku",
"muschi",
"nazis",
"nepesaurio",
"nigger*",
"orospu",
"paska*",
"perse",
"picka",
"pierdol*",
"pillu*",
"pimmel",
"piss*",
"pizda",
"poontsee",
"poop",
"porn",
"p0rn",
"pr0n",
"preteen",
"pula",
"pule",
"puta",
"puto",
"qahbeh",
"queef*",
"rautenberg",
"schaffer",
"scheiss*",
"schlampe",
"schmuck",
"screw",
"sh!t*",
"sharmuta",
"sharmute",
"shipal",
"shiz",
"skribz",
"skurwysyn",
"sphencter",
"spic",
"spierdalaj",
"splooge",
"suka",
"b00b*",
"testicle*",
"titt*",
"twat",
"vittu",
"wank*",
"wetback*",
"wichser",
"wop*",
"yed",
"zabourah"
]
}

36
node_modules/bad-words/package.json generated vendored Normal file
View File

@ -0,0 +1,36 @@
{
"name": "bad-words",
"version": "3.0.4",
"description": "A javascript filter for bad words",
"main": "./lib/badwords",
"directories": {
"test": "test"
},
"scripts": {
"test": "./node_modules/.bin/mocha -R spec",
"docs": "./node_modules/.bin/documentation readme --section API ./lib/badwords.js"
},
"repository": {
"type": "git",
"url": "git://github.com/web-mech/badwords.git"
},
"keywords": [
"curse",
"words",
"profanity",
"filter"
],
"dependencies": {
"badwords-list": "^1.0.0"
},
"devDependencies": {
"better-assert": "1.0.0",
"documentation": "^5.3.3",
"mocha": "^5.2.0"
},
"author": "Mike P.",
"license": "MIT",
"engines": {
"node": ">=8.0.0"
}
}

28
node_modules/bad-words/test/addWords.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
require('assert');
var Filter = require('../lib/badwords.js'),
filter = new Filter(),
assert = require('better-assert');
describe('filter', function(){
describe('addWords',function(){
it('Should append words to the filter list.', function(){
filter.addWords('dog', 'go');
assert(filter.clean('Go dog go') === '** *** **');
});
it('Should append words to the filter using an array', () => {
let addWords = ['go', 'dog'];
filter = new Filter()
filter.addWords(...addWords);
assert(filter.clean('Go dog go') === '** *** **');
});
it('Should allow a list to be passed to the constructor', function() {
filter = new Filter({
list: ['dog']
});
assert(filter.clean('Go dog go') === 'Go *** go');
});
});
});

47
node_modules/bad-words/test/filter.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
require('assert');
var Filter = require('../lib/badwords.js'),
filter = new Filter(),
assert = require('better-assert');
describe('filter', function(){
describe('clean',function(){
it('Should replace a bad word within a sentence asterisks (******)',function(){
console.log(filter.clean('Don\'t be an ash0le'));
assert(filter.clean('Don\'t be an ash0le') === 'Don\'t be an ******');
});
it('Should replace multiple instances of any bad words within a sentence asterisks (******)',function(){
assert(filter.clean('cnts ash0le knob xxx') === '**** ****** **** ***');
});
it('Should not replace anything within a sentence if there are no bad words',function(){
assert(filter.clean('The cat ran fast') === 'The cat ran fast');
});
it('Should replace a string with proper placeholder when overridden', function(){
var customFilter = new Filter({ placeHolder: 'x'});
assert(customFilter.clean('This is a hells good test') === 'This is a xxxxx good test');
});
it('Should allow an instance of filter with an empty blacklist', function() {
var customFilter = new Filter({
emptyList: true
});
assert(customFilter.clean('This is a hells good test') === 'This is a hells good test');
});
it('Should tokenize words according to regex word boundaries',function(){
assert(filter.clean('what a bitch...fuck you') === 'what a *****...**** you');
assert(filter.clean('<p>Don\'t be an asshole</p>') === '<p>Don\'t be an *******</p>');
});
xit('Should filter words that are derivatives of words from the filter blacklist', function() {
assert(filter.clean('shitshit') === '********');
});
it('Shouldn\'t filter words that aren\'t profane.', function() {
assert(filter.clean('hello there') === 'hello there');
});
});
});

44
node_modules/bad-words/test/isProfane.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
require('assert');
var Filter = require('../lib/badwords.js'),
filter = new Filter(),
assert = require('better-assert');
describe('filter', function(){
describe('isProfane',function(){
it("Should detect a bad word and return a boolean value",function(){
assert(filter.isProfane("ash0le"));
});
it("Should return false when no bad word is detected",function(){
assert(filter.isProfane("wife") === false);
});
it("Should be able to detect a bad word in a sentence",function(){
assert(filter.isProfane("that person is an ash0le"));
});
it('Filters out special characters appropriately', function() {
assert(filter.isProfane("You're an asshole^ you are"));
});
it('Should detect filtered words from badwords-list', function(){
assert(filter.isProfane('willies'));
});
it('Should detect filtered words regardless of type case', function() {
var filter = new Filter({
list: ['Test']
});
assert(filter.isProfane('test'));
});
it('Should tokenize words according to regex word boundaries', function() {
assert(filter.isProfane("that person is an\nasshole"));
});
it('Should detect bad word phrases', function () {
filter.addWords('oh no');
assert(filter.isProfane("oh no! this is profane!"));
});
});
});

24
node_modules/bad-words/test/options.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
require('assert');
var Filter = require('../lib/badwords.js'),
assert = require('better-assert');
describe('options', function() {
describe('split regex', function() {
it('default value', function() {
filter = new Filter();
filter.addWords('français');
assert(filter.clean('fucking asshole') == '******* *******');
assert(filter.clean('mot en français') == 'mot en français');
});
it('override value', function() {
filter = new Filter({splitRegex: / /});
filter.addWords('français');
assert(filter.clean('fucking asshole') == '******* *******');
assert(filter.clean('mot en français') == 'mot en *******');
});
});
});

21
node_modules/bad-words/test/removeWords.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
require('assert');
var Filter = require('../lib/badwords.js'),
filter = new Filter(),
assert = require('better-assert');
describe('filter', () => {
describe('removeWords',() => {
it('Should allow you to remove words from the filter blacklist and no longer filter them (case-insensitive)', () => {
filter.removeWords('Hells');
assert(filter.clean('This is a hells good test') === 'This is a hells good test');
});
it ('Should allow you to remove an array of words from the filter blacklist and no longer filter them', () => {
let removingWords = ['hells', 'sadist'];
filter = new Filter();
filter.removeWords(...removingWords);
assert(filter.clean('This is a hells sadist test') === 'This is a hells sadist test');
});
});
});

12
node_modules/bad-words/test/replaceWord.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
require('assert');
var Filter = require('../lib/badwords.js'),
filter = new Filter(),
assert = require('better-assert');
describe('filter', function(){
describe('replaceWord',function(){
it("Should replace a bad word with asterisks (******)",function(){
assert(filter.replaceWord("ash0le") == '******');
});
});
});

15
node_modules/badwords-list/.npmignore generated vendored Normal file
View File

@ -0,0 +1,15 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
npm-debug.log
node_modules/

20
node_modules/badwords-list/LICENSE generated vendored Normal file
View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Maurice Butler
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4
node_modules/badwords-list/Makefile generated vendored Normal file
View File

@ -0,0 +1,4 @@
test:
@./node_modules/mocha/bin/_mocha -R $(REPORTER)
.PHONY: test

57
node_modules/badwords-list/README.md generated vendored Normal file
View File

@ -0,0 +1,57 @@
badwords-list v1.0.0
========
A highly consumable list of bad (profanity) english words based on the nice short and simple list found in [Google's "what do you love" project](http://www.wdyl.com/) made accessable by [Jamie Wilkinson](https://gist.github.com/jamiew) [here](https://gist.github.com/jamiew/1112488)
Inspired by [badwords](https://github.com/MauriceButler/badwords)
This data has been exposed as an object that contains
- an array
- an object
- a regular expression
depending on what is required for your purposes.
Install
=======
npm install badwords-list
Usage
=====
```
var list = require('badwords-list'),
array = list.array,
object = list.object,
regex = list.regex;
```
Testing
=======
####Requires
- Mocha
- better-assert
```
npm test
```
**or**
```
REPORTER=spec make
```
**or**
```
mocha
```

1
node_modules/badwords-list/lib/array.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = ["4r5e", "5h1t", "5hit", "a55", "anal", "anus", "ar5e", "arrse", "arse", "ass", "ass-fucker", "asses", "assfucker", "assfukka", "asshole", "assholes", "asswhole", "a_s_s", "b!tch", "b00bs", "b17ch", "b1tch", "ballbag", "balls", "ballsack", "bastard", "beastial", "beastiality", "bellend", "bestial", "bestiality", "bi+ch", "biatch", "bitch", "bitcher", "bitchers", "bitches", "bitchin", "bitching", "bloody", "blow job", "blowjob", "blowjobs", "boiolas", "bollock", "bollok", "boner", "boob", "boobs", "booobs", "boooobs", "booooobs", "booooooobs", "breasts", "buceta", "bugger", "bum", "bunny fucker", "butt", "butthole", "buttmuch", "buttplug", "c0ck", "c0cksucker", "carpet muncher", "cawk", "chink", "cipa", "cl1t", "clit", "clitoris", "clits", "cnut", "cock", "cock-sucker", "cockface", "cockhead", "cockmunch", "cockmuncher", "cocks", "cocksuck", "cocksucked", "cocksucker", "cocksucking", "cocksucks", "cocksuka", "cocksukka", "cok", "cokmuncher", "coksucka", "coon", "cox", "crap", "cum", "cummer", "cumming", "cums", "cumshot", "cunilingus", "cunillingus", "cunnilingus", "cunt", "cuntlick", "cuntlicker", "cuntlicking", "cunts", "cyalis", "cyberfuc", "cyberfuck", "cyberfucked", "cyberfucker", "cyberfuckers", "cyberfucking", "d1ck", "damn", "dick", "dickhead", "dildo", "dildos", "dink", "dinks", "dirsa", "dlck", "dog-fucker", "doggin", "dogging", "donkeyribber", "doosh", "duche", "dyke", "ejaculate", "ejaculated", "ejaculates", "ejaculating", "ejaculatings", "ejaculation", "ejakulate", "f u c k", "f u c k e r", "f4nny", "fag", "fagging", "faggitt", "faggot", "faggs", "fagot", "fagots", "fags", "fanny", "fannyflaps", "fannyfucker", "fanyy", "fatass", "fcuk", "fcuker", "fcuking", "feck", "fecker", "felching", "fellate", "fellatio", "fingerfuck", "fingerfucked", "fingerfucker", "fingerfuckers", "fingerfucking", "fingerfucks", "fistfuck", "fistfucked", "fistfucker", "fistfuckers", "fistfucking", "fistfuckings", "fistfucks", "flange", "fook", "fooker", "fuck", "fucka", "fucked", "fucker", "fuckers", "fuckhead", "fuckheads", "fuckin", "fucking", "fuckings", "fuckingshitmotherfucker", "fuckme", "fucks", "fuckwhit", "fuckwit", "fudge packer", "fudgepacker", "fuk", "fuker", "fukker", "fukkin", "fuks", "fukwhit", "fukwit", "fux", "fux0r", "f_u_c_k", "gangbang", "gangbanged", "gangbangs", "gaylord", "gaysex", "goatse", "God", "god-dam", "god-damned", "goddamn", "goddamned", "hardcoresex", "hell", "heshe", "hoar", "hoare", "hoer", "homo", "hore", "horniest", "horny", "hotsex", "jack-off", "jackoff", "jap", "jerk-off", "jism", "jiz", "jizm", "jizz", "kawk", "knob", "knobead", "knobed", "knobend", "knobhead", "knobjocky", "knobjokey", "kock", "kondum", "kondums", "kum", "kummer", "kumming", "kums", "kunilingus", "l3i+ch", "l3itch", "labia", "lust", "lusting", "m0f0", "m0fo", "m45terbate", "ma5terb8", "ma5terbate", "masochist", "master-bate", "masterb8", "masterbat*", "masterbat3", "masterbate", "masterbation", "masterbations", "masturbate", "mo-fo", "mof0", "mofo", "mothafuck", "mothafucka", "mothafuckas", "mothafuckaz", "mothafucked", "mothafucker", "mothafuckers", "mothafuckin", "mothafucking", "mothafuckings", "mothafucks", "mother fucker", "motherfuck", "motherfucked", "motherfucker", "motherfuckers", "motherfuckin", "motherfucking", "motherfuckings", "motherfuckka", "motherfucks", "muff", "mutha", "muthafecker", "muthafuckker", "muther", "mutherfucker", "n1gga", "n1gger", "nazi", "nigg3r", "nigg4h", "nigga", "niggah", "niggas", "niggaz", "nigger", "niggers", "nob", "nob jokey", "nobhead", "nobjocky", "nobjokey", "numbnuts", "nutsack", "orgasim", "orgasims", "orgasm", "orgasms", "p0rn", "pawn", "pecker", "penis", "penisfucker", "phonesex", "phuck", "phuk", "phuked", "phuking", "phukked", "phukking", "phuks", "phuq", "pigfucker", "pimpis", "piss", "pissed", "pisser", "pissers", "pisses", "pissflaps", "pissin", "pissing", "pissoff", "poop", "porn", "porno", "pornography", "pornos", "prick", "pricks", "pron", "pube", "pusse", "pussi", "pussies", "pussy", "pussys", "rectum", "retard", "rimjaw", "rimming", "s hit", "s.o.b.", "sadist", "schlong", "screwing", "scroat", "scrote", "scrotum", "semen", "sex", "sh!+", "sh!t", "sh1t", "shag", "shagger", "shaggin", "shagging", "shemale", "shi+", "shit", "shitdick", "shite", "shited", "shitey", "shitfuck", "shitfull", "shithead", "shiting", "shitings", "shits", "shitted", "shitter", "shitters", "shitting", "shittings", "shitty", "skank", "slut", "sluts", "smegma", "smut", "snatch", "son-of-a-bitch", "spac", "spunk", "s_h_i_t", "t1tt1e5", "t1tties", "teets", "teez", "testical", "testicle", "tit", "titfuck", "tits", "titt", "tittie5", "tittiefucker", "titties", "tittyfuck", "tittywank", "titwank", "tosser", "turd", "tw4t", "twat", "twathead", "twatty", "twunt", "twunter", "v14gra", "v1gra", "vagina", "viagra", "vulva", "w00se", "wang", "wank", "wanker", "wanky", "whoar", "whore", "willies", "willy", "xrated", "xxx"];

5
node_modules/badwords-list/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
object: require('./object'),
array: require('./array'),
regex: require('./regexp')
};

1
node_modules/badwords-list/lib/object.js generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/badwords-list/lib/regexp.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = /\b(4r5e|5h1t|5hit|a55|anal|anus|ar5e|arrse|arse|ass|ass-fucker|asses|assfucker|assfukka|asshole|assholes|asswhole|a_s_s|b!tch|b00bs|b17ch|b1tch|ballbag|balls|ballsack|bastard|beastial|beastiality|bellend|bestial|bestiality|bi\+ch|biatch|bitch|bitcher|bitchers|bitches|bitchin|bitching|bloody|blow job|blowjob|blowjobs|boiolas|bollock|bollok|boner|boob|boobs|booobs|boooobs|booooobs|booooooobs|breasts|buceta|bugger|bum|bunny fucker|butt|butthole|buttmuch|buttplug|c0ck|c0cksucker|carpet muncher|cawk|chink|cipa|cl1t|clit|clitoris|clits|cnut|cock|cock-sucker|cockface|cockhead|cockmunch|cockmuncher|cocks|cocksuck|cocksucked|cocksucker|cocksucking|cocksucks|cocksuka|cocksukka|cok|cokmuncher|coksucka|coon|cox|crap|cum|cummer|cumming|cums|cumshot|cunilingus|cunillingus|cunnilingus|cunt|cuntlick|cuntlicker|cuntlicking|cunts|cyalis|cyberfuc|cyberfuck|cyberfucked|cyberfucker|cyberfuckers|cyberfucking|d1ck|damn|dick|dickhead|dildo|dildos|dink|dinks|dirsa|dlck|dog-fucker|doggin|dogging|donkeyribber|doosh|duche|dyke|ejaculate|ejaculated|ejaculates|ejaculating|ejaculatings|ejaculation|ejakulate|f u c k|f u c k e r|f4nny|fag|fagging|faggitt|faggot|faggs|fagot|fagots|fags|fanny|fannyflaps|fannyfucker|fanyy|fatass|fcuk|fcuker|fcuking|feck|fecker|felching|fellate|fellatio|fingerfuck|fingerfucked|fingerfucker|fingerfuckers|fingerfucking|fingerfucks|fistfuck|fistfucked|fistfucker|fistfuckers|fistfucking|fistfuckings|fistfucks|flange|fook|fooker|fuck|fucka|fucked|fucker|fuckers|fuckhead|fuckheads|fuckin|fucking|fuckings|fuckingshitmotherfucker|fuckme|fucks|fuckwhit|fuckwit|fudge packer|fudgepacker|fuk|fuker|fukker|fukkin|fuks|fukwhit|fukwit|fux|fux0r|f_u_c_k|gangbang|gangbanged|gangbangs|gaylord|gaysex|goatse|God|god-dam|god-damned|goddamn|goddamned|hardcoresex|hell|heshe|hoar|hoare|hoer|homo|hore|horniest|horny|hotsex|jack-off|jackoff|jap|jerk-off|jism|jiz|jizm|jizz|kawk|knob|knobead|knobed|knobend|knobhead|knobjocky|knobjokey|kock|kondum|kondums|kum|kummer|kumming|kums|kunilingus|l3i\+ch|l3itch|labia|lust|lusting|m0f0|m0fo|m45terbate|ma5terb8|ma5terbate|masochist|master-bate|masterb8|masterbat*|masterbat3|masterbate|masterbation|masterbations|masturbate|mo-fo|mof0|mofo|mothafuck|mothafucka|mothafuckas|mothafuckaz|mothafucked|mothafucker|mothafuckers|mothafuckin|mothafucking|mothafuckings|mothafucks|mother fucker|motherfuck|motherfucked|motherfucker|motherfuckers|motherfuckin|motherfucking|motherfuckings|motherfuckka|motherfucks|muff|mutha|muthafecker|muthafuckker|muther|mutherfucker|n1gga|n1gger|nazi|nigg3r|nigg4h|nigga|niggah|niggas|niggaz|nigger|niggers|nob|nob jokey|nobhead|nobjocky|nobjokey|numbnuts|nutsack|orgasim|orgasims|orgasm|orgasms|p0rn|pawn|pecker|penis|penisfucker|phonesex|phuck|phuk|phuked|phuking|phukked|phukking|phuks|phuq|pigfucker|pimpis|piss|pissed|pisser|pissers|pisses|pissflaps|pissin|pissing|pissoff|poop|porn|porno|pornography|pornos|prick|pricks|pron|pube|pusse|pussi|pussies|pussy|pussys|rectum|retard|rimjaw|rimming|s hit|s.o.b.|sadist|schlong|screwing|scroat|scrote|scrotum|semen|sex|sh!\+|sh!t|sh1t|shag|shagger|shaggin|shagging|shemale|shi\+|shit|shitdick|shite|shited|shitey|shitfuck|shitfull|shithead|shiting|shitings|shits|shitted|shitter|shitters|shitting|shittings|shitty|skank|slut|sluts|smegma|smut|snatch|son-of-a-bitch|spac|spunk|s_h_i_t|t1tt1e5|t1tties|teets|teez|testical|testicle|tit|titfuck|tits|titt|tittie5|tittiefucker|titties|tittyfuck|tittywank|titwank|tosser|turd|tw4t|twat|twathead|twatty|twunt|twunter|v14gra|v1gra|vagina|viagra|vulva|w00se|wang|wank|wanker|wanky|whoar|whore|willies|willy|xrated|xxx)\b/gi;

33
node_modules/badwords-list/package.json generated vendored Normal file
View File

@ -0,0 +1,33 @@
{
"name": "badwords-list",
"version": "1.0.0",
"author": "Michael Price <webmech@gmail.com>",
"license": "MIT",
"description": "A highly consumable list of bad (profanity) english words (forked from badwords)",
"main": "./lib/index",
"scripts": {
"test": "./node_modules/.bin/mocha -R nyan"
},
"repository": {
"type": "git",
"url": "git@github.com:web-mech/badwords-list.git"
},
"keywords": [
"bad",
"word",
"words",
"profanity",
"filter",
"blacklist",
"black",
"list",
"swear"
],
"devDependencies":{
"mocha":"1.14.0",
"better-assert":"1.0.0"
},
"bugs": {
"url": "https://github.com/web-mech/badwords-list/issues"
}
}

18
node_modules/badwords-list/test/exports.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
var assert = require('better-assert');
describe('filter', function(){
it('Should contain property object', function(){
var list = require('../lib/index');
assert(list.hasOwnProperty('object'));
});
it('Should contain property array', function(){
var list = require('../lib/index');
assert(list.hasOwnProperty('array'));
});
it('Should contain property regex', function(){
var list = require('../lib/index');
assert(list.hasOwnProperty('regex'));
});
});

30
package-lock.json generated
View File

@ -5,6 +5,7 @@
"packages": {
"": {
"dependencies": {
"bad-words": "^3.0.4",
"express": "4.18.2",
"socket.io": "4.6.1"
}
@ -49,6 +50,22 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/bad-words": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/bad-words/-/bad-words-3.0.4.tgz",
"integrity": "sha512-v/Q9uRPH4+yzDVLL4vR1+S9KoFgOEUl5s4axd6NIAq8SV2mradgi4E8lma/Y0cw1ltVdvyegCQQKffCPRCp8fg==",
"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": "sha512-oWhaSG67e+HQj3OGHQt2ucP+vAPm1wTbdp2aDHeuh4xlGXBdWwzZ//pfu6swf5gZ8iX0b7JgmSo8BhgybbqszA=="
},
"node_modules/base64id": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
@ -842,6 +859,19 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"bad-words": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/bad-words/-/bad-words-3.0.4.tgz",
"integrity": "sha512-v/Q9uRPH4+yzDVLL4vR1+S9KoFgOEUl5s4axd6NIAq8SV2mradgi4E8lma/Y0cw1ltVdvyegCQQKffCPRCp8fg==",
"requires": {
"badwords-list": "^1.0.0"
}
},
"badwords-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/badwords-list/-/badwords-list-1.0.0.tgz",
"integrity": "sha512-oWhaSG67e+HQj3OGHQt2ucP+vAPm1wTbdp2aDHeuh4xlGXBdWwzZ//pfu6swf5gZ8iX0b7JgmSo8BhgybbqszA=="
},
"base64id": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"bad-words": "^3.0.4",
"express": "4.18.2",
"socket.io": "4.6.1"
}

View File

@ -35,7 +35,7 @@ class Player extends Sprite {
// ctx.drawImage(img,this.animationColumn*frameWidth,row*frameHeight, frameWidth, frameHeight, this.position.x-frameWidth/2-8, this.position.y-frameHeight/2,frameWidth*2, frameHeight*2);
ctx.fillStyle = this.color;
// ctx.fillStyle = this.color;
ctx.textAlign = "center";
ctx.fillStyle = 'hsla(211, 100%, 100%, 0.5)';
@ -55,66 +55,69 @@ class Player extends Sprite {
}
update(){
if(this.message!=''){SpeechBubble(ctx,ctx.measureText(this.message).width-20,20,'hsla(181, 100%, 100%, 0.6)',this.position.x-25,this.position.y-100,10)}
ctx.beginPath();
ctx.textAlign = "center";
ctx.font = 'bold 18px win98';
ctx.fillStyle = 'cyan';
ctx.fillText(this.username, this.position.x, this.position.y+15);
ctx.font = 'normal 15px sans-serif';
ctx.fillStyle = 'white';
ctx.fillText(this.message, this.position.x, this.position.y-65);
ctx.fillStyle = 'black';
ctx.fillText(this.message, this.position.x-5, this.position.y-80,200);
ctx.fill()
function SpeechBubble(ctx, width, height, color, x, y, radius, text)
{
var maxWidth = 300;
var r = radius;
var w = (width > maxWidth ? maxWidth : width) + 40;
var h = ((width > maxWidth ? Math.ceil(width / maxWidth) : 1) * height) + 10;
var pi2 = Math.PI * 2;
var ap = w/2-10;
var aw = 20;
var ah = 10;
x = x-(width/2)
// Speechbubble create start
ctx.beginPath();
ctx.arc(x+r, y+r, r, pi2 * 0.5, pi2 * 0.75);
ctx.arc(x+ w - r, y+ r, r, pi2 * 0.75, pi2);
ctx.arc(x+w - r,y+ h - r, r, 0, pi2 * 0.25);
ctx.lineTo(x+w - ap, y+h);
ctx.lineTo(x+w - ap - (aw / 2),y+ h + ah);
ctx.lineTo(x+w - ap - aw, y+h);
ctx.arc(x+r, y+h - r, r, pi2 * 0.25, pi2 * 0.5);
ctx.fillStyle = color;
ctx.fill();
// Speechbubble create end
// Speechbubble text start
// ctx.fillStyle = "#fff";
// wrapText(ctx, text, 25, 17, maxWidth, 16);
// Speechbubble text end
}
//ctx.measureText(this.message).width
// if((Math.sign(incrementX)==1&&fPlayer.x<clickCoordinates[0])||(Math.sign(incrementX)==-1&&fPlayer.x>clickCoordinates[0])){fPlayer.x += incrementX;fPlayer.atPosition=false; socket.emit('clickPositionX',fPlayer.x)}else{fPlayer.atPosition=true}
// if((Math.sign(incrementY)==1&&fPlayer.y<clickCoordinates[1])||(Math.sign(incrementY)==-1&&fPlayer.y>clickCoordinates[1])){fPlayer.y += incrementY;fPlayer.atPosition=false; socket.emit('clickPositionY',fPlayer.y)}else{fPlayer.atPosition=true}
if(this.position.x.toFixed(2)!=this.clickX){
calculateIncrement(this);
// if(this.messageSent){
// var refreshId = setInterval(() =>{
// clearInterval(refreshId);
// this.message=''
// console.log("message deleted")
// this.messageSent=false
// },2000)
// }
console.log(this.messageSent)
if(length>1){
this.atPosition=false
if(225<this.angleDeg && this.angleDeg<315){this.image = this.Up; console.log('going up')}else
if(225<this.angleDeg && this.angleDeg<315){this.image = this.Up}else
if(45<this.angleDeg && this.angleDeg<135){this.image = this.Down}else
if(135<this.angleDeg && this.angleDeg<225){this.image = this.Left}else{this.image = this.Right}
// console.log(this.angleDeg)
// switch(this.angleDeg){
// case -135:
// this.image = this.Up
// break;
// case 1:
// this.image = this.Down
// break;
// }
this.position.x+=this.incrementX;
this.position.y+=this.incrementY;
// console.log('goingtolocation')
}else{
this.atPosition=true
}
// function clearMessage(){
// this.message='t'
// console.log("message deleted")
// this.messageSent=false
// }
}
function calculateIncrement(player){
@ -144,3 +147,4 @@ console.log(this.messageSent)
}

View File

@ -61,7 +61,7 @@
<!-- <canvas id="canvas"></canvas> -->
<form id="textInput" action="" >
<input placeholder="Say somethinng" id="input" autocomplete="off" /><button id="messageButton">Send</button>
<input placeholder="Say something" maxlength="20" required="required" id="input" autocomplete="off" /><button id="messageButton">Send</button>
</form>

View File

@ -19,6 +19,8 @@ let pageVisible = true;
let debugMode = false;
let timeoutHandle;
// let atPosition = true;
// img.src = 'demaSprite.png';
clickCoordinates = [100,100]
@ -137,6 +139,7 @@ function animate(){
allfPlayer.draw()
if(debugMode) allfPlayer.debug()
allfPlayer.update()
// allfPlayer.message()
}