void Player_PlayerChat(Player p, string message)
        {
            if (Player.HasBadColorCodes(message) || String.IsNullOrEmpty(message.Trim()))
            {
                Player.SendMessage(p, "You cannot send that message");
                return;
            }


            if (Server.ircColorsEnable == true && Server.irc && IsConnected())
            {
                Say(p.color + p.prefix + p.name + ": &0" + message, p.opchat);
            }
            if (Server.ircColorsEnable == false && Server.irc && IsConnected())
            {
                Say(p.name + ": " + message, p.opchat);
            }
        }
        void Listener_OnNick(UserInfo user, string newNick)
        {
            //Player.GlobalMessage(Server.IRCColour + "[IRC] " + user.Nick + " changed nick to " + newNick);

            if (Player.HasBadColorCodes(newNick) || newNick.Trim() == "")
            {
                this.Pm(user.Nick, "You cannot have that username");
                return;
            }

            string key;

            if (newNick.Split('|').Length == 2)
            {
                key = newNick.Split('|')[1];
                if (key != null && key != "")
                {
                    switch (key)
                    {
                    case "AFK":
                        Player.GlobalMessage("[IRC] " + Server.IRCColour + user.Nick + Server.DefaultColor + " is AFK"); Server.ircafkset.Add(user.Nick); break;

                    case "Away":
                        Player.GlobalMessage("[IRC] " + Server.IRCColour + user.Nick + Server.DefaultColor + " is Away"); Server.ircafkset.Add(user.Nick); break;
                    }
                }
            }
            else if (Server.ircafkset.Contains(newNick))
            {
                Player.GlobalMessage("[IRC] " + Server.IRCColour + newNick + Server.DefaultColor + " is back");
                Server.ircafkset.Remove(newNick);
            }
            else
            {
                Player.GlobalMessage("[IRC] " + Server.IRCColour + user.Nick + Server.DefaultColor + " is now known as " + newNick);
            }
        }
Beispiel #3
0
        public void Say(string message, Player p = null)
        {
            if (p != null && p.muted)
            {
                Player.SendMessage(p, "*Tears* You aren't allowed to talk to the nice people of global chat");
            }
            if ((p == null && !Server.canusegc) || (p != null && !p.canusegc))
            {
                Player.SendMessage(p, "You can no longer use the GC!");
                return;
            }
            #region General rules
            if (message.Contains("minecraft.net/classic/play/"))
            {
                Player.SendMessage(p, "No server links Mr whale!");
                if (p == null)
                {
                    Server.gcmultiwarns++;
                }
                else
                {
                    p.multi++;
                    Command.all.Find("gcrules").Use(p, "");
                }
                return;
            }
            if (message.Contains("http://") || message.Contains("https://") || message.Contains("www."))
            {
                Player.SendMessage(p, "No links!");
                if (p == null)
                {
                    Server.gcmultiwarns++;
                }
                else
                {
                    p.multi++;
                    Command.all.Find("gcrules").Use(p, "");
                }
                return;
            }
            if (Player.HasBadColorCodes(message))
            {
                Player.SendMessage(p, "Can't let you do that Mr whale!");
                if (p != null)
                {
                    p.Kick("Kicked for trying to crash all players!");
                }
                return;
            }
            if (message.ToLower().Contains(Server.name.ToLower()))
            {
                Player.SendMessage(p, "Let's not advertise Mr whale!");
                if (p != null)
                {
                    p.multi++;
                }
                else
                {
                    Server.gcmultiwarns++;
                }
                return;
            }
            #endregion
            #region Repeating message spam
            if ((p == null ? Server.gclastmsg : p.lastmsg) == message.ToLower())
            {
                if (p == null)
                {
                    Server.gcspamcount++; Server.gcmultiwarns++;
                }
                else
                {
                    p.spamcount++; p.multi++;
                }
                Player.SendMessage(p, "Don't send repetitive messages!");
                if ((p == null ? Server.gcspamcount : p.spamcount) >= 4)
                {
                    if (p == null)
                    {
                        Server.canusegc = false;
                    }
                    else
                    {
                        p.canusegc = false;
                    }
                    Player.SendMessage(p, "You can no longer use the gc! Reason: repetitive message spam");
                    return;
                }
                if ((p == null ? Server.gcspamcount : p.spamcount) >= 2)
                {
                    return;
                }
                return;
            }
            else
            {
                if (p != null)
                {
                    p.lastmsg = message.ToLower(); p.spamcount = 0;
                }
                else
                {
                    Server.gclastmsg = message.ToLower(); Server.gcspamcount = 0;
                }
            }
            #endregion

            /*
             #region Caps spam
             * int rage = 0;
             * for (int i = 0; i < message.Length; i++) { if (caps.IndexOf(message[i]) != -1) { rage++; } }
             * if (rage >= 7 && !(message.Length <= 7)) { //maybe more if there are still people who use proper capitalization?
             *  Player.SendMessage(p, "Woah there Mr whale, lay of the caps!");
             *  message = message.ToLower();
             *  if (p == null) { Server.gccapscount++; Server.gcmultiwarns++; }
             *  else { p.capscount++; p.multi++; }
             *  if ((p == null ? Server.gccapscount : p.capscount) >= 5) {
             *      if (p == null) { Server.canusegc = false; }
             *      else { Server.canusegc = false; }
             *      Player.SendMessage(p, "You can no longer use the gc! Reason: caps spam");
             *      return;
             *  }
             *  if (rage >= 10) { return; }
             * }
             #endregion*/
            #region Flooding
            TimeSpan t = DateTime.Now - (p == null ? Server.gclastmsgtime : p.lastmsgtime);
            if (t < new TimeSpan(0, 0, 1))
            {
                Player.SendMessage(p, "Stop the flooding buddy!");
                if (p == null)
                {
                    Server.gcfloodcount++; Server.gcmultiwarns++;
                }
                else
                {
                    p.floodcount++; p.multi++;
                }
                if ((p == null ? Server.gcfloodcount : p.floodcount) >= 5)
                {
                    if (p == null)
                    {
                        Server.canusegc = false;
                    }
                    else
                    {
                        p.canusegc = false;
                    }
                    Player.SendMessage(p, "You can no longer use the gc! Reason: flooding");
                }
                if ((p == null ? Server.gcfloodcount : p.floodcount) >= 3)
                {
                    return;
                }
            }
            if (p != null)
            {
                p.lastmsgtime = DateTime.Now;
            }
            else
            {
                Server.gclastmsgtime = DateTime.Now;
            }
            #endregion

            if ((p == null ? Server.gcmultiwarns : p.multi) >= 10)
            {
                if (p == null)
                {
                    Server.canusegc = false;
                }
                else
                {
                    p.canusegc = false;
                }
                Player.SendMessage(p, "You can no longer use the gc! Reason: multiple offenses!");
                return;
            }
            if (OnNewSayGlobalMessage != null)
            {
                OnNewSayGlobalMessage(p == null ? "Console" : p.name, message);
            }
            if (Server.UseGlobalChat && IsConnected())
            {
                connection.Sender.PublicMessage(channel, message);
            }
        }
        public void Say(string message, Player p = null)
        {
            RemoveVariables(ref message);
            RemoveWhitespace(ref message);

            if (p != null && p.muted)
            {
                Player.SendMessage(p, "*Tears* You aren't allowed to talk to the nice people of global chat");
            }
            if ((p == null && !Server.canusegc) || (p != null && !p.canusegc))
            {
                Player.SendMessage(p, "You can no longer use the GC!");
                return;
            }
            #region General rules
            if (message.Contains("minecraft.net/classic/play/"))
            {
                Player.SendMessage(p, "No server links Mr whale!");
                if (p == null)
                {
                    Server.gcmultiwarns++;
                }
                else
                {
                    p.multi++;
                    Command.all.Find("gcrules").Use(p, "");
                }
                return;
            }
            if (message.Contains("http://") || message.Contains("https://") || message.Contains("www."))
            {
                Player.SendMessage(p, "No links!");
                if (p == null)
                {
                    Server.gcmultiwarns++;
                }
                else
                {
                    p.multi++;
                    Command.all.Find("gcrules").Use(p, "");
                }
                return;
            }
            if (Player.HasBadColorCodes(message))
            {
                Player.SendMessage(p, "Can't let you do that Mr whale!");
                if (p != null)
                {
                    p.Kick("Kicked for trying to crash all players!");
                }
                return;
            }
            if (message.ToLower().Contains(Server.name.ToLower()))
            {
                Player.SendMessage(p, "Let's not advertise Mr whale!");
                if (p != null)
                {
                    p.multi++;
                }
                else
                {
                    Server.gcmultiwarns++;
                }
                return;
            }
            #endregion
            #region Repeating message spam
            if ((p == null ? Server.gclastmsg : p.lastmsg) == message.ToLower())
            {
                if (p == null)
                {
                    Server.gcspamcount++; Server.gcmultiwarns++;
                }
                else
                {
                    p.spamcount++; p.multi++;
                }
                Player.SendMessage(p, "Don't send repetitive messages!");
                if ((p == null ? Server.gcspamcount : p.spamcount) >= 4)
                {
                    if (p == null)
                    {
                        Server.canusegc = false;
                    }
                    else
                    {
                        p.canusegc = false;
                    }
                    Player.SendMessage(p, "You can no longer use the gc! Reason: repetitive message spam");
                    return;
                }
                if ((p == null ? Server.gcspamcount : p.spamcount) >= 2)
                {
                    return;
                }
                return;
            }
            else
            {
                if (p != null)
                {
                    p.lastmsg = message.ToLower(); p.spamcount = 0;
                }
                else
                {
                    Server.gclastmsg = message.ToLower(); Server.gcspamcount = 0;
                }
            }
            #endregion
            #region Flooding

            TimeSpan t = DateTime.Now - (p == null ? Server.gclastmsgtime : p.lastmsgtime);

            if (t < new TimeSpan(0, 0, 1))
            {
                Player.SendMessage(p, "Stop the flooding buddy!");

                if (p == null)
                {
                    Server.gcfloodcount++;
                    Server.gcmultiwarns++;
                }
                else
                {
                    p.floodcount++;
                    p.multi++;
                }

                if ((p == null ? Server.gcfloodcount : p.floodcount) >= 5)
                {
                    if (p == null)
                    {
                        Server.canusegc = false;
                    }
                    else
                    {
                        p.canusegc = false;
                    }

                    Player.SendMessage(p, "You can no longer use the gc! Reason: flooding");
                }
                if ((p == null ? Server.gcfloodcount : p.floodcount) >= 3)
                {
                    return;
                }
            }
            if (p != null)
            {
                p.lastmsgtime = DateTime.Now;
            }
            else
            {
                Server.gclastmsgtime = DateTime.Now;
            }

            #endregion

            if ((p == null ? Server.gcmultiwarns : p.multi) >= 10)
            {
                if (p == null)
                {
                    Server.canusegc = false;
                }
                else
                {
                    p.canusegc = false;
                }
                Player.SendMessage(p, "You can no longer use the gc! Reason: multiple offenses!");

                return;
            }

            if (String.IsNullOrEmpty(message.Replace("Console:", "").Trim()))
            {
                Player.SendMessage(p, "You should send some text!");
                return;
            }

            if (OnNewSayGlobalMessage != null)
            {
                OnNewSayGlobalMessage(p == null ? "Console" : p.name, message);
            }

            if (Server.UseGlobalChat && IsConnected())
            {
                connection.Sender.PublicMessage(channel, message);
            }
        }