/// <summary> /// Serializes the theGroup information. /// </summary> /// <param name="group">The theGroup.</param> /// <param name="response">The response.</param> /// <param name="session">The session.</param> /// <param name="room">The room.</param> /// <param name="newWindow">if set to <c>true</c> [new window].</param> internal void SerializeGroupInfo(Group group, ServerMessage response, GameClient session, Room room, bool newWindow = false) { if (room == null || group == null) { return; } DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime dateTime2 = dateTime.AddSeconds(group.CreateTime); response.Init(LibraryParser.OutgoingRequest("GroupDataMessageComposer")); response.AppendInteger(group.Id); response.AppendBool(true); response.AppendInteger(group.State); response.AppendString(group.Name); response.AppendString(group.Description); response.AppendString(group.Badge); response.AppendInteger(group.RoomId); response.AppendString(Yupi.GetGame().GetRoomManager().GenerateRoomData(@group.RoomId) == null ? "No room found.." : Yupi.GetGame().GetRoomManager().GenerateRoomData(group.RoomId).Name); response.AppendInteger(@group.CreatorId == session.GetHabbo().Id ? 3 : (group.Requests.ContainsKey(session.GetHabbo().Id) ? 2 : (group.Members.ContainsKey(session.GetHabbo().Id) ? 1 : 0))); response.AppendInteger(group.Members.Count); response.AppendBool(session.GetHabbo().FavouriteGroup == group.Id); response.AppendString($"{dateTime2.Day.ToString("00")}-{dateTime2.Month.ToString("00")}-{dateTime2.Year}"); response.AppendBool(group.CreatorId == session.GetHabbo().Id); response.AppendBool(group.Admins.ContainsKey(session.GetHabbo().Id)); response.AppendString(Yupi.GetHabboById(@group.CreatorId) == null ? string.Empty : Yupi.GetHabboById(group.CreatorId).UserName); response.AppendBool(newWindow); response.AppendBool(group.AdminOnlyDeco == 0u); response.AppendInteger(group.Requests.Count); response.AppendBool(group.Forum.Id != 0); room.SendMessage(response); }
/// <summary> /// Destroys the friendship. /// </summary> /// <param name="friendId">The friend identifier.</param> internal void DestroyFriendship(uint friendId) { Habbo habbo = GetClient().GetHabbo(); Habbo habboFriend = Yupi.GetHabboById(friendId); if (habbo != null && habboFriend != null) { using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) { queryReactor.RunFastQuery(string.Concat("DELETE FROM messenger_friendships WHERE (user_one_id = ", habbo.Id, " AND user_two_id = ", habboFriend.Id, ")")); queryReactor.RunFastQuery(string.Concat("SELECT id FROM users_relationships WHERE user_id = ", habbo.Id, " AND target = ", habboFriend.Id, " LIMIT 1")); object integerResultUser = queryReactor.GetInteger(); int idUser; int.TryParse(integerResultUser.ToString(), out idUser); if (idUser > 0 && habbo.Relationships.ContainsKey(idUser)) { queryReactor.RunFastQuery(string.Concat("DELETE FROM users_relationships WHERE (user_id = ", habbo.Id, " AND target = ", habboFriend.Id, ")")); if (habbo.Relationships.ContainsKey(idUser)) { habbo.Relationships.Remove(idUser); } } queryReactor.RunFastQuery(string.Concat("DELETE FROM messenger_friendships WHERE (user_one_id = ", habboFriend.Id, " AND user_two_id = ", habbo.Id, ")")); queryReactor.RunFastQuery(string.Concat("SELECT id FROM users_relationships WHERE user_id = ", habboFriend.Id, " AND target = ", habbo.Id, " LIMIT 1")); object integerResultFriend = queryReactor.GetInteger(); int idFriend; int.TryParse(integerResultFriend.ToString(), out idFriend); if (idFriend > 0 && habboFriend.Relationships.ContainsKey(idFriend)) { queryReactor.RunFastQuery(string.Concat("DELETE FROM users_relationships WHERE (user_id = ", habboFriend.Id, " AND target = ", habbo.Id, ")")); if (habboFriend.Relationships.ContainsKey(idFriend)) { habboFriend.Relationships.Remove(idFriend); } } } OnDestroyFriendship(habboFriend.Id); habboFriend.GetMessenger().OnDestroyFriendship(habbo.Id); } }
internal void Serialize(ref ServerMessage message) { Habbo habbo = Yupi.GetHabboById(UserId); message.AppendInteger(Yupi.DifferenceInMilliSeconds(TimeStamp, DateTime.Now)); message.AppendInteger(UserId); message.AppendString(habbo == null ? "*User not found*" : habbo.UserName); message.AppendString(Message); message.AppendBool(GlobalMessage); }
/// <summary> /// Picks the specified p moderator identifier. /// </summary> /// <param name="pModeratorId">The p moderator identifier.</param> /// <param name="updateInDb">if set to <c>true</c> [update in database].</param> internal void Pick(uint pModeratorId, bool updateInDb) { Status = TicketStatus.Picked; ModeratorId = pModeratorId; _modName = Yupi.GetHabboById(pModeratorId).UserName; if (!updateInDb) { return; } using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) queryReactor.RunFastQuery( string.Concat("UPDATE moderation_tickets SET status = 'picked', moderator_id = ", pModeratorId, ", timestamp = '", Yupi.GetUnixTimeStamp(), "' WHERE id = ", TicketId)); }
internal static void MatchingPollResults(GameClient client, Poll poll) { Room room = client.GetHabbo().CurrentRoom; if (poll == null || poll.Type != PollType.Matching || room == null) { return; } HashSet <RoomUser> users = room.GetRoomUserManager().GetRoomUsers(); for (int i = 0; i < 10; i++) { Thread.Sleep(1000); foreach (RoomUser roomUser in users) { Habbo user = Yupi.GetHabboById(roomUser.UserId); if (user.AnsweredPool) { ServerMessage result = new ServerMessage(LibraryParser.OutgoingRequest("MatchingPollResultMessageComposer")); result.AppendInteger(poll.Id); result.AppendInteger(2); result.AppendString("0"); result.AppendInteger(poll.AnswersNegative); result.AppendString("1"); result.AppendInteger(poll.AnswersPositive); client.SendMessage(result); } } } foreach (RoomUser roomUser in users) { Yupi.GetHabboById(roomUser.UserId).AnsweredPool = false; } }
/// <summary> /// Closes the ticket. /// </summary> /// <param name="session">The session.</param> /// <param name="ticketId">The ticket identifier.</param> /// <param name="result">The result.</param> internal void CloseTicket(GameClient session, uint ticketId, int result) { SupportTicket ticket = GetTicket(ticketId); if (ticket == null || ticket.Status != TicketStatus.Picked || ticket.ModeratorId != session.GetHabbo().Id) { return; } Habbo senderUser = Yupi.GetHabboById(ticket.SenderId); if (senderUser == null) { return; } uint statusCode; TicketStatus newStatus; switch (result) { case 1: statusCode = 1; newStatus = TicketStatus.Invalid; break; case 2: statusCode = 2; newStatus = TicketStatus.Abusive; break; default: statusCode = 0; newStatus = TicketStatus.Resolved; break; } if (statusCode == 2) { using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) { AbusiveCooldown.Add(ticket.SenderId, Yupi.GetUnixTimeStamp() + 600); queryReactor.RunFastQuery( $"UPDATE users_info SET cfhs_abusive = cfhs_abusive + 1 WHERE user_id = {ticket.SenderId}"); } } GameClient senderClient = Yupi.GetGame().GetClientManager().GetClientByUserId(senderUser.Id); if (senderClient != null) { foreach ( SupportTicket current2 in Tickets.FindAll( current => current.ReportedId == ticket.ReportedId && current.Status == TicketStatus.Picked) ) { current2.Delete(true); SendTicketToModerators(current2); current2.Close(newStatus, true); } senderClient.GetMessageHandler() .GetResponse() .Init(LibraryParser.OutgoingRequest("ModerationToolUpdateIssueMessageComposer")); senderClient.GetMessageHandler().GetResponse().AppendInteger(1); senderClient.GetMessageHandler().GetResponse().AppendInteger(ticket.TicketId); senderClient.GetMessageHandler().GetResponse().AppendInteger(ticket.ModeratorId); senderClient.GetMessageHandler() .GetResponse() .AppendString(Yupi.GetHabboById(ticket.ModeratorId) != null ? Yupi.GetHabboById(ticket.ModeratorId).UserName : "******"); senderClient.GetMessageHandler().GetResponse().AppendBool(false); senderClient.GetMessageHandler().GetResponse().AppendInteger(0); senderClient.GetMessageHandler() .GetResponse() .Init(LibraryParser.OutgoingRequest("ModerationTicketResponseMessageComposer")); senderClient.GetMessageHandler().GetResponse().AppendInteger(statusCode); senderClient.GetMessageHandler().SendResponse(); } else { foreach ( SupportTicket current2 in Tickets.FindAll( current => current.ReportedId == ticket.ReportedId && current.Status == TicketStatus.Picked) ) { current2.Delete(true); SendTicketToModerators(current2); current2.Close(newStatus, true); } } using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor()) queryreactor2.RunFastQuery( $"UPDATE users_stats SET tickets_answered = tickets_answered+1 WHERE id={session.GetHabbo().Id} LIMIT 1"); }
/// <summary> /// Serializes the user chatlog. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage SerializeUserChatlog(uint userId) { ServerMessage result; using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery( $"SELECT DISTINCT room_id FROM users_chatlogs WHERE user_id = '{userId}' ORDER BY timestamp DESC LIMIT 4"); DataTable table = queryReactor.GetTable(); ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserChatlogMessageComposer")); serverMessage.AppendInteger(userId); serverMessage.AppendString(Yupi.GetGame().GetClientManager().GetNameById(userId)); if (table != null) { serverMessage.AppendInteger(table.Rows.Count); IEnumerator enumerator = table.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { DataRow dataRow = (DataRow)enumerator.Current; queryReactor.SetQuery( $"SELECT user_id,timestamp,message FROM users_chatlogs WHERE room_id = {dataRow["room_id"]} AND user_id = {userId} ORDER BY timestamp DESC LIMIT 30"); DataTable table2 = queryReactor.GetTable(); RoomData roomData = Yupi.GetGame().GetRoomManager().GenerateRoomData((uint)dataRow["room_id"]); if (table2 != null) { serverMessage.AppendByte(1); serverMessage.AppendShort(2); serverMessage.AppendString("roomName"); serverMessage.AppendByte(2); serverMessage.AppendString(roomData == null ? "This room was deleted" : roomData.Name); serverMessage.AppendString("roomId"); serverMessage.AppendByte(1); serverMessage.AppendInteger((uint)dataRow["room_id"]); serverMessage.AppendShort(table2.Rows.Count); IEnumerator enumerator2 = table2.Rows.GetEnumerator(); try { while (enumerator2.MoveNext()) { DataRow dataRow2 = (DataRow)enumerator2.Current; Habbo habboForId = Yupi.GetHabboById((uint)dataRow2["user_id"]); Yupi.UnixToDateTime((double)dataRow2["timestamp"]); if (habboForId == null) { return(null); } serverMessage.AppendInteger( (int)(Yupi.GetUnixTimeStamp() - (double)dataRow2["timestamp"])); serverMessage.AppendInteger(habboForId.Id); serverMessage.AppendString(habboForId.UserName); serverMessage.AppendString(dataRow2["message"].ToString()); serverMessage.AppendBool(false); } continue; } finally { IDisposable disposable = enumerator2 as IDisposable; disposable?.Dispose(); } } serverMessage.AppendByte(1); serverMessage.AppendShort(0); serverMessage.AppendShort(0); } result = serverMessage; return(result); } finally { IDisposable disposable2 = enumerator as IDisposable; disposable2?.Dispose(); } } serverMessage.AppendInteger(0); result = serverMessage; } return(result); }