emojis cant be send in chat anymore

This commit is contained in:
GameHerobrine 2022-08-28 12:24:20 +03:00
parent 5e45d6160c
commit 732591f174
2 changed files with 9 additions and 2 deletions

View file

@ -2042,6 +2042,10 @@ class Player{
$this->server->api->console->run(substr($message, 1), $this);
}else{
$data = ["player" => $this, "message" => $message];
if(Utils::hasEmoji($data["message"])){
$this->sendChat("Your message contains illegal characters");
break;
}
if($this->server->api->handle("player.chat", $data) !== false){
$this->server->send2Discord("<" . $this->username . "> " . $message);
if(isset($data["message"])){

View file

@ -12,7 +12,7 @@ class Utils{
/*public static function isOnline(){
return ((@fsockopen("8.8.8.8", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.linux.org", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.php.net", 80, $e = null, $n = null, 2) !== false) ? true:false);
}*/
const emojiRegex = "([*#0-9](?>\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?|(((?<zwj>\\xE2\\x80\\x8D)\\xE2\\x9D\\xA4\\xEF\\xB8\\x8F\k<zwj>\\xF0\\x9F..(\k<zwj>\\xF0\\x9F\\x91.)?|(\\xE2\\x80\\x8D\\xF0\\x9F\\x91.){2,3}))?))";
public static function getEntityTypeByID($id){
switch($id){
case 10:
@ -38,7 +38,9 @@ class Utils{
}
return $id;
}
public static function hasEmoji($s){
return preg_match(Utils::emojiRegex, $s, $matches);
}
public static function getCallableIdentifier(callable $variable){
if(is_array($variable)){
return sha1(strtolower(get_class($variable[0])) . "::" . strtolower($variable[1]));
@ -662,6 +664,7 @@ class Utils{
}
return $x;
}
}
//if(Utils::isOnline() === false){