| Line | |
|---|
| 1 | using System;
|
|---|
| 2 | using AllocsFixes.PersistentData;
|
|---|
| 3 |
|
|---|
| 4 | namespace CoppisAdditions
|
|---|
| 5 | {
|
|---|
| 6 | public class ChatFilter
|
|---|
| 7 | {
|
|---|
| 8 |
|
|---|
| 9 | public static bool Exec (ClientInfo _cInfo, EnumGameMessages _type, string _message, string _playerName)
|
|---|
| 10 | {
|
|---|
| 11 | if (_type == EnumGameMessages.Chat && !string.IsNullOrEmpty (_message)) {
|
|---|
| 12 | if (_cInfo != null) {
|
|---|
| 13 | Player p = PersistentContainer.Instance.Players [_cInfo.playerId, false];
|
|---|
| 14 | if (p != null) {
|
|---|
| 15 | if (_message.Length > p.MaxChatLength) {
|
|---|
| 16 | _cInfo.SendPackage (new NetPackageGameMessage (EnumGameMessages.Chat, "Your message was too long. So we blocked it!", "Server (PM)", false, "", false));
|
|---|
| 17 | return false;
|
|---|
| 18 | }
|
|---|
| 19 | if (p.IsChatMuted) {
|
|---|
| 20 | _cInfo.SendPackage (new NetPackageGameMessage (EnumGameMessages.Chat, "Your chat is muted!", "Server (PM)", false, "", false));
|
|---|
| 21 | return false;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | //Check its a command
|
|---|
| 25 | if (PersistentContainer.Instance.Attributes.HideChatCommands) {
|
|---|
| 26 | if (_message.Trim ().StartsWith (PersistentContainer.Instance.Attributes.HideChatCommandPrefix)) {
|
|---|
| 27 | _cInfo.SendPackage (new NetPackageGameMessage (EnumGameMessages.Chat, "Command received " + _message, "Server (PM)", false, "", false));
|
|---|
| 28 | Log.Out ("Chat command from '" + p.Name + "': " + _message);
|
|---|
| 29 | return false;
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
| 33 | } else {
|
|---|
| 34 | // Log.Error ("ChatFilter: Argument _cInfo null on message: {0}", _message);
|
|---|
| 35 | }
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | return true;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.