Ejemplo n.º 1
0
    private void ListenGamble(RestreamChatMessage newMessage)
    {
        string message = newMessage.Message;

        if (!message.ToLower().StartsWith("gamble"))
        {
            return;
        }
        string[] tokens = message.Split(' ');
        if (tokens.Length < 3)
        {
            return;
        }

        long  moneyGambled;
        float timeEstimated;

        if (!long.TryParse(tokens[1], out moneyGambled))
        {
            return;
        }
        if (!float.TryParse(tokens[2], out timeEstimated))
        {
            return;
        }

        _linkedBank.Use(newMessage.UserID, moneyGambled);
        _gambles.Add(new UserGamble()
        {
            _userId = newMessage.UserID, _gambledValue = moneyGambled, _gameTime = timeEstimated
        });
    }
    private void MessageToObjectPop(RestreamChatMessage newMessage)
    {
        string trimMessage = "";
        string message     = newMessage.Message;

        int messageIndex = message.IndexOf(_prefixMessage);

        if (messageIndex > -1)
        {
            trimMessage = message.Substring(messageIndex + _prefixMessage.Length);
            if (_linkedBank.Use(newMessage.UserID, _messageCost))
            {
                _onMessageBought.Invoke(_messageCost, trimMessage, newMessage);
            }
        }

        int warningIndex = message.IndexOf(_prefixWarning);

        if (warningIndex > -1)
        {
            trimMessage = message.Substring(warningIndex + _prefixWarning.Length);
            if (_linkedBank.Use(newMessage.UserID, _warningCost))
            {
                _onMessageBought.Invoke(_warningCost, trimMessage, newMessage);
            }
        }
    }
Ejemplo n.º 3
0
 private void DebugDisplay(string arg0, long arg1, GameObject arg2, RestreamChatMessage msg)
 {
     if (_debug)
     {
         Debug.Log(string.Format("Object bought({0}) for {1}$ by {2} ", arg0, arg1, msg.UserName), arg2);
     }
 }
 private void DebugDisplayWarning(long arg1, string msg, RestreamChatMessage arg2)
 {
     if (_debug)
     {
         Debug.Log(string.Format("Bought warning to player({0}): {1}", arg1, msg));
     }
 }
Ejemplo n.º 5
0
 private void DisplayMessage(RestreamChatMessage messages)
 {
     if (_useDebug)
     {
         Debug.Log("> " + messages.Message);
     }
 }
    private string GetFileName(ref RestreamChatMessage message)
    {
        string fileTitle = message.Date + "_" + message.When + "_" + message.UserName;
        Regex  rgx       = new Regex("[^a-zA-Z0-9_]");

        fileTitle = rgx.Replace(fileTitle, "");
        return(fileTitle + ".txt");
    }
Ejemplo n.º 7
0
    private void UserMessageDetected(RestreamChatMessage newMessage)
    {
        UserIdentifier userId = newMessage.UserID;

        if (UserNotRegistered(userId.GetID()))
        {
            CreateBankAccount(userId, minimumCash);
        }
    }
Ejemplo n.º 8
0
 public void CountPlatfomrInteraction(RestreamChatMessage winnerMessage)
 {
     foreach (PlatformToCount point in _messagesCount)
     {
         if (winnerMessage.Platform == point._platform)
         {
             point.AddPoints(1);
         }
     }
 }
Ejemplo n.º 9
0
 public void AddDisplayedNameFromMessage(RestreamChatMessage msg)
 {
     if (!msg.Message.StartsWith(m_startTag))
     {
         return;
     }
     AddDisplayedName(
         msg.UserID.GetID(),
         msg.Message.Substring(m_startTag.Length));
 }
 public void AddPointsToWinners(RestreamChatMessage winnerMessage)
 {
     foreach (PlatformToPoint point in _pointsListener)
     {
         if (winnerMessage.Platform == point._platform)
         {
             point.AddPoints(1);
         }
     }
 }
Ejemplo n.º 11
0
 public void SetMessage(RestreamChatMessage message)
 {
     if (_philosoraptor != null && message != null)
     {
         string[] tokens = message.Message.Split('|');
         if (tokens.Length == 3 && tokens[0].ToLower().Contains("philosoraptor"))
         {
             _philosoraptor.SetText(tokens[1], tokens[2]);
         }
     }
 }
    public void BanThisUserFromOneLine(string oneliner)
    {
        bool isValide;
        RestreamChatMessage msg;

        RestreamChatMessage.CreateFromOneLiner(oneliner, out isValide, out msg);
        if (isValide)
        {
            BanThisUser(msg);
        }
    }
Ejemplo n.º 13
0
 private Score GetPlayer(RestreamChatMessage answer)
 {
     for (int i = 0; i < _top10.Count; i++)
     {
         if (_top10[i].playerName == answer.UserName && _top10[i].playerPlatform == answer.Platform)
         {
             return(_top10[i]);
         }
     }
     return(null);
 }
Ejemplo n.º 14
0
 public static string GetDisplayNameOf(ref RestreamChatMessage msg)
 {
     if (m_instance == null)
     {
         return(msg.Message);
     }
     if (m_instance.m_displayNameDB.ContainsKey(msg.UserID.GetID()))
     {
         return(m_instance.m_displayNameDB[msg.UserID.GetID()]);
     }
     return(msg.Message);
 }
    public void PushIfNotBan(RestreamChatMessage message)
    {
        bool isBanUser = IsUserBan(message);

        if (isBanUser)
        {
            m_fromBanUser.Invoke(message);
        }
        else
        {
            m_fromAuthorizedUser.Invoke(message);
        }
    }
    private void CheckForGoodAnswer(RestreamChatMessage newMessage)
    {
        float userAnswer = 0;

        if (float.TryParse(newMessage.Message, out userAnswer))
        {
            if (userAnswer == _answer)
            {
                _onWinnerDetected.Invoke(newMessage);
                SetNewEquation();
            }
        }
    }
    public void SetWithNewMessageReceived(RestreamChatMessage message)
    {
        RestreamChatMessage tmpNew = null, tmpOld = m_lastMessage.GetStoredMessage();

        m_lastMessage.SetWith(message);
        tmpNew = tmpOld;
        for (int i = 0; i < m_previousMessage.Length; i++)
        {
            tmpOld = m_previousMessage[i].GetStoredMessage();
            m_previousMessage[i].SetWith(tmpNew);
            tmpNew = tmpOld;
        }
    }
Ejemplo n.º 18
0
 public void AddNewUserIfNew(RestreamChatMessage user)
 {
     if (!m_userDummiesObj.IsRegistered(ref user))
     {
         GameObject             created = GameObject.Instantiate(m_prefabDummy);
         DummyCharacter_AngleMs script  = created.GetComponent <DummyCharacter_AngleMs>();
         m_userDummiesObj.Store(ref user, script);
         AngleDistanceMoveList moves = new AngleDistanceMoveList();
         m_userDummiesPath.Store(ref user, moves);
         script.m_startPoint   = m_startPoint;
         script.m_generalColor = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value, 1);
     }
 }
    public void TryToTranslateAsKeyStroke(RestreamChatMessage message)
    {
        bool   executed = false;
        string msg      = message.Message;

        if (msg.ToLower().StartsWith(m_startWith))
        {
            string toTranslate = msg.Substring(0 + m_startWith.Length);
            int    antispam    = toTranslate.LastIndexOf(m_antiSpam);
            if (antispam > -1)
            {
                toTranslate = toTranslate.Substring(0, antispam);
            }
            m_lastReceived = toTranslate;
            for (int i = 0; i < m_actionsPossible.Count; i++)
            {
                if (toTranslate.Trim().ToLower()
                    == m_actionsPossible[i].m_exactTextToShortTrigger.ToLower().Trim() ||
                    toTranslate.Trim().ToLower()
                    == m_actionsPossible[i].m_exactTextToLongTrigger.ToLower().Trim())
                {
                    executed = true;
                    foreach (var item in m_server.GetJavaOMISelected())
                    {
                        if (m_actionsPossible[i].m_sendType == SendType.Shortcut)
                        {
                            item.SendShortcutCommands(m_actionsPossible[i].m_jomiRequest);
                        }
                        if (m_actionsPossible[i].m_sendType == SendType.Command)
                        {
                            item.SendRawCommand(m_actionsPossible[i].m_jomiRequest);
                        }
                        if (m_actionsPossible[i].m_sendType == SendType.Text)
                        {
                            item.PastText(m_actionsPossible[i].m_jomiRequest);
                        }
                    }
                }
            }

            if (executed)
            {
                m_executed.Invoke(toTranslate);
            }
            else
            {
                m_failToExecute.Invoke(toTranslate);
            }
        }
    }
Ejemplo n.º 20
0
    // Use this for initialization
    public void AddGoodAnswer(RestreamChatMessage answer)
    {
        Score playerScore = GetPlayer(answer);

        if (playerScore == null)
        {
            playerScore = new Score()
            {
                playerName = answer.UserName, playerPlatform = answer.Platform
            };
            _top10.Add(playerScore);
        }
        playerScore.score++;
        _top10            = _top10.OrderByDescending(p => p.score).Take(10).ToList();
        _topTenDebug.text = GetListOfBestPlayers();
    }
    public void TryToPush(RestreamChatMessage message)
    {
        int  credit    = GetUserCredit(message.UserID);
        bool isSpammer = credit <= 0;

        if (isSpammer)
        {
            m_onRefused.Invoke(message);
        }
        else
        {
            m_onValidate.Invoke(message);
        }
        credit -= m_consumedByMessage;
        SetUserCredit(message.UserID, credit);
    }
Ejemplo n.º 22
0
    private void MessageToObjectPop(RestreamChatMessage newMessage)
    {
        // Is prefix of object present ?

        string message = newMessage.Message;

        for (int i = 0; i < _buyablePrefabs.Length; i++)
        {
            int messageIndex = message.IndexOf(_buyablePrefabs[i]._idName);
            if (messageIndex > -1)
            {
                //arguments = trimMessage.Substring(messageIndex + _buyablePrefabs[i]._idName.Length);
                if (_linkedBank.Use(newMessage.UserID, _buyablePrefabs[i]._cost))
                {
                    _onPrefabBought.Invoke(_buyablePrefabs[i]._idName, _buyablePrefabs[i]._cost, _buyablePrefabs[i]._prefab, newMessage);
                }
            }
        }
    }
Ejemplo n.º 23
0
    //public Regex add = new Regex("^add.*");
    public void TryToInterpertMessage(RestreamChatMessage userMsg)
    {
        AddNewUserIfNew(userMsg);
        string msg        = userMsg.Message.ToLower().Trim();
        bool   hasChanged = false;

        if (set.IsMatch(msg))
        {
            string[] tokens = msg.Split(' ');
            int      distance;
            int      angle;
            int      index;
            if (int.TryParse(tokens[1], out index) && int.TryParse(tokens[2], out angle) && int.TryParse(tokens[3], out distance))
            {
                GetPath(userMsg).Set(index, new AngleDistanceMove(angle, distance / 100f), true);

                hasChanged = true;
            }
        }
        else if (clear.IsMatch(msg))
        {
            GetPath(userMsg).Clear();

            hasChanged = true;
        }
        else if (add.IsMatch(msg))
        {
            string[] tokens = msg.Split(' ');
            int      distance;
            int      angle;
            if (int.TryParse(tokens[1], out angle) && int.TryParse(tokens[2], out distance))
            {
                GetPath(userMsg).Add(new AngleDistanceMove(angle, distance / 100f));
                hasChanged = true;
            }
        }
        if (hasChanged)
        {
            RefreshUser(userMsg);
        }
    }
    public void DisplayLagOf(RestreamChatMessage message)
    {
        string msg = message.Message;
        Regex  r   = new Regex("(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)");
        Match  m   = r.Match(msg);

        m_user.text = message.UserName;
        if (!string.IsNullOrEmpty(m.Value))
        {
            string[] tokens = m.Value.Split(':');
            DateTime d      = message.GetWhenAsDateTime();
            DateTime md     = new DateTime(d.Year, d.Month, d.Day, int.Parse(tokens[0]), int.Parse(tokens[1]), int.Parse(tokens[2]));
            m_userLag.text  = "" + Mathf.Abs((float)(m_date - md).TotalMilliseconds / 1000f);
            m_userTime.text = "" + md.ToString("HH:mm:ss");
        }
        else
        {
            m_userLag.text  = "" + Mathf.Abs((float)(m_date - message.GetWhenAsDateTime()).TotalMilliseconds / 1000f);
            m_userTime.text = "" + m_date.ToString("HH:mm:ss");
        }
    }
Ejemplo n.º 25
0
    public void TryToPush(RestreamChatMessage message)
    {
        string messageToFilter = m_ignoreCase? message.Message.ToLower(): message.Message;

        bool oneIsNotThere = false;
        bool oneIsThere    = false;

        for (int i = 0; i < m_lookingFor.Length; i++)
        {
            string toLook = m_ignoreCase ? m_lookingFor[i].ToLower():m_lookingFor[i];
            bool   isInIt = messageToFilter.IndexOf(toLook) > -1;
            if (isInIt)
            {
                oneIsThere = true;
            }
            else
            {
                oneIsNotThere = true;
            }
        }

        if (m_filterType == SearchType.All && !oneIsNotThere)
        {
            m_onAllowed.Invoke(message);
        }

        else if (m_filterType == SearchType.AtLeastOne && oneIsThere)
        {
            m_onAllowed.Invoke(message);
        }
        else if (m_filterType == SearchType.NoneOf && !oneIsThere)
        {
            m_onAllowed.Invoke(message);
        }
        else
        {
            m_onRefused.Invoke(message);
        }
    }
 public void SaveIfRequested(RestreamChatMessage message)
 {
     try
     {
         if (!m_isOn.isOn)
         {
             return;
         }
         if (string.IsNullOrEmpty(m_directoryPath.text))
         {
             return;
         }
         if (!Directory.Exists(m_directoryPath.text))
         {
             Directory.CreateDirectory(m_directoryPath.text);
         }
         File.WriteAllText(m_directoryPath.text + "\\" + GetFileName(ref message), message.GetAsOneLiner());
     }
     catch (Exception e) {
         Debug.LogWarning(GetFileName(ref message) + "\n" + e.StackTrace);
     }
 }
 private void TriggerUnityEventAtUpdate(RestreamChatMessage newMessage)
 {
     m_receivedToPushOnUpdate.Enqueue(newMessage);
 }
    private bool IsUserBan(RestreamChatMessage message)
    {
        string id = message.UserID.GetID().Trim();

        return(m_listOfBanned.ContainsKey(id));
    }
 public void BanThisUser(RestreamChatMessage message)
 {
     BanThisUserId(message.UserID.GetID());
 }
Ejemplo n.º 30
0
 public void AddMessageToApi(RestreamChatMessage message)
 {
     AddMessagesToApi(message);
 }