internal void SendInstantMessenger() { if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null) { return; } var userId = Request.PopWiredInt32(); var message = OtanixEnvironment.FilterInjectionChars(Request.PopFixedString()); #region Mute if (Session.GetHabbo().Rank < 4) // Si no es un staff comprobamos si está muteado. { int timeToEndGlobalMute = OtanixEnvironment.GetGame().GetMuteManager().HasMuteExpired(Session.GetHabbo().Id); if (timeToEndGlobalMute > 0) { return; } } #endregion #region Flood if (!Session.GetHabbo().HasFuse("ignore_flood_filter")) { TimeSpan SinceLastMessage = DateTime.Now - Session.GetHabbo().spamFloodTime; if (SinceLastMessage.Seconds > 3) { FloodCount = 0; } else if (FloodCount > 5) { 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, "<Consola Privado>")) { return; } } #endregion bool isGroup = userId < 0; if (isGroup) { Session.GetHabbo().GetMessenger().SendInstantMessageGroup(userId, message); } else { Session.GetHabbo().GetMessenger().SendInstantMessage(Convert.ToUInt32(userId), message); } }
/// <summary> /// Chats the specified session. /// </summary> /// <param name="session">The session.</param> /// <param name="msg">The MSG.</param> /// <param name="shout">if set to <c>true</c> [shout].</param> /// <param name="count">The count.</param> /// <param name="textColor">Color of the text.</param> internal void Chat(GameClient session, string msg, bool shout, int count, int textColor = 0) { if (IsPet || IsBot) { if (!IsPet) { textColor = 2; } ServerMessage botChatmsg = new ServerMessage(); botChatmsg.Init(shout ? LibraryParser.OutgoingRequest("ShoutMessageComposer") : LibraryParser.OutgoingRequest("ChatMessageComposer")); botChatmsg.AppendInteger(VirtualId); botChatmsg.AppendString(msg); botChatmsg.AppendInteger(0); botChatmsg.AppendInteger(textColor); botChatmsg.AppendInteger(0); botChatmsg.AppendInteger(count); GetRoom().SendMessage(botChatmsg); return; } if (msg.Length > 100) // si el mensaje es mayor que la máxima longitud (scripter) { return; } if (!ServerSecurityChatFilter.CanTalk(session, msg)) { return; } if (session == null || session.GetHabbo() == null) { return; } BlackWord word; if (!(msg.StartsWith(":deleteblackword ") && session.GetHabbo().Rank > 4) && BlackWordsManager.Check(msg, BlackWordType.Hotel, out word)) { BlackWordTypeSettings settings = word.TypeSettings; //session.HandlePublicist(word.Word, msg, "CHAT", settings); if (settings.ShowMessage) { session.SendWhisper("A mensagem contém a palavra: " + word.Word + " que não é permitida, você poderá ser banido!"); return; } } if (!IsBot && IsFlooded && FloodExpiryTime <= Yupi.GetUnixTimeStamp()) { IsFlooded = false; } else if (!IsBot && IsFlooded) { return; // ciao flooders! } if (session.GetHabbo().Rank < 4 && GetRoom().CheckMute(session)) { return; } UnIdle(); if (!IsPet && !IsBot) { if (msg.StartsWith(":") && CommandsManager.TryExecute(msg.Substring(1), session)) { return; } Habbo habbo = GetClient().GetHabbo(); if (GetRoom().GetWiredHandler().ExecuteWired(Interaction.TriggerOnUserSay, this, msg)) { return; } GetRoom().AddChatlog(session.GetHabbo().Id, msg, true); uint rank = 1; if (session.GetHabbo() != null) { rank = session.GetHabbo().Rank; } msg = GetRoom() .WordFilter .Aggregate(msg, (current1, current) => Regex.Replace(current1, current, "bobba", RegexOptions.IgnoreCase)); if (rank < 4) { TimeSpan span = DateTime.Now - habbo.SpamFloodTime; if ((span.TotalSeconds > habbo.SpamProtectionTime) && habbo.SpamProtectionBol) { _floodCount = 0; habbo.SpamProtectionBol = false; habbo.SpamProtectionAbuse = 0; } else if (span.TotalSeconds > 4.0) { _floodCount = 0; } ServerMessage message; if ((span.TotalSeconds < habbo.SpamProtectionTime) && habbo.SpamProtectionBol) { message = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer")); int i = habbo.SpamProtectionTime - span.Seconds; message.AppendInteger(i); IsFlooded = true; FloodExpiryTime = Yupi.GetUnixTimeStamp() + i; GetClient().SendMessage(message); return; } if ((span.TotalSeconds < 4.0) && (_floodCount > 5) && (rank < 5)) { message = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer")); habbo.SpamProtectionCount++; if (habbo.SpamProtectionCount % 2 == 0) { habbo.SpamProtectionTime = 10 * habbo.SpamProtectionCount; } else { habbo.SpamProtectionTime = 10 * (habbo.SpamProtectionCount - 1); } habbo.SpamProtectionBol = true; int j = habbo.SpamProtectionTime - span.Seconds; message.AppendInteger(j); IsFlooded = true; FloodExpiryTime = Yupi.GetUnixTimeStamp() + j; GetClient().SendMessage(message); return; } habbo.SpamFloodTime = DateTime.Now; _floodCount++; } if (habbo.Preferences.ChatColor != textColor) { habbo.Preferences.ChatColor = textColor; habbo.Preferences.Save(); } } else if (!IsPet) { textColor = 2; } ServerMessage chatMsg = new ServerMessage(); chatMsg.Init(shout ? LibraryParser.OutgoingRequest("ShoutMessageComposer") : LibraryParser.OutgoingRequest("ChatMessageComposer")); chatMsg.AppendInteger(VirtualId); chatMsg.AppendString(msg); chatMsg.AppendInteger(ChatEmotions.GetEmotionsForText(msg)); chatMsg.AppendInteger(textColor); chatMsg.AppendInteger(0); // links count (foreach string string bool) chatMsg.AppendInteger(count); GetRoom().BroadcastChatMessage(chatMsg, this, session.GetHabbo().Id); GetRoom().OnUserSay(this, msg, shout); GetRoom().GetRoomUserManager().TurnHeads(X, Y, HabboId); }
/// <summary> /// Sends the instant message. /// </summary> /// <param name="toId">To identifier.</param> /// <param name="message">The message.</param> internal void SendInstantMessage(uint toId, string message) { if (string.IsNullOrEmpty(message)) { return; } if (toId != 0) { BlackWord word; if (BlackWordsManager.Check(message, BlackWordType.Hotel, out word)) { BlackWordTypeSettings settings = word.TypeSettings; GameClient thisClient = GetClient(); if (thisClient != null) { thisClient.HandlePublicist(word.Word, message, "MESSENGER", settings); if (settings.ShowMessage) { thisClient.SendModeratorMessage("A mensagem contém a palavra: " + word.Word + " que não é permitida, você poderá ser banido!"); return; } } } } if (!FriendshipExists(toId)) { DeliverInstantMessageError(6, toId); return; } if (toId == 0) // Staff Chat { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ConsoleChatMessageComposer")); serverMessage.AppendInteger(0); //userid serverMessage.AppendString(GetClient().GetHabbo().UserName + " : " + message); serverMessage.AppendInteger(0); if (GetClient().GetHabbo().Rank >= Yupi.StaffAlertMinRank) { Yupi.GetGame().GetClientManager().StaffAlert(serverMessage, GetClient().GetHabbo().Id); } else if (GetClient().GetHabbo().Rank >= Convert.ToUInt32(Yupi.GetDbConfig().DbData["ambassador.minrank"])) { Yupi.GetGame().GetClientManager().AmbassadorAlert(serverMessage, GetClient().GetHabbo().Id); } } else { GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(toId); if (clientByUserId?.GetHabbo().GetMessenger() == null) { if (!Yupi.OfflineMessages.ContainsKey(toId)) { Yupi.OfflineMessages.Add(toId, new List <OfflineMessage>()); } Yupi.OfflineMessages[toId].Add(new OfflineMessage(GetClient().GetHabbo().Id, message, Yupi.GetUnixTimeStamp())); OfflineMessage.SaveMessage(Yupi.GetDatabaseManager().GetQueryReactor(), toId, GetClient().GetHabbo().Id, message); return; } if (GetClient().GetHabbo().Muted) { DeliverInstantMessageError(4, toId); return; } if (clientByUserId.GetHabbo().Muted) { DeliverInstantMessageError(3, toId); } if (message == string.Empty) { return; } clientByUserId.GetHabbo().GetMessenger().DeliverInstantMessage(message, _userId); } }
internal static void HandleSave(GameClient Session, uint itemID, Room room, ClientMessage clientMessage) { if (room == null || room.GetRoomItemHandler() == null) { return; } var item = room.GetRoomItemHandler().GetItem(itemID); if (item == null) { return; } if (item.wiredHandler != null) { item.wiredHandler.Dispose(); item.wiredHandler = null; } InteractorGenericSwitch.DoAnimation(item); var type = item.GetBaseItem().InteractionType; switch (type) { #region Causantes case InteractionType.triggeronusersay: { var junk = clientMessage.PopWiredInt32(); var isOnlyOwner = (clientMessage.PopWiredInt32() == 1); var message = clientMessage.PopFixedString(); IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), isOnlyOwner, message, room); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerwalkonfurni: { var junk = clientMessage.PopWiredInt32(); var message = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerwalkofffurni: { var junk = clientMessage.PopWiredInt32(); var message = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggergameend: { IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager()); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggergamestart: { IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager()); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggertimer: { var junk = clientMessage.PopWiredInt32(); var cycles = clientMessage.PopWiredInt32(); IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager()); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerrepeater: { var junk = clientMessage.PopWiredInt32(); var cycleTimes = clientMessage.PopWiredInt32(); IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerroomenter: { var junk = clientMessage.PopWiredInt32(); var users = clientMessage.PopFixedString(); IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerscoreachieved: { var junk = clientMessage.PopWiredInt32(); var score = clientMessage.PopWiredInt32(); IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager()); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerstatechanged: { var junk = clientMessage.PopWiredInt32(); var junk3 = clientMessage.PopWiredBoolean(); var junk2 = clientMessage.PopWiredBoolean(); int furniAmount; var items = GetItems(clientMessage, room, out furniAmount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, items); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggercollision: { IWiredTrigger handler = new Collision(item, room.GetWiredHandler(), room.GetRoomUserManager()); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerlongperiodic: { var junk = clientMessage.PopWiredInt32(); var cycleTimes = clientMessage.PopWiredInt32(); IWiredTrigger handler = new LongRepeater(room.GetWiredHandler(), item, cycleTimes); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerbotreachedavtr: { var junk = clientMessage.PopWiredInt32(); var botname = clientMessage.PopFixedString(); IWiredTrigger handler = new BotAlcanzaUsuario(item, room.GetWiredHandler(), room.GetRoomUserManager(), botname); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.triggerbotreachedstf: { var junk = clientMessage.PopWiredInt32(); var botname = clientMessage.PopFixedString(); int furniAmount; var items = GetItems(clientMessage, room, out furniAmount); IWiredTrigger handler = new BotAlcanzaFurni(item, room.GetWiredHandler(), room.GetRoomUserManager(), items, botname); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } #endregion #region Efectos case InteractionType.actiongivescore: { var junk = clientMessage.PopWiredInt32(); var points = clientMessage.PopWiredInt32(); var games = clientMessage.PopWiredInt32(); IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionposreset: { var junk = clientMessage.PopWiredInt32(); var state = clientMessage.PopWiredInt32(); var direction = clientMessage.PopWiredInt32(); var position = clientMessage.PopWiredInt32(); var junk3 = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new PositionReset(items, delay, state + "," + direction + "," + position, new Dictionary <uint, OriginalItemLocation>(), room.GetRoomItemHandler(), room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionresettimer: { var junk = clientMessage.PopWiredInt32(); var junk3 = clientMessage.PopWiredBoolean(); var junk2 = clientMessage.PopWiredBoolean(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionshowmessage: { var junk = clientMessage.PopWiredInt32(); var message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString()); if (BlackWordsManager.Check(message, BlackWordType.Hotel, Session, "<WiredMensaje>")) { message = "Mensaje bloqueado por el filtro bobba."; } IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionhandiitemcustom: { var junk = clientMessage.PopWiredInt32(); var message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString()); int valorInteiro; bool inteiroCustom = int.TryParse(message, out valorInteiro); if (inteiroCustom) { IWiredTrigger action = new HandiCustom(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); } else { RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números."); } break; } case InteractionType.actioneffectcustom: { var junk = clientMessage.PopWiredInt32(); var message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString()); int valorInteiro; bool inteiroCustom = int.TryParse(message, out valorInteiro); if (inteiroCustom) { IWiredTrigger action = new EffectCustom(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); } else { RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números."); } break; } case InteractionType.actiondiamantescustom: { var junk = clientMessage.PopWiredInt32(); var message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString()); int valorInteiro; bool inteiroCustom = int.TryParse(message, out valorInteiro); if (inteiroCustom) { IWiredTrigger action = new DiamantesCustom(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } else { RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números e hífen (-)."); } break; } case InteractionType.actiondancecustom: { var junk = clientMessage.PopWiredInt32(); var message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString()); int valorInteiro; bool inteiroCustom = int.TryParse(message, out valorInteiro); if (inteiroCustom) { IWiredTrigger action = new DanceCustom(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); } else { RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números."); } break; } case InteractionType.actionfastwalk: { var junk = clientMessage.PopWiredInt32(); var cycleTimes = clientMessage.PopWiredInt32(); IWiredTrigger handler = new FastWalkCustom(room.GetWiredHandler(), item, cycleTimes); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.actionfreezecustom: { var junk = clientMessage.PopWiredInt32(); var cycleTimes = clientMessage.PopWiredInt32(); IWiredTrigger handler = new FreezeCustom(room.GetWiredHandler(), item, cycleTimes); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.actionteleportto: { var junk = clientMessage.PopWiredInt32(); var junk2 = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actiontogglestate: { var junk = clientMessage.PopWiredInt32(); var message = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new ToggleItemState(room.GetWiredHandler(), items, delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionmoverotate: { var junk = clientMessage.PopWiredInt32(); var movement = (MovementState)clientMessage.PopWiredInt32(); var rotation = (RotationState)clientMessage.PopWiredInt32(); var junk3 = clientMessage.PopWiredBoolean(); var junk2 = clientMessage.PopWiredBoolean(); var items = GetItems(clientMessage, room, out int furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger handler = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), item); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.actiongivereward: { if (!Session.GetHabbo().HasFuse("fuse_wired_rewards")) { Session.SendNotif("No tienes permitido usar este Wired."); break; } var junk = clientMessage.PopWiredInt32(); var often = clientMessage.PopWiredInt32(); var unique = clientMessage.PopWiredInt32(); var limite = clientMessage.PopWiredInt32(); var nInt = clientMessage.PopWiredInt32(); var extrainfo = clientMessage.PopFixedString(); #region Posible Bug? if (extrainfo.Contains(";")) { foreach (var s in extrainfo.Split(';')) { if (s.StartsWith("1")) { string value = s.Split(',')[1]; if (!value.StartsWith("diamonds:") && !value.StartsWith("alert:")) { try { int.Parse(value); } catch { Session.SendNotif("Has intentado poner un item inválido. Recuerda que debes poner el item_id."); return; } } } } } else { if (extrainfo.StartsWith("1")) { string value = extrainfo.Split(',')[1]; if (!value.StartsWith("diamonds:") && !value.StartsWith("alert:")) { try { int.Parse(value); } catch { Session.SendNotif("Has intentado poner un item inválido. Recuerda que debes poner el item_id."); return; } } } } #endregion OtanixEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, "", "WiredReward", "Wired Id: " + item.Id + ", RoomId: " + item.RoomId + "."); IWiredTrigger action = new GiveReward(extrainfo, limite, often, unique, nInt, item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionchase: { var junk = clientMessage.PopWiredInt32(); var junk2 = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new Chase(items, delay, room, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionkickuser: { var junk = clientMessage.PopWiredInt32(); var message = clientMessage.PopFixedString(); IWiredTrigger action = new KickUser(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionescape: { var junk = clientMessage.PopWiredInt32(); var junk2 = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new Escape(items, delay, room, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionjointoteam: { var junk = clientMessage.PopWiredInt32(); var teamid = (Team)clientMessage.PopWiredInt32(); IWiredTrigger action = new JoinToTeam(room.GetWiredHandler(), item, teamid); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionleaveteam: { IWiredTrigger action = new LeaveTeam(room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actiongiveteamscore: { var junk = clientMessage.PopWiredInt32(); var points = clientMessage.PopWiredInt32(); var games = clientMessage.PopWiredInt32(); var teamid = (Team)clientMessage.PopWiredInt32(); IWiredTrigger action = new GiveTeamScore(games, points, teamid, room.GetGameManager(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actioncallstacks: { var junk = clientMessage.PopWiredInt32(); var junk2 = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new CallStacks(items, room, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionmovetodir: { var junk = clientMessage.PopWiredInt32(); var movement = (MovementDirection)clientMessage.PopWiredInt32(); var rotation = (WhenMovementBlock)clientMessage.PopWiredInt32(); var junk3 = clientMessage.PopWiredBoolean(); var junk2 = clientMessage.PopWiredBoolean(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger handler = new MoveToDir(items, movement, rotation, room, room.GetWiredHandler(), item); HandleTriggerSave(handler, room.GetWiredHandler(), room, item); break; } case InteractionType.actionbotmove: { var junk = clientMessage.PopWiredInt32(); var botName = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredUInt(); IWiredTrigger action = new BotMove(item.Id, room, room.GetWiredHandler(), botName, items, delay); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionbotwhisper: { var junk = clientMessage.PopWiredInt32(); bool talkorwhisper = clientMessage.PopWiredInt32() == 1; string message = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); IWiredTrigger action = new BotTalkToUser(item.Id, room, room.GetWiredHandler(), message, talkorwhisper); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionbotteleport: { var junk = clientMessage.PopWiredInt32(); var botName = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredUInt(); IWiredTrigger action = new BotTeleport(item.Id, room, room.GetWiredHandler(), botName, items, delay); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionbotclothes: { int junk = clientMessage.PopWiredInt32(); string message = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredUInt(); IWiredTrigger action = new BotChangeLook(item.Id, room, room.GetWiredHandler(), message, delay); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionbottalk: { var junk = clientMessage.PopWiredInt32(); bool talkorshout = clientMessage.PopWiredInt32() == 1; string message = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredUInt(); IWiredTrigger action = new BotTalkToAll(item.Id, room, room.GetWiredHandler(), message, talkorshout, delay); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionbothanditem: { var junk = clientMessage.PopWiredInt32(); int handitem = clientMessage.PopWiredInt32(); string botname = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredUInt(); IWiredTrigger action = new BotGiveHandItem(item.Id, room, room.GetWiredHandler(), botname, handitem, delay); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionbotfollowavt: { var junk = clientMessage.PopWiredInt32(); bool followorstop = clientMessage.PopWiredInt32() == 1; string botname = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredUInt(); IWiredTrigger action = new BotFollowUser(item.Id, room, room.GetWiredHandler(), botname, followorstop, delay); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionmutetriggerer: { var junk = clientMessage.PopWiredInt32(); uint mutetimer = clientMessage.PopWiredUInt(); string botname = clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredUInt(); IWiredTrigger action = new MuteTriggerer(room.GetWiredHandler(), botname, mutetimer, delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } case InteractionType.actionmovetofurni: { var junk = clientMessage.PopWiredInt32(); int direction = clientMessage.PopWiredInt32(); int length = clientMessage.PopWiredInt32(); clientMessage.PopFixedString(); int furniCount; var items = GetItems(clientMessage, room, out furniCount); var delay = clientMessage.PopWiredInt32(); IWiredTrigger action = new MoveToFurni(room.GetWiredHandler(), items, length, direction, delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, item); break; } #endregion } Session.SendMessage(new ServerMessage(Outgoing.SaveWired)); }
internal void SendInstantInvite() { var count = Request.PopWiredInt32(); var UserIds = new List <uint>(); for (var i = 0; i < count; i++) { UserIds.Add(Request.PopWiredUInt()); } var message = OtanixEnvironment.FilterInjectionChars(Request.PopFixedString(), true); #region Mute if (Session.GetHabbo().Rank < 4) // Si no es un staff comprobamos si está muteado. { int timeToEndGlobalMute = OtanixEnvironment.GetGame().GetMuteManager().HasMuteExpired(Session.GetHabbo().Id); if (timeToEndGlobalMute > 0) { return; } } #endregion #region Flood if (!Session.GetHabbo().HasFuse("ignore_flood_filter")) { TimeSpan SinceLastMessage = DateTime.Now - Session.GetHabbo().spamFloodTime; if (SinceLastMessage.Seconds > 3) { FloodCount = 0; } else if (FloodCount > 5) { 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, "<Consola Spam>")) { return; } } #endregion ServerMessage Message = new ServerMessage(Outgoing.InstantInvite); Message.AppendUInt(Session.GetHabbo().Id); Message.AppendString(message); foreach (var Id in UserIds) { if (!Session.GetHabbo().GetMessenger().FriendshipExists(Id)) { continue; } var Client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(Id); if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().IgnoreRoomInvitations) { return; } Client.SendMessage(Message); } }
internal void HandleGroup(ClientMessage Message, GameClient Session) { var Group = new GroupItem { Name = OtanixEnvironment.FilterInjectionChars(Message.PopFixedString()), Description = OtanixEnvironment.FilterInjectionChars(Message.PopFixedString()), RoomId = Message.PopWiredUInt(), RightsType = 1 }; if (BlackWordsManager.Check(Group.Name, BlackWordType.Insult, Session, "<Nombre de Grupo>")) { Group.Name = "Mensaje bloqueado por el filtro bobba."; } if (BlackWordsManager.Check(Group.Description, BlackWordType.Insult, Session, "<Descripción de Grupo>")) { Group.Description = "Mensaje bloqueado por el filtro bobba."; } var rData = OtanixEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)Group.RoomId); if (rData.GroupId != 0) { Session.SendNotif("Esta sala ya tiene creado un grupo"); return; } if (EmuSettings.HOTEL_LUCRATIVO && (Session.GetHabbo().Moedas < 10)) { Session.SendNotif("Moedas insuficientes"); return; } if (rData.OwnerId != Session.GetHabbo().Id) { Session.SendNotif("¡Oops, ha sucedido un error has intentado crear un grupo en una sala que no te pertenece!"); return; } Session.GetHabbo().Moedas -= 10; Group.CustomColor1 = Message.PopWiredInt32(); Group.CustomColor2 = Message.PopWiredInt32(); var ArrayItem = (Message.PopWiredInt32() - 3) / 3; Group.GroupBase = Message.PopWiredInt32(); Group.GroupBaseColor = Message.PopWiredInt32(); Group.GroupBasePosition = Message.PopWiredInt32(); for (var k = 0; k < ArrayItem; k++) { if (k == 0) { Group.GroupItem1 = new int[] { Message.PopWiredInt32(), Message.PopWiredInt32(), Message.PopWiredInt32() } } ; else if (k == 1) { Group.GroupItem2 = new int[] { Message.PopWiredInt32(), Message.PopWiredInt32(), Message.PopWiredInt32() } } ; else if (k == 2) { Group.GroupItem3 = new int[] { Message.PopWiredInt32(), Message.PopWiredInt32(), Message.PopWiredInt32() } } ; else if (k == 3) { Group.GroupItem4 = new int[] { Message.PopWiredInt32(), Message.PopWiredInt32(), Message.PopWiredInt32() } } ; } Group.GroupImage = GenerateGuildImage(Group); Group.HtmlColor1 = GetHtmlColor(Group.CustomColor1, 1); Group.HtmlColor2 = GetHtmlColor(Group.CustomColor2, 2); Group.DateCreated = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; Group.OwnerId = Session.GetHabbo().Id; Group.OwnerName = Session.GetHabbo().Username; var ThisMonth = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[DateTime.Now.Month - 1].Substring(0, 3); ThisMonth = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(ThisMonth); var DateJoined = ThisMonth + " " + DateTime.Now.Day + ", " + DateTime.Now.Year; using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO groups (name, description, roomid, customcolor1, customcolor2, groupbase, groupbasecolor, groupbaseposition, groupitem1, groupitem2, groupitem3, groupitem4, groupimage, htmlcolor1, htmlcolor2, datecreated, ownerid, rightsType) VALUES (@name, @description, '" + Group.RoomId + "', '" + Group.CustomColor1 + "','" + Group.CustomColor2 + "','" + Group.GroupBase + "','" + Group.GroupBaseColor + "','" + Group.GroupBasePosition + "','" + GeneratePartData(Group.GroupItem1) + "', '" + GeneratePartData(Group.GroupItem2) + "', '" + GeneratePartData(Group.GroupItem3) + "', '" + GeneratePartData(Group.GroupItem4) + "', '" + Group.GroupImage + "','" + Group.HtmlColor1 + "','" + Group.HtmlColor2 + "','" + Group.DateCreated + "','" + Group.OwnerId + "','1')"); dbClient.addParameter("name", Group.Name); dbClient.addParameter("description", Group.Description); Group.Id = (uint)dbClient.insertQuery(); Session.GetHabbo().MyGroups.Add(Group.Id); if (Session.GetHabbo().FavoriteGroup == 0) { Session.GetHabbo().FavoriteGroup = Group.Id; } dbClient.runFastQuery("UPDATE rooms SET groupId = '" + Group.Id + "' WHERE id = '" + Group.RoomId + "'"); dbClient.setQuery("INSERT INTO groups_users VALUES (@groupid, @userid, '1', '0', @datejoined)"); dbClient.addParameter("groupid", Group.Id); dbClient.addParameter("userid", Session.GetHabbo().Id); dbClient.addParameter("datejoined", DateJoined); dbClient.runQuery(); } rData.GroupId = Group.Id; var SendItem = new ServerMessage(Outgoing.PurchaseOKMessageOfferData); SendItem.AppendInt32(6165); SendItem.AppendString("CREATE_GUILD"); SendItem.AppendBoolean(false); SendItem.AppendInt32(10); SendItem.AppendInt32(0); SendItem.AppendInt32(0); SendItem.AppendBoolean(true); SendItem.AppendInt32(0); SendItem.AppendInt32(2); SendItem.AppendBoolean(false); Session.SendMessage(SendItem); var SendOwnerId = new ServerMessage(Outgoing.SendOwnerId); SendOwnerId.AppendUInt(Session.GetHabbo().Id); Session.SendMessage(SendOwnerId); var GroupAndRoom = new ServerMessage(Outgoing.SendRoomAndGroup); GroupAndRoom.AppendUInt(Group.RoomId); GroupAndRoom.AppendUInt(Group.Id); Session.SendMessage(GroupAndRoom); var Room = OtanixEnvironment.GetGame().GetRoomManager().GetRoom((uint)Group.RoomId); if (Room != null) { var Update = new ServerMessage(Outgoing.UpdateRoom); Update.AppendUInt(Group.RoomId); Room.SendMessage(Update); var AddGuild = new ServerMessage(Outgoing.SendMyGroups); AddGuild.AppendInt32(Session.GetHabbo().MyGroups.Count); // Count of guilds foreach (var xGroupId in Session.GetHabbo().MyGroups) { var xGroup = OtanixEnvironment.GetGame().GetGroup().LoadGroup(xGroupId); if (xGroup == null) { Session.GetHabbo().MyGroups.Remove(xGroupId); return; } AddGuild.AppendUInt(xGroup.Id); AddGuild.AppendString(xGroup.Name); AddGuild.AppendString(xGroup.GroupImage); AddGuild.AppendString(xGroup.HtmlColor1); AddGuild.AppendString(xGroup.HtmlColor2); AddGuild.AppendBoolean((xGroup.Id == Session.GetHabbo().FavoriteGroup) ? true : false); AddGuild.AppendUInt(xGroup.OwnerId); AddGuild.AppendBoolean(false); // not used. } Session.SendMessage(AddGuild); if (Session.GetHabbo().FavoriteGroup == Group.Id) { var UpdateUserGroup = new ServerMessage(Outgoing.SendGroup); UpdateUserGroup.AppendInt32(1); UpdateUserGroup.AppendUInt(Group.Id); UpdateUserGroup.AppendString(Group.GroupImage); Room.SendMessage(UpdateUserGroup); if (Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id) != null) { var UpdateUserGroup2 = new ServerMessage(Outgoing.UpdateUserGroupRemoving); UpdateUserGroup2.AppendInt32(Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id).VirtualId); UpdateUserGroup2.AppendUInt(Group.Id); UpdateUserGroup2.AppendInt32(3); // state UpdateUserGroup2.AppendString(Group.Name); Room.SendMessage(UpdateUserGroup2); } } } }
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 }