Ejemplo n.º 1
0
        internal void SendInstantMessage(uint ToId, string Message)
        {
            if (GetClient() != null && GetClient().GetHabbo() != null && OtanixEnvironment.GetGame().GetPrisaoManager().estaPreso(GetClient().GetHabbo().Id))
            {
                GetClient().SendNotif(LanguageLocale.GetValue("prisao.chatamigos"));
                return;
            }

            if (GetClient() != null && GetClient().GetHabbo() != null && !GetClient().GetHabbo().passouPin)
            {
                GetClient().SendNotif("Você precisa digitar o pin staff");
                return;
            }

            if (ToId == EmuSettings.CHAT_USER_ID)
            {
                if (!GetClient().GetHabbo().HasFuse("fuse_chat_staff")) // no inyections
                {
                    return;
                }

                ServerMessage InstantMessage = new ServerMessage(Outgoing.InstantChat);
                InstantMessage.AppendUInt(EmuSettings.CHAT_USER_ID);
                InstantMessage.AppendString(GetClient().GetHabbo().Username + ": " + Message);
                InstantMessage.AppendInt32(0);
                OtanixEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(InstantMessage, "fuse_chat_staff", UserId);

                return;
            }

            if (!FriendshipExists(ToId))
            {
                DeliverInstantMessageError(6, ToId);
                return;
            }

            var Client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

            if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().GetMessenger() == null)
            {
                // DeliverInstantMessageError(5, ToId);
                MessengerChat.AddMessageToId(UserId, ToId, Message);
                return;
            }

            if (OtanixEnvironment.GetGame().GetMuteManager().HasMuteExpired(GetClient().GetHabbo().Id) > 0)
            {
                DeliverInstantMessageError(4, ToId);
                return;
            }

            if (OtanixEnvironment.GetGame().GetMuteManager().HasMuteExpired(Client.GetHabbo().Id) > 0)
            {
                DeliverInstantMessageError(3, ToId); // No return, as this is just a warning.
            }

            if (Message == "")
            {
                return;
            }

            SpyChatMessage.SaveUserLog(UserId, 0, ToId, Message);
            Client.GetHabbo().GetMessenger().DeliverInstantMessage(Message, UserId);
        }
Ejemplo n.º 2
0
        internal void Chat(GameClient Session, string Message, int Color, bool Shout, bool frank = false)
        {
            #region Progress
            #region Checks
            if (frank)
            {
                goto NoCheckings;
            }

            if (Message.Length <= 0 || Message.Length > 100) // si el mensaje es mayor que la máxima longitud (scripter)
            {
                return;
            }

            if (OtanixEnvironment.ContainsHTMLCode(Message))
            {
                WhisperComposer(LanguageLocale.GetValue("chat.html.detected"));
                return;
            }

            if (IsPet || IsBot) // si no es un usuario, directamente saltamos a mandar el mensaje
            {
                goto NoCheckings;
            }

            if (IsSpectator)
            {
                return;
            }

            if (Session == null || Session.GetHabbo() == null) // si el usuario ya está desconectado, pasamos de todo
            {
                return;
            }

            if (!Session.GetHabbo().passouPin)
            {
                WhisperComposer("Você precisa digitar o pin staff");
                return;
            }
            #endregion

            #region Muted
            if (!GetRoom().CheckRights(Session, true)) // Si no es un staff comprobamos si está muteado.
            {
                if (GetRoom().RoomMuted)
                {
                    return;
                }

                int timeToEndRoomMute   = GetRoom().HasMuteExpired(Session.GetHabbo().Id);
                int timeToEndGlobalMute = OtanixEnvironment.GetGame().GetMuteManager().HasMuteExpired(Session.GetHabbo().Id);
                int timeMuted           = (timeToEndGlobalMute > timeToEndRoomMute) ? timeToEndGlobalMute : timeToEndRoomMute;

                if (timeMuted > 0)
                {
                    ServerMessage message = new ServerMessage(Outgoing.MuteTimerMessageComposer);
                    message.AppendInt32(timeMuted);
                    Session.SendMessage(message);
                    return;
                }
            }
            #endregion

            if (Message.StartsWith("@red@") || Message.StartsWith("@blue@") || Message.StartsWith("@cyan@") || Message.StartsWith("@green@") || Message.StartsWith("@purple@") || Message.StartsWith("@normal@"))
            {
                if (Message.StartsWith("@red@"))
                {
                    Session.GetHabbo().ChatColor = "@red@";
                    Message = Message.Replace("@red@", "");
                }
                else if (Message.StartsWith("@blue@"))
                {
                    Session.GetHabbo().ChatColor = "@blue@";
                    Message = Message.Replace("@blue@", "");
                }
                else if (Message.StartsWith("@cyan@"))
                {
                    Session.GetHabbo().ChatColor = "@cyan@";
                    Message = Message.Replace("@cyan@", "");
                }
                else if (Message.StartsWith("@green@"))
                {
                    Session.GetHabbo().ChatColor = "@green@";
                    Message = Message.Replace("@green@", "");
                }
                else if (Message.StartsWith("@purple@"))
                {
                    Session.GetHabbo().ChatColor = "@purple@";
                    Message = Message.Replace("@purple@", "");
                }
                else if (Message.StartsWith("@normal@"))
                {
                    Session.GetHabbo().ChatColor = "";
                    Message = Message.Replace("@normal@", "");
                }
            }

            #region Commands
            if (Message.StartsWith(":"))                                                             // Si el mensaje comienza por :
            {
                if (ChatCommandRegister.IsChatCommand(Message.Split(' ')[0].ToLower().Substring(1))) // si está en nuestra lista de comandos
                {
                    ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Session, mRoom, this);

                    try
                    {
                        if (handler.WasExecuted())
                        {
                            return;
                        }
                    }
                    finally
                    {
                        handler.Dispose();
                    }
                }
            }
            else if (Message.StartsWith("@"))
            {
                string nomeFinal    = String.Empty;
                var    nomeSplitado = Message.Replace("@", "").Split(' ');
                if (nomeSplitado.Length != 0)
                {
                    nomeFinal = Convert.ToString(nomeSplitado[0]);
                }

                GameClient buscaUsuario = OtanixEnvironment.GetGame().GetClientManager().GetClientByUsername(nomeFinal);
                if (buscaUsuario == null || buscaUsuario.GetHabbo() == null)
                {
                    goto naoMarcar;
                }

                ServerMessage Alert = new ServerMessage(Outgoing.CustomAlert);
                Alert.AppendString("furni_placement_error");
                Alert.AppendInt32(3);
                Alert.AppendString("message");
                Alert.AppendString("O usuário " + Session.GetHabbo().Username + " te marcou em uma conversa, clique aqui para ir ao quarto.");
                Alert.AppendString("image");
                Alert.AppendString("${image.library.url}notifications/" + EmuSettings.EVENTHA_ICON + ".png");
                Alert.AppendString("linkUrl");
                Alert.AppendString("event:navigator/goto/" + Session.GetHabbo().CurrentRoomId);
                buscaUsuario.SendMessage(Alert);

                WhisperComposer("Você marcou o usuário " + buscaUsuario.GetHabbo().Username + " com sucesso.");
            }
naoMarcar:
            #endregion
            #region Flood
            if (!Session.GetHabbo().HasFuse("ignore_flood_filter") && Session.GetHabbo().Id != GetRoom().RoomData.OwnerId&& !IsBot)
            {
                TimeSpan SinceLastMessage = DateTime.Now - Session.GetHabbo().spamFloodTime;
                if (SinceLastMessage.Seconds > 3)
                {
                    FloodCount = 0;
                }
                else if (FloodCount > 5)
                {
                    ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter);
                    Packet.AppendInt32(30);
                    GetClient().SendMessage(Packet);

                    OtanixEnvironment.GetGame().GetMuteManager().AddUserMute(Session.GetHabbo().Id, 0.5);
                    return;
                }
                Session.GetHabbo().spamFloodTime = DateTime.Now;
                FloodCount++;
            }
            #endregion
            #region Filter
            if (!Session.GetHabbo().HasFuse("ignore_spam_filter"))
            {
                if (BlackWordsManager.Check(Message, BlackWordType.Hotel, Session, "<ID do Quarto:" + Session.GetHabbo().CurrentRoomId + ">"))
                {
                    return;
                }

                if (BlackWordsManager.CheckRoomFilter(Message, mRoom.RoomFilterWords))
                {
                    return;
                }
            }
            #endregion

            #region Show Message Progress
            if (Session.GetHabbo().Rank < 2 && EmuSettings.CHAT_TYPES_USERS.Contains(Color))
            {
                Color = 0;
            }

            // if (Session.GetHabbo().GetBadgeComponent().HasBadge(OtanixEnvironment.GetGame().GetRoomRankConfig().BOTS_DEFAULT_BADGE) && Session.GetHabbo().GetBadgeComponent().GetBadge(OtanixEnvironment.GetGame().GetRoomRankConfig().BOTS_DEFAULT_BADGE).Slot > 0 && OtanixEnvironment.GetGame().GetRoomRankConfig().ROOMS_TO_MODIFY.Contains((int)GetRoom().RoomId))
            //     Color = OtanixEnvironment.GetGame().GetRoomRankConfig().BOTS_DEFAULT_COLOR; // si la sala está elegida como sala para bots, mejor que cada bot hable con su tipo de chat, no?

            Unidle();
            OtanixEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.SOCIAL_CHAT); // miramos el reto

            SpyChatMessage.SaveUserLog(Session.GetHabbo().Id, mRoom.RoomId, 0, Message);
            var Mess = new ChatMessage(Session.GetHabbo().Id, Session.GetHabbo().Username, mRoom.RoomId, Message, DateTime.Now, true); // creamos la clase para el Mensaje
            Session.GetHabbo().GetChatMessageManager().AddMessage(Mess);                                                               // Mod Tools: User Message
            mRoom.GetChatMessageManager().AddMessage(Mess);                                                                            // Mod Tools: Room Message

            OtanixEnvironment.GetGame().CorManager().atualizaPracolorido(Session);

NoCheckings:
            GetRoom().QueueChatMessage(new InvokedChatMessage(this, Message, Color, Shout));

            if (IsBot)
            {
                BotCommands(VirtualId, Message, mRoom);
            }
            #endregion
            #endregion
        }