public void SendMessageToIrc(ref Queue <string> mToRelease)
    {
        if (_coolDown > 0f)
        {
            return;
        }
        _coolDown = _timeBetweenMessage;

        string messageToSend = mToRelease.Dequeue();


        _twitchIRC.SendMsg(messageToSend);
    }
Пример #2
0
    //when message is recieved from IRC-server or our own message.
    void OnChatMsgRecieved(string msg)
    {
        //parse from buffer.
        int    msgIndex  = msg.IndexOf("PRIVMSG #");
        string msgString = msg.Substring(msgIndex + IRC.channelName.Length + 11);
        string user      = msg.Substring(1, msg.IndexOf('!') - 1);


        if (msgString.StartsWith("Hey Roach,", System.StringComparison.CurrentCultureIgnoreCase))
        {
            Regex whatsOnMenuRegex = new Regex("hey roach,.*menu.*", RegexOptions.IgnoreCase);

            Regex whatAreIngredientsRegex = new Regex("hey roach,(.*ingredient.*|.*topping.*)", RegexOptions.IgnoreCase);
            //Whats on the menu
            if (whatsOnMenuRegex.IsMatch(msgString))
            {
                string menu = OrderHandler.whatsOnTheMenu();
                foreach (string menuItem in menu.Split('|'))
                {
                    IRC.SendMsg(menuItem);
                }
            }
            else if (whatAreIngredientsRegex.IsMatch(msgString))
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("All available ingredients:");
                foreach (string ingredient in System.Enum.GetValues(typeof(Ingredient.ITypes)))
                {
                    sb.Append(' ');
                    sb.Append(ingredient);
                    sb.Append(',');
                }
                sb.Remove(sb.Length - 1, 1);
            }

            //Assume its an order
            else
            {
                orderHandler.handleStreamText(msgString, user);
            }
        }


        //remove old messages for performance reasons.
        if (messages.Count > maxMessages)
        {
            Destroy(messages.First.Value);
            messages.RemoveFirst();
        }
    }
Пример #3
0
    public void SendMessageToIRC(string message, MessagePriority priority = MessagePriority.Classic)
    {
        if (_antiSpamFilter)
        {
            switch (priority)
            {
            case MessagePriority.Classic:
                _antiSpamFilter.SendMessageWithFilter(message);
                break;

            case MessagePriority.Important:
                _antiSpamFilter.SendMessageWithPriorityFilter(message);
                break;

            case MessagePriority.Direct:
                _antiSpamFilter.SendMessageWithNoProtection(message);
                break;

            default:
                break;
            }
        }
        else
        {
            _twitchIRC.SendMsg(message);
        }
    }
Пример #4
0
    async void OnChatMsgReceived(string msg)
    {
        int    msgIndex  = msg.IndexOf("PRIVMSG #");
        string msgString = msg.Substring(msgIndex + IRC.channelName.Length + 11);
        string user      = msg.Substring(1, msg.IndexOf('!') - 1);
        string command   = msgString.Split('!')[1].Split(' ')[0];

        string[] data = msgString.Split(' ');
        data = data.Slice(1, data.Length);
        var response = "";

        if (msgString == "!help")
        {
            response = "type !rain, !fire or !wind=X (x is integer amount)";
        }
        else if (EventDict.ContainsKey(command))
        {
            var invoice = await EventDict[command].CreateInvoice(lnd, user, data);
            activeInvoices.Add(invoice, new EventInvoicePayload(command, user, data));
            response = invoice;
        }
        if (response != "")
        {
            //GetComponent<TwitchChatExample>().CreateUIMessage("sputnck1", response);
            IRC.SendMsg(response);
        }
    }
 //when Submit button is clicked or ENTER is pressed.
 public void OnSubmit()
 {
     if (inputField.text.Length > 0)
     {
         IRC.SendMsg(inputField.text);                   //send message.
         CreateUIMessage(IRC.nickName, inputField.text); //create ui element.
         inputField.text = "";
     }
 }
Пример #6
0
    async void OnChatMsgRecieved(string msg)
    {
        int    msgIndex  = msg.IndexOf("PRIVMSG #");
        string msgString = msg.Substring(msgIndex + IRC.channelName.Length + 11);
        string user      = msg.Substring(1, msg.IndexOf('!') - 1);

        Debug.Log(msg);
        Debug.Log(msgString);
        var response = "";

        if (msgString == "!help")
        {
            response = "type !rain, !fire or !wind=X (x is integer amount)";
        }
        else if (msgString == "!rain")
        {
            response = response + await weatherClient.GetWeatherInvoice("rain", 5);
        }
        else if (msgString == "!fire")
        {
            response = await weatherClient.GetWeatherInvoice("fire", 10);
        }
        else if (msgString.Contains("wind"))
        {
            var s = msgString.Split('=');
            response = response + await weatherClient.GetWeatherInvoice("wind", int.Parse(s[1]));
        }
        else if (msgString == "!channel")
        {
            response = weatherClient.pubkey + "@" + externalIp + ":" + port;
        }
        if (response != "")
        {
            GetComponent <TwitchChatExample>().CreateUIMessage("sputnck1", response);
            IRC.SendMsg(response);
        }
    }
Пример #7
0
    public void handleStreamText(string message, string user)
    {
        Boolean customOrder = false;
        Order   order       = OrderFactory.Create(message);

        if (order == null)
        {
            order = Order.convertStringToOrder(message);
            order.setLabel("Custom Order").setUser(user);
            customOrder = true;
        }
        else
        {
            order = Order.convertStringToOrder(message, order);
        }
        if (validateOrder(order))
        {
            if (customOrder)
            {
                twithComm.SendMsg(string.Format("Sure {0}, I can make a sandwich that has {1}", order.user, order.ToPrettyString()));
            }
            else
            {
                twithComm.SendMsg(string.Format("You got it {0}, making that {1}", order.user, order.label));
            }
            order.setDescription(message);
            orders.Enqueue(order);
            orderNotification.SetOrderNotification(order);
            Debug.Log(order.ToString());
        }
        else
        {
            //Courtesy Message for bad ingredients
            twithComm.SendMsg(string.Format("Sorry {0}, thats not a real sandwich. Select a sandwich from our menu. To see it type: \"Hey Roach, whats on the menu?\" Or build your own by naming off the ingredients you want. To see our ingredients type \"Hey Roach, what ingredients do you have?\" .", user));
        }
    }
Пример #8
0
    public void WritePollTwitchChat()
    {
        string poll = ("!poll start " + pollTitle + " ");

        for (int i = 0; i < 5; i++)
        {
            if (actionPoll[i] != null)
            {
                poll += "| " + actionPoll[i] + " ";
            }
        }
        IRC.SendMsg(poll);

        /*
         *      string path = "C:/Streamlabs_Chatbot/Twitch_Poll.txt";
         *      StreamWriter writer = new StreamWriter(path);
         *      writer.Write("!poll start " + pollTitle + " ");
         *
         *      for (int i = 0; i < 5; i++)
         *          if (actionPoll[i] != null || actionPoll[i] == "---------------")
         *              writer.Write("| " + actionPoll[i] + " ");
         *      writer.Close();
         */
    }
Пример #9
0
    public static void GetABet(string incomingBet, string incomingBettersName, GameObject raceManagerGameObjectRef)
    {
        //print("We got a bet: "+ incomingBet);

        RaceManager racemanagerScriptRef = raceManagerGameObjectRef.GetComponent <RaceManager>();

        foreach (GameObject eachTurtle in racemanagerScriptRef.TurtlesInTheRace)
        {
            TurtleAI turtleScriptRef = eachTurtle.GetComponent <TurtleAI>();
            if (incomingBet.CaseInsensitiveContains("register"))
            {
                foreach (GuestData gD in GuestManager.AllGuests)
                {
                    if (gD.guestName == incomingBettersName)
                    {
                        gD.registeredAddress = incomingBet;
                    }
                }
            }

            if (incomingBet.CaseInsensitiveContains("bid"))
            {
                if (incomingBet.CaseInsensitiveContains(" a"))
                {
                    Debug.Log("incoming bet " + incomingBet);
                    TurtleForSale turtleForBiddingScriptRef = racemanagerScriptRef.CurrentTurtlesForSale[0].GetComponent <TurtleForSale>();
                    turtleForBiddingScriptRef.GetABid(int.Parse(Regex.Match(incomingBet, @"\d+").Value));
                }
                if (incomingBet.CaseInsensitiveContains(" b"))
                {
                    Debug.Log("incoming bet " + incomingBet);
                    TurtleForSale turtleForBiddingScriptRef = racemanagerScriptRef.CurrentTurtlesForSale[1].GetComponent <TurtleForSale>();
                    turtleForBiddingScriptRef.GetABid(int.Parse(Regex.Match(incomingBet, @"\d+").Value));
                }
                if (incomingBet.CaseInsensitiveContains(" c"))
                {
                    Debug.Log("incoming bet " + incomingBet);
                    TurtleForSale turtleForBiddingScriptRef = racemanagerScriptRef.CurrentTurtlesForSale[2].GetComponent <TurtleForSale>();
                    turtleForBiddingScriptRef.GetABid(int.Parse(Regex.Match(incomingBet, @"\d+").Value));
                }
            }

            if (incomingBet.CaseInsensitiveContains(eachTurtle.name) && RaceManager.isBettingOpen)
            {
                //bet on the turtle
                //print("Bet on this turtle " + eachTurtle.name);


                if (incomingBet.CaseInsensitiveContains("win") || incomingBet.CaseInsensitiveContains("show") || incomingBet.CaseInsensitiveContains("place"))
                {
                    //bet to win
                    string numbersInMessage = Regex.Match(incomingBet, @"\d+").Value;
                    int    betAsInt         = int.Parse(numbersInMessage);
                    if (betAsInt < 0)
                    {
                        return;
                    }
                    BetData thisBet = new BetData();
                    thisBet.TurtlesName = eachTurtle.name;
                    thisBet.BetAmount   = betAsInt;
                    if (incomingBet.CaseInsensitiveContains("win"))
                    {
                        thisBet.BetType = "win";
                        turtleScriptRef.howMuchIsBetOnMe += thisBet.BetAmount;
                    }
                    if (incomingBet.CaseInsensitiveContains("place"))
                    {
                        thisBet.BetType = "place";
                        turtleScriptRef.howMuchIsBetOnMeToPlace += thisBet.BetAmount;
                    }
                    if (incomingBet.CaseInsensitiveContains("show"))
                    {
                        thisBet.BetType = "show";
                        turtleScriptRef.howMuchIsBetOnMeToShow += thisBet.BetAmount;
                    }
                    thisBet.BettersName = incomingBettersName;
                    thisBet.BetOdds     = turtleScriptRef.myRealOdds;
                    foreach (GuestData gD in GuestManager.AllGuests)
                    {
                        if (gD.guestName == thisBet.BettersName)
                        {
                            if (gD.guestCash < thisBet.BetAmount)
                            {
                                thisBet.BetAmount = gD.guestCash;
                            }
                            if (gD.guestCash == thisBet.BetAmount)
                            {
                                GameObject     bottomToaster  = GameObject.Find("Toaster");
                                ToasterManager toastScriptRef = bottomToaster.GetComponent <ToasterManager>();
                                toastScriptRef.ShowAToaster(gD.guestName, " Went ALL IN!");
                            }
                            gD.guestCash -= thisBet.BetAmount;
                        }
                    }
                    racemanagerScriptRef.CurrentRaceBets.Add(thisBet);

                    TwitchIRC tIRC = raceManagerGameObjectRef.GetComponent <TwitchIRC>();
                    if (!thisBet.BettersName.Contains("turtlebot"))
                    {
                        tIRC.SendMsg("Confirmed: " + thisBet.BettersName + " Bet " + thisBet.BetAmount + " on " + thisBet.TurtlesName + " to " + thisBet.BetType);
                    }

                    //tIRC.SendCommand(".PRIVMSG #turtleracingalpha :/w turtleracingalpha this is a whisper with .");
                    //tIRC.SendCommand("/PRIVMSG #turtleracingalpha :/w turtleracingalpha this is a whisper with /");
                    //tIRC.SendCommand(":PRIVMSG #turtleracingalpha :/w turtleracingalpha this is a whisper with :");
                    //tIRC.SendMsg("/w turtleracingalpha this is a whisper with msg");

                    //Debug.Log("For <color=green>" + thisBet.BetAmount + "</color> at odds of " + thisBet.BetOdds);
                }
            }
        }
    }
Пример #10
0
	} //End.SendActionMessage()

	// Use this for initialization
	void Start()
	{
		IRC = this.GetComponent<TwitchIRC>();
		cultistGO = GameObject.Find ("Cultist");
		if (cultistGO)
			cultist = cultistGO.GetComponent<Cultist>();
		//IRC.SendCommand("CAP REQ :twitch.tv/tags"); //register for additional data such as emote-ids, name color etc.
		IRC.messageRecievedEvent.AddListener(OnChatMsgReceived);

		IRC.SendMsg ("!moobot poll close");
		string votes = "";
		foreach (string vote in voteOptions) {
			votes = votes + " " + vote;
		}
		IRC.SendMsg ("!moobot poll open w, s, a, d");
		InvokeRepeating ("PollResults", timer, timer);
	} //End.Start()
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeSinceLevelLoad > 1 && !hasPlacedAIBets)
        {
            TwitchChatExample ChatLink = gameObject.GetComponent <TwitchChatExample>();
            for (int i = 0; i <= 128; i++)
            {
                ChatLink.fakeMessage(TurtlesInTheRace[Random.Range(0, 10)].name);
            }
            hasPlacedAIBets = true;
        }


        if (Input.GetKeyDown(KeyCode.X))
        {
            foreach (GameObject eachTurtle in TurtlesInTheRace)
            {
                TurtleAI ti = eachTurtle.GetComponent <TurtleAI>();
                ti.BaseSpeed = 50;
            }
            TimeBetweenRaces = 2;
        }
        if (Input.GetKeyDown(KeyCode.S))
        { //start the race shortcut
            TimeBetweenRaces = 2;
        }

        if (TimeBetweenRaces - 9 < Time.timeSinceLevelLoad && BettingOpenDialog.activeInHierarchy == true)
        {
            AudioSource.PlayClipAtPoint(bellSound, Camera.main.transform.position);
            BettingClosedDialog.SetActive(true);
            BettingOpenDialog.SetActive(false);
            raceInfoDialog.SetActive(false);
        }
        if (TimeBetweenRaces - 6 < Time.timeSinceLevelLoad && isBettingOpen)
        {
            isBettingOpen = false;
        }

        if (TimeBetweenRaces / 2 < Time.timeSinceLevelLoad && !hasAucionCompleted)
        {
            TurtleAuctionManager.FinalizeAuction(this.gameObject);
        }
        if (TimeBetweenRaces < Time.timeSinceLevelLoad && !hasRaceStarted)
        {
            hasRaceStarted = true;
            RaceStartingTimerObject.SetActive(false);
            BettingClosedDialog.SetActive(false);
            RaceCam1.m_Speed = 1;
            //TimeBetweenRaces += Time.time; //this was causing extra delays
            BetManager.FinalizeOdds(this.gameObject);
        }
        else
        {
            RaceStartingTimer.text = Mathf.RoundToInt(TimeBetweenRaces - Time.timeSinceLevelLoad) + " Seconds";
        }
        if (hasRaceStarted && FinishLineCam.Priority != 16)
        {
            foreach (GameObject turtleRef in TurtlesInTheRace)
            {
                TurtleAI turlteScriptRef = turtleRef.GetComponent <TurtleAI>();

                /*if(BackHalfCam.Priority!=15 && turlteScriptRef.percentFinished > 0.5f){
                 *                      BackHalfCam.Priority = 15;
                 *              }*/
                if (turlteScriptRef.percentFinished > 0.9f)
                {
                    FinishLineCam.Priority = 16;
                }
            }
        }

        if (TurtleAI.HowManyTurtlesFinished == 10 && !hasRaceEnded)
        {
            hasRaceEnded = true;
            RaceResultsScreen.SetActive(true);
            BettingClosedDialog.SetActive(true);
            raceInfoDialog.SetActive(true);
            RaceResultsGUITextA.text = TurtleAI.RaceResultsColumn1 + "<nobr>";
            RaceResultsGUITextB.text = TurtleAI.RaceResultsColumn2 + "<nobr>";
            RaceResultsGuiTextC.text = TurtleAI.RaceResultsColumn3 + "<nobr>";

            timeRaceEnded = Time.timeSinceLevelLoad;
            int   totalTrueBets = 0;
            float totalPaidOut  = 0;
            foreach (BetData eachBet in CurrentRaceBets)
            {
                //Check for winning bets
                if (eachBet.BetType == "win")
                {
                    foreach (RaceResultData contestant in GuestManager.CurrentRaceresults)
                    {
                        if (contestant.FinishingPlace == 1 && contestant.TurtleName == eachBet.TurtlesName)
                        {
                            //They predicted this win!
                            eachBet.didBetComeTrue = true;
                            totalTrueBets++;
                        }
                    }
                }
                if (eachBet.BetType == "place")
                {
                    foreach (RaceResultData contestant in GuestManager.CurrentRaceresults)
                    {
                        if (contestant.TurtleName == eachBet.TurtlesName)
                        {
                            if (contestant.FinishingPlace == 1 || contestant.FinishingPlace == 2)
                            {
                                eachBet.didBetComeTrue = true;
                                totalTrueBets++;
                            }
                        }
                    }
                }
                if (eachBet.BetType == "show")
                {
                    foreach (RaceResultData contestant in GuestManager.CurrentRaceresults)
                    {
                        if (contestant.TurtleName == eachBet.TurtlesName)
                        {
                            if (contestant.FinishingPlace <= 3)
                            {
                                eachBet.didBetComeTrue = true;
                                totalTrueBets++;
                            }
                        }
                    }
                }

                foreach (GuestData eachGuest in GuestManager.AllGuests)
                {
                    if (eachGuest.guestName == eachBet.BettersName)
                    {
                        if (eachBet.didBetComeTrue)
                        {
                            //Pay them if the bet won.
                            float     amountToPay = eachBet.BetAmount * eachBet.BetOdds;
                            TwitchIRC tIRC        = GetComponent <TwitchIRC>();
                            if (eachBet.BetType == "place")
                            {
                                amountToPay = eachBet.BetAmount + OddsDisplay.CurrentTotalPlacePool * (eachBet.BetAmount / (OddsDisplay.CurrentTotalPlacePool / 2));
                                Debug.Log("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " to place of a pool of " + OddsDisplay.CurrentTotalPlacePool);
                                if (!eachGuest.guestName.Contains("turtlebot"))
                                {
                                    tIRC.SendMsg("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + "to place of a pool of " + OddsDisplay.CurrentTotalPlacePool);
                                }
                            }
                            if (eachBet.BetType == "win")
                            {
                                Debug.Log("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " at odds of " + eachBet.BetOdds);
                                if (!eachGuest.guestName.Contains("turtlebot"))
                                {
                                    tIRC.SendMsg("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " at odds of " + eachBet.BetOdds);
                                }
                            }
                            if (eachBet.BetType == "show")
                            {
                                amountToPay = eachBet.BetAmount + OddsDisplay.CurrentTotalShowPool * (eachBet.BetAmount / (OddsDisplay.CurrentTotalShowPool / 3));
                                Debug.Log("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " to show of a pool of " + OddsDisplay.CurrentTotalShowPool);
                                if (!eachGuest.guestName.Contains("turtlebot"))
                                {
                                    tIRC.SendMsg("Paying out " + amountToPay + " to " + eachGuest.guestName + " for betting " + eachBet.BetAmount + " on " + eachBet.TurtlesName + " to show of a pool of " + OddsDisplay.CurrentTotalShowPool);
                                }
                            }
                            eachGuest.guestCash += amountToPay;
                            totalPaidOut        += amountToPay;
                            float totalPaidIn = OddsDisplay.CurrentTotalPlacePool + OddsDisplay.CurrentTotalPot + OddsDisplay.CurrentTotalShowPool;
                            print("Total paid out = " + totalPaidOut + " Total paid in = " + totalPaidIn);
                        }
                    }
                }
            }
        }
        if (timeRaceEnded > 1)
        {
            if (RaceStartingTimerObject.activeInHierarchy != true)
            {
                RaceStartingTimerObject.SetActive(true);
            }
            RaceStartingTimer.text = Mathf.RoundToInt((timeRaceEnded + (TimeBetweenRaces / 4)) - Time.timeSinceLevelLoad) + " Seconds";
            //Debug.Log("Time race ended " + timeRaceEnded + "  Time between races " + TimeBetweenRaces + "  current time " + Time.time);
            if (Time.timeSinceLevelLoad > timeRaceEnded + (TimeBetweenRaces / 2))
            {
                GuestManager.SaveGuestData();
                print("restarting");
                SceneManager.LoadScene("Pachinko");
            }
        }
    }