Beispiel #1
0
        public OnlineCommand()
        {
            _updateOnlineTimer = new Timer(UpdateOnlineCallback, null, UpdateOnlineInterval, Timeout.Infinite);
            _paginationManager = new PaginationManager();

            Bot.DiscordClient.MessageReactionAdded += DiscordClientOnMessageReactionAdded;
        }
Beispiel #2
0
        /// <summary>
        /// Selects the appropriate cs go container to open, user replies with a number corrosponding to the case
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static PaginatedMessage ShowPossibleCases(SocketCommandContext context)
        {
            string botCommandPrefix = CommandGuildPrefixManager.GetGuildCommandPrefix(context);

            //Create pagination entries
            List <string> leftCounter        = new List <string>();
            List <string> filteredContainers = new List <string>();

            //Find containers whose name is not null
            filteredContainers = CsgoUnboxingHandler.csgoContiners.Containers.Where(c => c.Name != null).Select(c => c.Name).ToList();
            //Create a list of ascending numbers to reference each container
            for (int i = 0; i < filteredContainers.Count(); i++)
            {
                leftCounter.Add(i.ToString());
            }

            //Generate pagination
            PaginationConfig paginationConfig = new PaginationConfig
            {
                AuthorName = "CS:GO Containers",
                AuthorURL  = "https://csgostash.com/img/containers/c259.png",

                Description = $"Select a container by typing the appropriate number on the left\nThen use `{botCommandPrefix} cs open` to open cases",

                Field1Header = "Number",
                Field2Header = "Case",
            };

            PaginationManager paginationManager = new PaginationManager();
            var pager = paginationManager.GeneratePaginatedMessage(leftCounter, filteredContainers, paginationConfig);

            return(pager);
        }
Beispiel #3
0
 public RobotController(IData d)
 {
     _paginationManager = new PaginationManager(d);
     _contentManager    = new ContentManager(d);
     _robotManager      = new RobotManager(d);
     _programManager    = new ProgramManager(d);
     _commandManager    = new CommandManager(d);
 }
 public ProgramController(IData data)
 {
     _contentManager = new ContentManager(data);
     _paginationManager = new PaginationManager(data);
     _programManager = new ProgramManager(data);
     _robotManager = new RobotManager(data);
     _commandManager = new CommandManager(data);
 }
        public static PaginatedMessage DisplayUserCsgoInventory(SocketCommandContext context)
        {
            string botCommandPrefix = CommandGuildPrefixManager.GetGuildCommandPrefix(context);

            //Reset fields
            embedFieldsMaster      = new List <string>();
            embedPriceFieldsMaster = new List <string>();

            //Get user skins from xml file
            UserSkinStorageRootobject userSkin = new UserSkinStorageRootobject();

            try
            {
                userSkin = XmlManager.FromXmlFile <UserSkinStorageRootobject>(CoreMethod.GetFileLocation("UserSkinStorage.xml"));
            }
            catch (Exception)
            {
            }

            List <UserSkinEntry> foundUserSkins = new List <UserSkinEntry>();

            //Filter userSkinEntries xml file down to skins belonging to sender
            foreach (var userSkinEntry in userSkin.UserSkinEntries)
            {
                //Filter skin search to those owned by user
                if (userSkinEntry.OwnerID == context.Message.Author.Id)
                {
                    foundUserSkins.Add(new UserSkinEntry {
                        OwnerID = context.Message.Author.Id, ClassId = userSkinEntry.ClassId, UnboxDate = userSkinEntry.UnboxDate
                    });
                }
            }

            //Generate fields
            AddSkinFieldEntry(foundUserSkins);

            //Configurate paginated message
            var paginationConfig = new PaginationConfig
            {
                AuthorName = context.Message.Author.ToString().Substring(0, context.Message.Author.ToString().Length - 5) + " Inventory",
                AuthorURL  = context.Message.Author.GetAvatarUrl(),

                Description = $"To sell items, use `{botCommandPrefix} cs sell [name]` \n To sell all items matching filter, use `{botCommandPrefix} cs sellall [name]`",

                DefaultFieldHeader      = "You do not have any skins",
                DefaultFieldDescription = $"Go unbox some with `{botCommandPrefix} case open`",

                Field1Header = "Item Name",
                Field2Header = "Market Value",
            };

            var paginationManager = new PaginationManager();

            //Generate paginated message
            var pager = paginationManager.GeneratePaginatedMessage(embedFieldsMaster, embedPriceFieldsMaster, paginationConfig);

            return(pager);
        }
    public void FormListLogicTest()
    {
      var _manager = new PaginationManager(data);
      var result = _manager.FormProgramsPage(pageSize: 2, page: 1);
      var programs = data.Programs.Data.OrderBy(x => x.Name).Take(2);
      Assert.AreEqual(result.Count(), 2);
      Assert.AreEqual(result.First().Name, programs.First().Name);
      Assert.AreEqual(result.Last().Name, programs.Last().Name);

      var result2 = _manager.FormMyRobotsPage(robots:data.Robots.Data, pageSize: 2, page: 1);
      var robots = data.Robots.Data.OrderBy(x => x.RobotID).Take(1);
      Assert.AreEqual(result2.Count(), 1);
      Assert.AreEqual(result2.First().RobotID, robots.First().RobotID);
    }
        public void FormListLogicTest()
        {
            var _manager = new PaginationManager(data);
            var result   = _manager.FormProgramsPage(pageSize: 2, page: 1);
            var programs = data.Programs.Data.OrderBy(x => x.Name).Take(2);

            Assert.AreEqual(result.Count(), 2);
            Assert.AreEqual(result.First().Name, programs.First().Name);
            Assert.AreEqual(result.Last().Name, programs.Last().Name);

            var result2 = _manager.FormMyRobotsPage(robots: data.Robots.Data, pageSize: 2, page: 1);
            var robots  = data.Robots.Data.OrderBy(x => x.RobotID).Take(1);

            Assert.AreEqual(result2.Count(), 1);
            Assert.AreEqual(result2.First().RobotID, robots.First().RobotID);
        }
        public static PaginatedMessage GetCsgoMarketInventory(SocketCommandContext context, string filterString)
        {
            string botCommandPrefix = CommandGuildPrefixManager.GetGuildCommandPrefix(context);

            //Get skin data
            var rootWeaponSkin = CsgoDataHandler.GetRootWeaponSkin();

            List <string> filteredRootWeaponSkin      = new List <string>();
            List <string> filteredRootWeaponSkinPrice = new List <string>();

            try
            {
                //Filter rootWeaponSkin to those with a price found in rootWeaponSkinPrice
                foreach (var skin in rootWeaponSkin.ItemsList.Values)
                {
                    //If filter string is not null, filter market results by user filter string
                    if ((!string.IsNullOrEmpty(filterString) && skin.Name.ToLower().Contains(filterString.ToLower())) || (string.IsNullOrEmpty(filterString)))
                    {
                        string skinQualityEmote = GetEmoteBySkinRarity(skin.Rarity, skin.WeaponType);

                        //Add skin entry
                        try
                        {
                            Emote emote = Emote.Parse(skinQualityEmote);

                            //Add weapon skin
                            filteredRootWeaponSkin.Add(emote + " " + skin.Name);

                            //Add tax markup for market item
                            long weaponSkinValue = Convert.ToInt64(skin.Price.AllTime.Average);
                            weaponSkinValue += Convert.ToInt64(weaponSkinValue * float.Parse(SettingsManager.RetrieveFromConfigFile("taxRate")));

                            //Add weapon skin price
                            filteredRootWeaponSkinPrice.Add(emote + " " + weaponSkinValue.ToString());
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            //Configurate paginated message
            var paginationConfig = new PaginationConfig
            {
                AuthorName = "CS:GO Market",
                AuthorURL  = context.Message.Author.GetAvatarUrl(),

                Description = $"Current skin market, to buy skins, use `{botCommandPrefix} cs buy [name]` \n use `{botCommandPrefix} cs market [name]` to filter skins by name \n use `{botCommandPrefix} cs info [name]` to preview skins",

                DefaultFieldHeader      = "Unable to find specified weapon skin!",
                DefaultFieldDescription = $"Broaden your search parameters and try again",

                Field1Header = "Item Name",
                Field2Header = "Price",
            };

            var paginationManager = new PaginationManager();

            //Generate paginated message
            var pager = paginationManager.GeneratePaginatedMessage(filteredRootWeaponSkin, filteredRootWeaponSkinPrice, paginationConfig);

            return(pager);
        }