/// <summary>
 /// Adds a user to a community blacklist.
 /// </summary>
 /// <param name="groupId">Community ID.</param>
 /// <param name="userId">User ID.</param>
 /// <param name="endDate">Date when the user will be removed from the blacklist.</param>
 /// <param name="reason">Reason for ban.</param>
 /// <param name="comment">Text of comment to ban.</param>
 /// <param name="commentVisible">True — text of comment will be visible to the user; False — text of comment will be invisible to the user(default)</param>
 /// <returns>Returns True if the user installed the application; otherwise returns False.</returns>
 public async Task <Response <bool> > BanUser(int groupId, int userId, DateTime?endDate,
                                              BanTypes reason = BanTypes.Other, string comment = null, bool commentVisible = false)
 => await Request <bool>("banUser", new MethodParams
 {
     { "group_id", groupId, true },
     { "user_id", userId, true },
     { "end_date", endDate?.ToUnixTimeStamp() },
     { "reason", (int)reason },
     { "comment", comment },
     { "comment_visible", commentVisible }
 });
 public BanListViewModel(BanList banList, IdTypes idTypes, BanTypes banTypes, Action<Action> synchronousInvoker)
     : base(synchronousInvoker)
 {
     BanList = banList;
     IdTypes = idTypes;
     BanTypes = banTypes;
     this.BanListItems =
         new ObservableCollection<BanListItemViewModel>(
             BanList.Select(x => new BanListItemViewModel(x, synchronousInvoker)));
     this.BanListItems.CollectionChanged += BanListItemsOnCollectionChanged;
 }
 public bool OnCreatingResponse(PacketSession session, Packet requestPacket, Packet responsePacket)
 {
     if (ValidateRequestPacket(requestPacket))
     {
         var idTypes = session.Server.IdTypes;
         var banTypes = new BanTypes();
         var itemCreated = false;
         var banListItem = new BanListItem
                               {
                                   IdType = idTypes.FirstOrDefault(x => x.Code == requestPacket.Words[1]),
                                   IdValue = requestPacket.Words[2],
                                   BanType = banTypes.FirstOrDefault(x => x.Code == requestPacket.Words[3]),
                               };
         if (banListItem.BanType.Code == BanTypes.Perm.Code)
         {
             banListItem.Reason = requestPacket.Words[4];
             itemCreated = true;
         }
         else if (banListItem.BanType.Code == BanTypes.Seconds.Code)
         {
             banListItem.Seconds = Convert.ToInt32(requestPacket.Words[4]);
             banListItem.Reason = requestPacket.Words[5];
             itemCreated = true;
         }
         else if (banListItem.BanType.Code == BanTypes.Rounds.Code )
         {
             banListItem.Seconds = Convert.ToInt32(requestPacket.Words[4]);
             banListItem.Reason = requestPacket.Words[5];
             itemCreated = true;
         }
         if (itemCreated)
         {
             session.Server.BanList.Add(banListItem);
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_SUCCESS);
         }
         else
         {
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_INVALID_ARGUMENTS);
         }
     }
     else
     {
         responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_INVALID_ARGUMENTS);
     }
     return true;
 }
Exemple #4
0
        private static int AddBanDescription(PlayerInstance ch, string arg1, string arg2, int duration, BanTypes type)
        {
            var ban = ch.DestinationBuffer.CastAs <BanData>();

            if (ban == null)
            {
                LogManager.Instance.Bug("Null DestinationBuffer for character {0}", ch.Name);
                ch.SubState = CharacterSubStates.None;
                return(0);
            }

            if (!ban.Note.IsNullOrWhitespace())
            {
                ban.Note = string.Empty;
            }

            //ban.Note = build.copy_buffer(ch);
            //build.stop_editing(ch);

            ch.SubState = EnumerationExtensions.GetEnum <CharacterSubStates>(ch.tempnum);
            BanManager.Instance.Repository.Add(ban);

            if (ban.Duration > 0)
            {
                ch.Printf("{0} is banned for {1} days.\r\n", ban.Name, ban.Duration / 86400);
            }
            else
            {
                ch.Printf("{0} is banned forever.\r\n", ban.Name);
            }

            return(1);
        }
Exemple #5
0
        public static int AddBan(PlayerInstance ch, string arg1, string arg2, int duration, BanTypes type)
        {
            switch (ch.SubState)
            {
            case CharacterSubStates.Restricted:
                ch.SendTo("You cannot use this command from within another command.\r\n");
                return(0);

            case CharacterSubStates.BanDescription:
                return(AddBanDescription(ch, arg1, arg2, duration, type));
            }


            return(0);
        }
Exemple #6
0
 private static void ShowBans(CharacterInstance ch, BanTypes type)
 {
 }