Exemplo n.º 1
0
        private object OnUserChat(IPlayer player, string message)
        {
            if (UFilter != null)
            {
                var advertisements = (string[])UFilter.Call("Advertisements");
                if (advertisements != null && advertisements.Contains(message))
                {
                    return(null);
                }
            }

            foreach (var target in players.Connected)
            {
#if !DEBUG
                if (player.Equals(target))
                {
                    SendMessage(player, player, message);
                    continue;
                }
#endif
                Action <string> callback = response =>
                {
                    if (config.ShowOriginal)
                    {
                        response = $"{message}\n{response}";
                    }
                    SendMessage(target, player, response);
                };
                Translate(message, target.Id, player.Id, callback);
            }

            return(BetterChat == null ? (object)true : null);
        }
Exemplo n.º 2
0
        private object HandleChat(IPlayer player, string message)
        {
            if (UFilter != null)
            {
                string[] advertisements = UFilter.Call <string[]>("Advertisements");
                if (advertisements != null && Enumerable.Contains(advertisements, message))
                {
                    return(null);
                }
            }

            foreach (IPlayer target in players.Connected)
            {
#if !DEBUG
                if (player.Equals(target))
                {
                    SendMessage(player, player, message);
                    continue;
                }
#endif

                Action <string> callback = response =>
                {
                    if (config.ShowOriginal)
                    {
                        response = $"{message}\n{response}";
                    }

                    SendMessage(target, player, response);
                };
                Translate(message, target.Id, player.Id, callback);
            }

            return(true);
        }
Exemplo n.º 3
0
            public static void SendPM(IPlayer sender, IPlayer target, string message)
            {
                if (sender.Id == target.Id)
                {
                    sender.Message(LangMsg("NOT_PM_SELF", sender.Id));
                    return;
                }

                if (UFilter != null && UseUFilter == true)
                {
                    object filter = (object)UFilter?.Call("ProcessText", message, sender);

                    if (filter == null)
                    {
                        return;
                    }

                    message = filter.ToString();
                }

                if (UseCooldown)
                {
                    double time;
                    if (cooldown.TryGetValue(sender.Id, out time))
                    {
                        if (time > GetTimeStamp())
                        {
                            sender.Message(string.Format(LangMsg("COOLDOWN_MSG", sender.Id), Math.Round(time - GetTimeStamp(), 2)));
                            return;
                        }
                        else
                        {
                            cooldown.Remove(sender.Id);
                        }
                    }

                    cooldown.Add(sender.Id, GetTimeStamp() + Cooldown_Seconds);
                }
                PrivateMessage msg = FindOrCreate(sender.Id, target.Id);

                target.Message(string.Format(LangMsg("PM_FROM"), sender.Name, message));
                sender.Message(string.Format(LangMsg("PM_TO"), target.Name, message));

                lastplayer[sender.Id] = target.Id;
                lastplayer[target.Id] = sender.Id;

                msg.history.Add(string.Format(LangMsg("HISTORY_SYNTAX"), sender.Name, target.Name, message));

                if (msg.history.Count == 6)
                {
                    msg.history.Remove(msg.history.First());
                }
            }
Exemplo n.º 4
0
        private string IsUFilter(string[] args, bool isR = false)
        {
            string message = string.Join(" ", args.Skip(1).ToArray());

            if (isR)
            {
                message = string.Join(" ", args.Skip(0).ToArray());
            }

            if (configData.UseUFilter)
            {
                var hasUFilter = (object)UFilter?.Call("ProcessText", message);

                if (hasUFilter != null)
                {
                    message = hasUFilter.ToString();
                }
            }

            return(message);
        }