Пример #1
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            Regex joinCmd       = new Regex(@"(!join)(\s+)(.+)");
            Regex validSteamURL = new Regex(@"(http://)?(www\.)?(steamcommunity\.com/groups/)([a-zA-Z0-9_]+)");
            Match match         = joinCmd.Match(botContext.Command);
            Match urlMatch;

            if (match.Success)
            {
                urlMatch = validSteamURL.Match(match.Groups[3].Value);
                Console.WriteLine(match.Groups[3].Value);

                if (urlMatch.Success)
                {
                    string html         = new WebClient().DownloadString(match.Groups[3].Value);
                    Regex  joinChatExpr = new Regex(@".*(joinchat/)([0-9]+).*");
                    Match  htmlMatch    = joinChatExpr.Match(html);

                    if (htmlMatch.Success)
                    {
                        ulong chatID = 0;
                        if (UInt64.TryParse(htmlMatch.Groups[2].Value, out chatID))
                        {
                            Console.WriteLine("Entering chat...");
                            SteamID groupChatID = new SteamID(chatID);
                            botContext.SteamFriend.JoinChat(groupChatID);
                        }
                    }
                }
            }

            return("");
        }
Пример #2
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            if (botContext.Command.CompareTo("!directory") == 0 ||
                botContext.Command.CompareTo("/directory") == 0 ||
                botContext.Command.CompareTo("!overview") == 0 ||
                botContext.Command.CompareTo("/overview") == 0)
            {
                return("Group overview: http://steamcommunity.com/groups/TAP_Gaming");
            }

            if (botContext.Command.CompareTo("!events") == 0 ||
                botContext.Command.CompareTo("/events") == 0)
            {
                return("Group events: http://steamcommunity.com/groups/TAP_Gaming#events");
            }

            if (botContext.Command.CompareTo("!coopshop") == 0 ||
                botContext.Command.CompareTo("/coopshop") == 0)
            {
                return("The Co-op Shop: http://steamcommunity.com/groups/TAP_Gaming/discussions/3/618458030693142262/");
            }

            if (botContext.Command.CompareTo("!forums") == 0 ||
                botContext.Command.CompareTo("/forums") == 0 ||
                botContext.Command.CompareTo("!discussions") == 0 ||
                botContext.Command.CompareTo("/discussions") == 0)
            {
                return("Group forums: http://steamcommunity.com/groups/TAP_Gaming/discussions");
            }

            if (botContext.Command.CompareTo("!balances") == 0 ||
                botContext.Command.CompareTo("/balances") == 0)
            {
                return("User balances: http://steamcommunity.com/groups/TAP_Gaming/discussions/3/618458030693142262/#c618458030693142415");
            }

            if (botContext.Command.CompareTo("!inventory") == 0 ||
                botContext.Command.CompareTo("/inventory") == 0)
            {
                return("Co-op Shop inventory: http://steamcommunity.com/groups/TAP_Gaming/discussions/3/618458030693142262/#c618458030693142528");
            }

            if (botContext.Command.CompareTo("!sales") == 0 ||
                botContext.Command.CompareTo("/sales") == 0 ||
                botContext.Command.CompareTo("!sale") == 0 ||
                botContext.Command.CompareTo("/sale") == 0)
            {
                return("Co-op Shop sales: http://steamcommunity.com/groups/TAP_Gaming/discussions/3/618458030693142262/#c618458030693142805");
            }

            if (botContext.Command.CompareTo("!tag") == 0 ||
                botContext.Command.CompareTo("/tag") == 0)
            {
                return("The After Games forums: http://steamcommunity.com/groups/TAP_Gaming/discussions/9/");
            }

            return("");
        }
Пример #3
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            if (botContext.FriendID.ConvertToUInt64().ToString().CompareTo("76561198030277114") == 0)
            {
                dealAction.Reset();
            }

            return("");
        }
Пример #4
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            Regex  searchParam = new Regex(@"[!/](search )(.*)");
            Match  searchMatch = searchParam.Match(botContext.Command);
            string searchName  = "";

            if (!String.IsNullOrEmpty(searchMatch.Groups[2].ToString()))
            {
                searchName = searchMatch.Groups[2].ToString();
            }
            else
            {
                return("No search terms supplied.");
            }

            Regex  replRegex = new Regex(@"[^a-z0-9]");
            string testName  = searchName.ToLower();

            testName = replRegex.Replace(testName, "");

            Regex itemName = new Regex(@"([0-9]+)\s+([0-9]+)\s+([^\t]+)\t*(.*)?");

            try
            {
                using (StreamReader sr = new StreamReader(@"C:\Users\zykour\Dropbox\TAP Inventory 1.txt"))
                {
                    String line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        Match match = itemName.Match(line);

                        if (match.Success)
                        {
                            string matchedString = match.Groups[3].ToString().Trim();
                            searchName    = matchedString;
                            matchedString = matchedString.ToLower();
                            matchedString = replRegex.Replace(matchedString, "");

                            if (matchedString.CompareTo(testName) == 0)
                            {
                                return(searchName + " is available for " + match.Groups[2].ToString().Trim() + " points, just " + match.Groups[1].ToString().Trim() + " left!");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read: ");
                Console.WriteLine(e.Message);
            }

            return("Item not found in the master inventory list.");
        }
Пример #5
0
 public void ParseChatText(BotContext botContext)
 {
     foreach (BotAction action in actions)
     {
         if (action.IsValidCommand(botContext.Command.Trim().ToLower()))
         {
             action.Execute(botContext);
             //break;
         }
     }
 }
Пример #6
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            UserEntry userEntry = CoopShopUtility.GetUserEntry(botContext);

            if (userEntry != null)
            {
                return(userEntry.Name + ", your balance is " + userEntry.Balance);
            }

            return("");
        }
Пример #7
0
        // A helper method for all bot actions that sends a message in response to the command
        // Any command that should send always send a response to a user, call SendFriendMessage directly

        protected virtual void SendMessage(BotContext botContext, string chatMessage)
        {
            if (chatMessage.CompareTo("") != 0)
            {
                if (botContext.GroupID != null)
                {
                    SendGroupMessage(botContext, chatMessage);
                }
                else if (botContext.FriendID != null)
                {
                    SendFriendMessage(botContext, chatMessage);
                }
            }
        }
Пример #8
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            if (DateTime.Compare(currentDealDate.Date, DateTime.Today) != 0)
            {
                pendingPurchases.Clear();
                currentDealDate.Date = DateTime.Today;
                dealEntry.Deal       = dailyDealAction.Deal;
            }

            UserEntry buyer = CoopShopUtility.GetUserEntry(botContext);

            if (buyer == null)
            {
                return("");
            }

            foreach (UserEntry user in pendingPurchases)
            {
                if (user.Name.CompareTo(buyer.Name) == 0)
                {
                    pendingPurchases.Remove(user);

                    if (buyer.Balance < dealEntry.Price)
                    {
                        return(buyer.Name + ", you no longer have enough points!");
                    }

                    string chatMessage   = buyer.Name + " wishes to buy " + dealEntry.Name + " for " + dealEntry.Price + " points.";
                    string returnMessage = buyer.Name + ", a purchase request has been sent to Monukai for '" + dealEntry.Name + "'!";

                    if ((dealEntry.Quantity - 1) <= 0)
                    {
                        pendingPurchases.Clear();
                        dailyDealAction.Reroll();
                        dealEntry.Deal = dailyDealAction.Deal;
                    }
                    else
                    {
                        dealEntry.Quantity = dealEntry.Quantity - 1;
                        dailyDealAction.ComputeMessage();
                    }

                    botContext.SteamFriend.SendChatMessage(new SteamID(Convert.ToUInt64("76561198030277114")), EChatEntryType.ChatMsg, chatMessage);

                    return(returnMessage);
                }
            }

            return("It does not appear you have attempted to buy this deal, do so with '!buydeal'");
        }
Пример #9
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            if (botContext.GroupID == null)
            {
                return("");
            }

            if (botContext.GroupID.ConvertToUInt64().ToString().CompareTo("110338190875693447") != 0)
            {
                return("");
            }

            //if (currentDate.Date.CompareTo(DateTime.Today.Date) != 0 || String.IsNullOrEmpty(message))
            //{
            GetPOTW(botContext);
            //}

            return(message);
        }
Пример #10
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            Regex rollFormat = new Regex(@"[!/](roll )([0-9]+)\-([0-9]+)");

            Match match = rollFormat.Match(botContext.Command);

            int lower = 1;
            int upper = 100;

            if (match.Success)
            {
                try
                {
                    lower = Int32.Parse(match.Groups[2].ToString().Trim());
                }
                catch (OverflowException e)
                {
                    lower = Int32.MaxValue - 1;
                }

                try
                {
                    upper = Int32.Parse(match.Groups[3].ToString().Trim());
                }
                catch (OverflowException e)
                {
                    upper = Int32.MaxValue - 1;
                }
            }

            if (lower > upper)
            {
                int temp = lower;
                lower = upper;
                upper = temp;
            }

            Random rg        = new Random();
            int    randomNum = rg.Next(lower, upper + 1);

            return("rolled a " + randomNum);
        }
Пример #11
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);
        }
Пример #12
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            // General format for balances is: Name     ##      SteamID
            Regex balanceCmd = new Regex(@"([^0-9]*)([0-9]+)\s+([0-9]+)");

            try
            {
                using (StreamReader sr = new StreamReader(@"C:\Users\zykour\Dropbox\TAP balance.txt"))
                {
                    String line;
                    int    max           = 0;
                    string highestPoints = "";

                    while ((line = sr.ReadLine()) != null)
                    {
                        Match match = balanceCmd.Match(line);

                        if (match.Success)
                        {
                            if (max < Int32.Parse(match.Groups[2].ToString().Trim()))
                            {
                                max           = Int32.Parse(match.Groups[2].ToString().Trim());
                                highestPoints = match.Groups[1].ToString().Trim();
                                highestPoints = highestPoints.Substring(1);
                            }
                        }
                    }

                    return("Queen " + highestPoints + " is winning with " + max + " points!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            return(null);
        }
Пример #13
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());
        }
Пример #14
0
        protected override string ProduceChatMessage(BotContext botContext)
        {
            milkshakes += 1;

            return("Milkshakes: " + milkshakes);
        }
Пример #15
0
 protected override string ProduceChatMessage(BotContext botContext)
 {
     return("Your 64-bit SteamID is: " + botContext.FriendID.ConvertToUInt64().ToString());
 }
Пример #16
0
 protected override string ProduceChatMessage(BotContext botContext)
 {
     return("*" + botContext.Command.Substring(3).Trim() + "*");
 }
Пример #17
0
 public void Execute(BotContext botContext)
 {
     SendMessage(botContext, ProduceChatMessage(botContext));
 }
Пример #18
0
        // This is where the logic is done for every action and the output is generated (and returned)

        protected virtual string ProduceChatMessage(BotContext botContext)
        {
            return("");
        }
Пример #19
0
 protected void SendFriendMessage(BotContext botContext, string chatMessage)
 {
     botContext.SteamFriend.SendChatMessage(botContext.FriendID, EChatEntryType.ChatMsg, chatMessage);
 }
Пример #20
0
        // SendGroupMessage and SendFriendMessage are called by SendMessage but can be called directly for different behavior

        protected void SendGroupMessage(BotContext botContext, string chatMessage)
        {
            botContext.SteamFriend.SendChatRoomMessage(botContext.GroupID, EChatEntryType.ChatMsg, chatMessage);
        }
Пример #21
0
 protected override string ProduceChatMessage(BotContext botContext)
 {
     return(RecurseParse(botContext.Command.Trim()));
 }