internal void Chat(GameClient Session, string Message, bool Shout) { if (Session != null) { if (Session.GetHabbo().Rank < 5) { if (GetRoom().RoomMuted) { return; } } } Unidle(); if (!IsBot && GetClient().GetHabbo().Muted) { GetClient().SendNotif("You are muted."); return; } if (Message.StartsWith(":") && Session != null) { string[] parsedCommand = Message.Split(' '); if (ChatCommandRegister.IsChatCommand(parsedCommand[0].ToLower().Substring(1))) { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Session); if (handler.WasExecuted()) { Logging.LogMessage(string.Format("User {0} issued command {1}", GetUsername(), Message)); if (Session.GetHabbo().Rank > 5) { ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message)); } return; } } } uint rank = 1; Message = LanguageLocale.FilterSwearwords(Message); if (!IsBot && Session != null && Session.GetHabbo() != null) { rank = Session.GetHabbo().Rank; } TimeSpan SinceLastMessage = DateTime.Now - FloodTime; if (SinceLastMessage.Seconds > 4) { FloodCount = 0; } if (SinceLastMessage.Seconds < 4 && FloodCount > 5 && !IsBot && rank < 5) { ServerMessage Packet = new ServerMessage(27); Packet.AppendInt32(30); //Blocked for 30sec GetClient().SendMessage(Packet); return; } FloodTime = DateTime.Now; FloodCount++; if (!IsBot) { ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.SOCIAL_CHAT); } InvokedChatMessage message = new InvokedChatMessage(this, Message, Shout); GetRoom().QueueChatMessage(message); }
internal void Chat(GameClient Session, string Message, bool Shout) { if (Session != null) { if (Session.GetHabbo().Rank < 5) { if (GetRoom().RoomMuted) { return; } } } Unidle(); if (!IsPet && !IsBot) { Users.Habbo clientUser = GetClient().GetHabbo(); if (clientUser.Muted) { GetClient().SendNotif("You are muted."); return; } if (Message.StartsWith(":") && Session != null) { string[] parsedCommand = Message.Split(' '); if (ChatCommandRegister.IsChatCommand(parsedCommand[0].ToLower().Substring(1))) { try { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Session); if (handler.WasExecuted()) { //Logging.LogMessage(string.Format("User {0} issued command {1}", GetUsername(), Message)); if (Session.GetHabbo().Rank > 5) { FirewindEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message)); } return; } } catch (Exception x) { Logging.LogException("In-game command error: " + x.ToString()); } } if (FirewindEnvironment.IsHabin) { bool result; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT id FROM users WHERE (hpo = '1' OR hpo = '1' OR hds = '1' OR hmg = '1' OR hmb = '1' OR ele = '1' OR lar = '1') AND username = @name"); dbClient.addParameter("name", Session.GetHabbo().Username); result = dbClient.findsResult(); string command = parsedCommand[0].Substring(1); // F**k this command system, we make our own! switch (command) { case "relationship": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE (recipent_id = @myid OR sender_id = @myid) AND accepted = '0'"); dbClient.addParameter("myid", Session.GetHabbo().Id); if (dbClient.findsResult()) { Session.SendMOTD("Du har allerede spurt om et forhold med denne personen, vennligst vent på et svar."); return; } dbClient.setQuery("SELECT id FROM users WHERE username = @name"); dbClient.addParameter("name", parsedCommand[1]); int id = dbClient.getInteger(); dbClient.setQuery("INSERT IGNORE INTO users_relationships(sender_id,recipent_id) VALUES(@myid,@hisid)"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("hisid", id); dbClient.runQuery(); Session.SendMOTD("Du har sendt en forespørsel til " + parsedCommand[1]); return; case "mystatus": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } if (false) { Session.SendMOTD("Du er i et forhold med {0}, vil du avslutte forholdet skriv :remove {0}"); return; } StringBuilder statusMessage = new StringBuilder(); statusMessage.AppendLine("Du har følgende forespørsler:"); dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE accepted = '0' AND recipent_id = @myid LIMIT 6"); dbClient.addParameter("myid", Session.GetHabbo().Id); DataTable table = dbClient.getTable(); foreach (DataRow row in table.Rows) { statusMessage.AppendLine(FirewindEnvironment.getHabboForId(Convert.ToUInt32(row[0])).Username); } statusMessage.AppendLine("Du kan maks ha 6 forespørsler på en gang."); statusMessage.AppendLine("Skriv :accept navn for å akseptere en forespørsel."); Session.SendMOTD(statusMessage.ToString()); return; case "accept": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("SELECT sender_id FROM users_relationships WHERE (recipent_id = @myid OR sender_id = @myid) AND accepted = '1'"); dbClient.addParameter("myid", Session.GetHabbo().Id); if (dbClient.findsResult()) { Session.SendMOTD("Du er allerede i et forhold!"); return; } dbClient.setQuery("UPDATE users_relationships SET accepted = '1' WHERE sender_id = @sid AND recipent_id = @myid LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("sid", FirewindEnvironment.getHabboForName(parsedCommand[1]).Id); dbClient.runQuery(); Session.SendMOTD("Du er nå i et forhold med " + parsedCommand[1]); return; case "decline": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE sender_id = @sid AND recipent_id = @myid AND accepted = '0' LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.addParameter("sid", FirewindEnvironment.getHabboForName(parsedCommand[1]).Id); dbClient.runQuery(); Session.SendMOTD("Du har avslått " + parsedCommand[1]); return; case "declineall": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE recipent_id = @myid AND accepted = '0' LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.runQuery(); Session.SendMOTD("Du har avslått alle."); return; case "status": uint userID = FirewindEnvironment.getHabboForName(parsedCommand[1]).Id; dbClient.setQuery("SELECT sender_id,recipent_id FROM users_relationships WHERE (recipent_id = @userid OR sender_id = @userid) AND accepted = '1' LIMIT 1"); dbClient.addParameter("userid", userID); DataRow resultRow = dbClient.getRow(); if (resultRow == null) { Session.SendMOTD(parsedCommand[1] + " er singel."); } else { bool isSender = Convert.ToUInt32(resultRow[0]) == userID; Session.SendMOTD(parsedCommand[1] + " er i et forhold med " + (isSender ? FirewindEnvironment.getHabboForId(Convert.ToUInt32(resultRow[1])).Username : FirewindEnvironment.getHabboForId(Convert.ToUInt32(resultRow[0])).Username)); } return; case "removerelationship": if (!result) { Session.SendMOTD("Du må være medlem av Mafia eller Police for å ha kommandoene til forhold."); break; } dbClient.setQuery("DELETE FROM users_relationships WHERE accepted = '1' AND (recipent_id = @myid OR sender_id = @myid) LIMIT 1"); dbClient.addParameter("myid", Session.GetHabbo().Id); dbClient.runQuery(); Session.SendMOTD("Du er ikke lenger i noen forhold."); return; } } } } uint rank = 1; Message = LanguageLocale.FilterSwearwords(Message); if (Session != null && Session.GetHabbo() != null) { rank = Session.GetHabbo().Rank; } TimeSpan SinceLastMessage = DateTime.Now - clientUser.spamFloodTime; if (SinceLastMessage.TotalSeconds > clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { FloodCount = 0; clientUser.spamProtectionBol = false; clientUser.spamProtectionAbuse = 0; } else { if (SinceLastMessage.TotalSeconds > 4) { FloodCount = 0; } } if (SinceLastMessage.TotalSeconds < clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); int timeToWait = clientUser.spamProtectionTime - SinceLastMessage.Seconds; Packet.AppendInt32(timeToWait); //Blocked for X sec GetClient().SendMessage(Packet); if (FirewindEnvironment.spamBans == true) { clientUser.spamProtectionAbuse++; GameClient toBan; toBan = FirewindEnvironment.GetGame().GetClientManager().GetClientByUsername(Session.GetHabbo().Username); if (clientUser.spamProtectionAbuse >= FirewindEnvironment.spamBans_limit) { FirewindEnvironment.GetGame().GetBanManager().BanUser(toBan, "SPAM*ABUSE", 800, LanguageLocale.GetValue("flood.banmessage"), false); } else { toBan.SendNotif(LanguageLocale.GetValue("flood.pleasewait").Replace("%secs%", Convert.ToString(timeToWait))); } } return; } if (SinceLastMessage.TotalSeconds < 4 && FloodCount > 5 && rank < 5) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); clientUser.spamProtectionCount += 1; if (clientUser.spamProtectionCount % 2 == 0) { clientUser.spamProtectionTime = (10 * clientUser.spamProtectionCount); } else { clientUser.spamProtectionTime = 10 * (clientUser.spamProtectionCount - 1); } clientUser.spamProtectionBol = true; Packet.AppendInt32(clientUser.spamProtectionTime - SinceLastMessage.Seconds); //Blocked for X sec GetClient().SendMessage(Packet); return; } clientUser.spamFloodTime = DateTime.Now; FloodCount++; FirewindEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.SOCIAL_CHAT); GetClient().GetHabbo().GetChatMessageManager().AddMessage(ChatMessageFactory.CreateMessage(Message, this.GetClient(), this.GetRoom())); } InvokedChatMessage message = new InvokedChatMessage(this, Message, Shout); GetRoom().QueueChatMessage(message); }
internal override void Chat(string Message, bool Shout) { if (Client != null) { if (Client.GetHabbo().Rank < 5) { if (GetRoom().RoomMuted) { return; } } } Unidle(); Users.Habbo clientUser = GetClient().GetHabbo(); if (clientUser.Muted) { GetClient().SendNotif("You are muted."); return; } if (Message.StartsWith(":")) { string[] parsedCommand = Message.Split(' '); if (ChatCommandRegister.IsChatCommand(parsedCommand[0].ToLower().Substring(1))) { try { ChatCommandHandler handler = new ChatCommandHandler(Message.Split(' '), Client); if (handler.WasExecuted()) { //Logging.LogMessage(string.Format("User {0} issued command {1}", GetUsername(), Message)); if (Client.GetHabbo().Rank > 5) { FirewindEnvironment.GetGame().GetModerationTool().LogStaffEntry(Client.GetHabbo().Username, string.Empty, "Chat command", string.Format("Issued chat command {0}", Message)); } return; } } catch (Exception x) { Logging.LogException("In-game command error: " + x.ToString()); } } } uint rank = 1; Message = LanguageLocale.FilterSwearwords(Message); if (Client != null && Client.GetHabbo() != null) { rank = Client.GetHabbo().Rank; } TimeSpan SinceLastMessage = DateTime.Now - clientUser.spamFloodTime; if (SinceLastMessage.TotalSeconds > clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { FloodCount = 0; clientUser.spamProtectionBol = false; clientUser.spamProtectionAbuse = 0; } else { if (SinceLastMessage.TotalSeconds > 4) { FloodCount = 0; } } if (SinceLastMessage.TotalSeconds < clientUser.spamProtectionTime && clientUser.spamProtectionBol == true) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); int timeToWait = clientUser.spamProtectionTime - SinceLastMessage.Seconds; Packet.AppendInt32(timeToWait); //Blocked for X sec GetClient().SendMessage(Packet); if (FirewindEnvironment.spamBans == true) { clientUser.spamProtectionAbuse++; GameClient toBan; toBan = FirewindEnvironment.GetGame().GetClientManager().GetClientByUsername(Client.GetHabbo().Username); if (clientUser.spamProtectionAbuse >= FirewindEnvironment.spamBans_limit) { FirewindEnvironment.GetGame().GetBanManager().BanUser(toBan, "SPAM*ABUSE", 800, LanguageLocale.GetValue("flood.banmessage"), false); } else { toBan.SendNotif(LanguageLocale.GetValue("flood.pleasewait").Replace("%secs%", Convert.ToString(timeToWait))); } } return; } if (SinceLastMessage.TotalSeconds < 4 && FloodCount > 5 && rank < 5) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); clientUser.spamProtectionCount += 1; if (clientUser.spamProtectionCount % 2 == 0) { clientUser.spamProtectionTime = (10 * clientUser.spamProtectionCount); } else { clientUser.spamProtectionTime = 10 * (clientUser.spamProtectionCount - 1); } clientUser.spamProtectionBol = true; Packet.AppendInt32(clientUser.spamProtectionTime - SinceLastMessage.Seconds); //Blocked for X sec GetClient().SendMessage(Packet); return; } clientUser.spamFloodTime = DateTime.Now; FloodCount++; FirewindEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Client, HabboHotel.Quests.QuestType.SOCIAL_CHAT); GetClient().GetHabbo().GetChatMessageManager().AddMessage(ChatMessageFactory.CreateMessage(Message, this.GetClient(), this.GetRoom())); base.Chat(Message, Shout); }
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 }