Example #1
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            if (DateTime.Compare(DateTime.Today, currentDate) != 0)
            {
                hasRanToday = false;
                reroll      = 1;
            }

            if (!hasRanToday)
            {
                int day = Convert.ToInt32((DateTime.Today - new DateTime(2010, 1, 1)).TotalDays);

                currentDate    = DateTime.Today;
                hasRanToday    = true;
                dealEntry.Deal = dealPicker.PickDeal(new Random(day), reroll);

                ComputeMessage();
            }

            return(dealMessage);
        }
Example #2
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            if (botContext.FriendID.ConvertToUInt64().ToString().CompareTo("76561198030277114") != 0)
            {
                return("");
            }

            int numDeals = 1;

            try
            {
                numDeals = Convert.ToInt32(botContext.Command.Trim().Substring(6));
            }
            catch (Exception e)
            {
                if (e is OverflowException || e is FormatException)
                {
                    numDeals = 1; // no-op, essentially. just making it explicit
                }
            }

            int max = (dealPicker.Count() > numDeals) ? numDeals : dealPicker.Count();
            LinkedList <DealEntry> spunDeals = new LinkedList <DealEntry>();

            int iterator = numDeals;

            while (iterator > 0)
            {
                DealEntry tempDeal         = dealPicker.PickDeal();
                bool      dealHasBeenAdded = false;

                for (int i = 0; i < spunDeals.Count; i++)
                {
                    if (spunDeals.ElementAt(i).Name.CompareTo(tempDeal.Name) == 0)
                    {
                        dealHasBeenAdded = true;
                        break;
                    }

                    if (spunDeals.ElementAt(i).Name.CompareTo(tempDeal.Name) > 0)
                    {
                        spunDeals.AddBefore(spunDeals.Find(spunDeals.ElementAt(i)), tempDeal);
                        dealHasBeenAdded = true;
                        iterator--;
                        break;
                    }
                }

                if (!dealHasBeenAdded)
                {
                    spunDeals.AddLast(tempDeal);
                    iterator--;
                }
            }

            StringBuilder outputBuffer = new StringBuilder();

            foreach (DealEntry deal in spunDeals)
            {
                string tempStr = deal.Quantity + "\t" + deal.Price + " (" + deal.DiscountAmount + "%)" + ((deal.Price < 10) ? "\t\t" : "\t") + deal.Name + "\n";

                if (tempStr.Length + outputBuffer.Length > 2048)
                {
                    SendMessage(botContext, outputBuffer.ToString());

                    // don't want to attempt to send too many messages in a row
                    // this will cause the entire bot to sleep for up to a few seconds but as only one privleged person can invoke this command, that is ok

                    System.Threading.Thread.Sleep(1000);
                    outputBuffer.Clear();
                }

                outputBuffer.Append(tempStr);
            }

            return(outputBuffer.ToString());
        }
Example #3
0
        public void Initialize()
        {
            DealPicker dealPicker = new DealPicker();

            //------------------------------------------------------------------------

            // finds the balance (co-op shop points) of the invoker
            // Specific to The After Party steam group

            actions.Add(new BalanceBotAction());

            //------------------------------------------------------------------------

            // determines which member has the most co-op shop points.
            // Specific to The After Party steam group

            actions.Add(new QueenBotAction());

            //------------------------------------------------------------------------

            // rolls a number between the specified values, or if no values are specified it rolls a random number between 1-100

            actions.Add(new RollAction());

            //------------------------------------------------------------------------

            // a trivial action to count how many times !milkshakes has been invoked
            // no real purpose

            actions.Add(new MilkshakeAction());

            //------------------------------------------------------------------------

            // creates a daily deal for this day
            // Specific to The After Party steam group

            DealWrapper     deal       = new DealWrapper(dealPicker.PickDeal(new Random(Convert.ToInt32((DateTime.Today - new DateTime(2010, 1, 1)).TotalDays)), 1));
            DailyDealAction dealAction = new DailyDealAction(dealPicker, deal);

            actions.Add(dealAction);

            //------------------------------------------------------------------------

            // if the current deal is bought, there is need to reroll the deal to get a new random deal
            // otherwise it uses the same seed (a value procurred via today's date times a reroll factor)
            // and will just pick the next item on the list after the purchased item is removed
            // Specific to The After Party steam group

            actions.Add(new RerollAction(dealAction));

            //------------------------------------------------------------------------

            // resets the reroll counter in the dailyDealAction
            // only successfully executes if Monukai invokes it personally
            // Specific to The After Party steam group

            actions.Add(new ResetAction(dealAction));

            //------------------------------------------------------------------------

            // The buy deal action gives users a chance to reserve the current deal
            // It is complemented by a confirm action that confirms their purchase

            LinkedList <UserEntry> users = new LinkedList <UserEntry>();
            DateTimeWrapper        date  = new DateTimeWrapper();

            actions.Add(new BuyDealAction(users, date, dealAction, deal));
            actions.Add(new ConfirmBuyAction(users, date, dealAction, deal));

            //------------------------------------------------------------------------

            // The spin action "spins" a number of deals equal to the number specified in the command
            // -- uses current datetime to seed randomness
            // Specific to The After Party steam group

            actions.Add(new SpinAction(dealPicker));

            //------------------------------------------------------------------------

            // parses steamApp links to see if the specified game/app is in the co-op shop
            // Specific to The After Party steam group

            actions.Add(new ParseAppIDAction());

            //------------------------------------------------------------------------

            // simple action to join a specified chatroom by it's steamcommunity URL

            actions.Add(new JoinAction());

            //------------------------------------------------------------------------

            // report the player of the week of the TAP group

            actions.Add(new POTWAction());

            //------------------------------------------------------------------------

            // simple action to post directory URLs to help easily navigate users to certain pages

            actions.Add(new DirectoryAction());

            //------------------------------------------------------------------------

            // repost what the user said after the /me command as RP text

            actions.Add(new MeAction());

            //------------------------------------------------------------------------

            // simple action to tell the user who invokes the command their 64-bit Steam ID

            actions.Add(new IDAction());

            //------------------------------------------------------------------------

            // simple action to tell the user who invokes the command their 64-bit Steam ID

            actions.Add(new SearchAction());
        }