mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-12-03 20:31:07 -05:00
19 lines
588 B
JavaScript
19 lines
588 B
JavaScript
/* eslint-disable max-len */
|
|
/**
|
|
* character allowed in mc chat
|
|
* @param {String} character the character
|
|
* @return {boolean} allowed
|
|
*/
|
|
function isAllowedCharacter (character) {
|
|
return character !== '\xa7' && character >= ' ' && character !== '\x7f'
|
|
}
|
|
/**
|
|
* mc chat check if contains illegal chars.
|
|
* @param {String} string the string
|
|
* @return {boolean} if contains then true else false
|
|
*/
|
|
function containsIllegalCharacters (string) {
|
|
for (let i = 0; i < string.length; i++) if (!isAllowedCharacter(string[i])) return true
|
|
}
|
|
|
|
module.exports = { containsIllegalCharacters }
|