コード例 #1
0
    protected override void OnMessageReceived(string userNickName, string userColorCode, string text)
    {
        if (!text.StartsWith("!") || text.Equals("!"))
        {
            return;
        }
        text = text.Substring(1);

        string[] split     = text.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        string   textAfter = split.Skip(1).Join();

        if (text.Equals("cancel", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            _coroutineCanceller.SetCancel();
            return;
        }
        else if (text.Equals("stop", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            _coroutineCanceller.SetCancel();
            _coroutineQueue.CancelFutureSubcoroutines();
            return;
        }
        else if (text.Equals("manual", StringComparison.InvariantCultureIgnoreCase) ||
                 text.Equals("help", StringComparison.InvariantCultureIgnoreCase))
        {
            _ircConnection.SendMessage("!{0} manual [link to module {0}'s manual] | Go to {1} to get the vanilla manual for KTaNE", UnityEngine.Random.Range(1, 100), TwitchPlaysService.urlHelper.VanillaManual);
            _ircConnection.SendMessage("!{0} help [commands for module {0}] | Go to {1} to get the command reference for TP:KTaNE (multiple pages, see the menu on the right)", UnityEngine.Random.Range(1, 100), TwitchPlaysService.urlHelper.CommandReference);
            return;
        }
        else if (text.StartsWith("bonusscore", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            if (split.Length < 3)
            {
                return;
            }
            string playerrewarded = split[1];
            if (!int.TryParse(split[2], out int scorerewarded))
            {
                return;
            }
            if (UserAccess.HasAccess(userNickName, AccessLevel.SuperUser, true))
            {
                _ircConnection.SendMessage(TwitchPlaySettings.data.GiveBonusPoints, split[1], split[2], userNickName);
                Color usedColor = new Color(.31f, .31f, .31f);
                leaderboard.AddScore(playerrewarded, usedColor, scorerewarded);
            }
            return;
        }
        else if (text.StartsWith("reward", StringComparison.InvariantCultureIgnoreCase))
        {
            if (!IsAuthorizedDefuser(userNickName))
            {
                return;
            }
            if (UserAccess.HasAccess(userNickName, AccessLevel.SuperUser, true))
            {
                moduleCountBonus = Int32.Parse(split[1]);
                TwitchPlaySettings.SetRewardBonus(moduleCountBonus);
            }
        }
        else if (text.Equals("timemode", StringComparison.InvariantCultureIgnoreCase))
        {
            if (UserAccess.HasAccess(userNickName, AccessLevel.Mod, true))
            {
                OtherModes.toggleTimedMode();
                _ircConnection.SendMessage(OtherModes.timedModeCheck() ? "Time Mode Enabled" : "Time Mode Disabled");
            }
        }
        else if (text.StartsWith("rank", StringComparison.InvariantCultureIgnoreCase))
        {
            Leaderboard.LeaderboardEntry entry = null;
            if (split.Length > 1)
            {
                int desiredRank;
                switch (split.Length)
                {
                case 3 when split[1].Equals("solo", StringComparison.InvariantCultureIgnoreCase) && int.TryParse(split[2], out desiredRank):