Пример #1
0
        internal void HandleSpeech(GameClient Session, string str, bool bool_13, int TextColor = 0)
        {
            if (TextColor == 23 && Session.GetHabbo().Rank < 4)
            {
                TextColor = 0;
            }
            if (TextColor > 23 || TextColor < 0 || TextColor == 1 || TextColor == 8 || TextColor == 2)
            {
                TextColor = 0;
            }
            if (!String.IsNullOrEmpty(str) || !String.IsNullOrWhiteSpace(str))
            {
                string object_ = str;

                // string linkRegex = @"((http|https):\/\/|www.)?[a-zA-Z0-9\-\.]+\b(com|co\.uk|org|net|eu|cf|info|ml|nl|ca|es|fi)\b";

                if (Session == null || (Session.GetHabbo().HasFuse("ignore_roommute") || !this.GetRoom().bool_4))
                {
                    this.Unidle();

                    if (!this.IsBot && this.GetClient().GetHabbo().IsMuted)
                    {
                        this.GetClient().SendNotification(EssentialEnvironment.GetExternalText("error_muted"));
                    }
                    else
                    {
                        if (!str.StartsWith(":") || Session == null || !ChatCommandHandler.HandleCommands(Session, str.Substring(1)))
                        {
                            uint num = Outgoing.Talk; // Updated
                            if (bool_13)
                            {
                                num = Outgoing.Shout; // Updated
                            }
                            if (!this.IsBot && Session.GetHabbo().method_4() > 0)
                            {
                                TimeSpan timeSpan = DateTime.Now - Session.GetHabbo().dateTime_0;
                                if (timeSpan.Seconds > 4)
                                {
                                    Session.GetHabbo().int_23 = 0;
                                }
                                if (timeSpan.Seconds < 4 && Session.GetHabbo().int_23 > 5 && !this.IsBot)
                                {
                                    ServerMessage Message = new ServerMessage(Outgoing.FloodFilter);
                                    Message.AppendInt32(Session.GetHabbo().method_4());
                                    this.GetClient().SendMessage(Message);
                                    this.GetClient().GetHabbo().IsMuted = true;
                                    this.GetClient().GetHabbo().int_4   = Session.GetHabbo().method_4();
                                    return;
                                }
                                Session.GetHabbo().dateTime_0 = DateTime.Now;
                                Session.GetHabbo().int_23++;
                            }

                            if (!this.IsBot)
                            {
                                str = ChatCommandHandler.ApplyFilter(str);
                            }

                            if (!this.GetRoom().method_9(this, str))
                            {
                                ServerMessage Message2 = new ServerMessage(num);
                                Message2.AppendInt32(this.VirtualId);
                                string Site = "";
                                if (str.Contains("http://") || str.Contains("www."))
                                {
                                    string[] Split = str.Split(' ');

                                    foreach (string Msg in Split)
                                    {
                                        if (Msg.StartsWith("http://") || Msg.StartsWith("www."))
                                        {
                                            Site = Msg;
                                        }
                                    }

                                    //str = str.Replace(Site, "{0}");
                                }

                                Message2.AppendStringWithBreak(str);
                                Message2.AppendInt32(ParseEmoticon(str));
                                Message2.AppendInt32(this.IsBot && !this.IsPet ? 2 : TextColor);
                                Message2.AppendInt32(0);
                                Message2.AppendInt32(-1);
                                if (!Essential.GetAntiAd().ContainsIllegalWord(object_))
                                {
                                    if (!this.IsBot && this.GetClient() != null && this.GetClient().GetHabbo().PassedSafetyQuiz)
                                    {
                                        this.GetRoom().method_58(Message2, Session.GetHabbo().list_2, Session.GetHabbo().Id);
                                    }
                                    else
                                    {
                                        this.GetRoom().SendMessage(Message2, this.IsPet ? this.GetRoom().RoomUsers.Where(p => p != null && p.GetClient() != null && p.GetClient().GetHabbo() != null && p.GetClient().GetHabbo().MutePets).Select(o => o.GetClient().GetHabbo().Id).ToList() : this.IsBot ? this.GetRoom().RoomUsers.Where(p => p != null && p.GetClient() != null && p.GetClient().GetHabbo() != null && p.GetClient().GetHabbo().MuteBots).Select(o => o.GetClient().GetHabbo().Id).ToList() : null);
                                    }
                                }
                                else if (Essential.GetAntiAd().ContainsIllegalWord(object_) && this.GetClient() != null)
                                {
                                    ServerMessage Message3 = new ServerMessage(Outgoing.InstantChat);
                                    Message3.AppendUInt(0u);
                                    Message3.AppendString("[AWS] " + Session.GetHabbo().Username + ": " + object_);
                                    Message3.AppendString(Essential.GetUnixTimestamp() + string.Empty);
                                    Essential.GetGame().GetClientManager().SendToStaffs(Session, Message3);

                                    Session.SendNotification(Essential.GetGame().GetRoleManager().GetConfiguration().getData("antiad.alert"));
                                    return;
                                }
                            }
                            else
                            {
                                if (!this.IsBot)
                                {
                                    Session.GetHabbo().Whisper(str);
                                }
                            }

                            if (!this.IsBot)
                            {
                                this.GetRoom().method_7(this, str, bool_13);

                                if (Session.GetHabbo().CurrentQuestId > 0 && Essential.GetGame().GetQuestManager().GetQuestAction(Session.GetHabbo().CurrentQuestId) == "CHAT_WITH_SOMEONE")
                                {
                                    Essential.GetGame().GetQuestManager().ProgressUserQuest(Session.GetHabbo().CurrentQuestId, Session);
                                }
                            }

                            if (ServerConfiguration.EnableChatlog && !this.IsBot && !Essential.GetAntiAd().ContainsIllegalWord(object_) && this.GetRoom().Id != 74402)
                            {
                                using (DatabaseClient @class = Essential.GetDatabase().GetClient())
                                {
                                    @class.AddParamWithValue("message", object_);
                                    @class.ExecuteQuery(string.Concat(new object[]
                                    {
                                        "INSERT INTO chatlogs (user_id,room_id,hour,minute,timestamp,message,user_name,full_date) VALUES ('",
                                        Session.GetHabbo().Id,
                                        "','",
                                        this.GetRoom().Id,
                                        "','",
                                        DateTime.Now.Hour,
                                        "','",
                                        DateTime.Now.Minute,
                                        "',UNIX_TIMESTAMP(),@message,'",
                                        Session.GetHabbo().Username,
                                        "','",
                                        DateTime.Now.ToLongDateString(),
                                        "')"
                                    }));
                                }
                            }
                        }
                    }
                }
            }
        }