Beispiel #1
0
        private async Task HandleClearMock(ChatMessage msg)
        {
            if (!CommandUtils.HasAdvancePermissions(msg.UserId))
            {
                await CommandUtils.SendAccessDenied(m_firehose, msg.ChannelId, msg.UserName);

                return;
            }

            // Clear all.
            m_mockDict.Clear();

            await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, "I'm not mocking anyone anymore. 😢", msg.IsWhisper);
        }
Beispiel #2
0
        private async Task HandleExit(ChatMessage msg)
        {
            if (!CommandUtils.HasAdvancePermissions(msg.UserId))
            {
                await CommandUtils.SendAccessDenied(m_firehose, msg);

                return;
            }
            await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"👋 Later! Powering down.", msg.IsWhisper);

            // Give the message time to send.
            await Task.Delay(1000);

            Environment.Exit(-1);
        }
Beispiel #3
0
        private async Task HandleEcho(ChatMessage msg)
        {
            if (!CommandUtils.HasAdvancePermissions(msg.UserId))
            {
                await CommandUtils.SendAccessDenied(m_firehose, msg.ChannelId, msg.UserName);

                return;
            }
            string body = CommandUtils.GetCommandBody(msg.Text);

            if (!String.IsNullOrWhiteSpace(body))
            {
                await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, body, msg.IsWhisper);
            }
        }
Beispiel #4
0
        private async Task HandleMockToggle(ChatMessage msg, bool isPrivate)
        {
            if (!CommandUtils.HasAdvancePermissions(msg.UserId))
            {
                await CommandUtils.SendAccessDenied(m_firehose, msg.ChannelId, msg.UserName);

                return;
            }

            // Find the user name.
            string userName = CommandUtils.GetSingleWordArgument(msg.Text);

            if (userName == null)
            {
                await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, "I need a user name.", true);

                return;
            }

            // Get the user id.
            int?userId = await MixerUtils.GetUserId(userName);

            if (!userId.HasValue || userName.Length == 0)
            {
                await CommandUtils.SendMixerUserNotFound(m_firehose, msg, userName);

                return;
            }

            // Update the map.
            bool removed = false;
            bool currentValue;

            if (m_mockDict.TryGetValue(userId.Value, out currentValue))
            {
                // Remove if it's the same toggle.
                if (currentValue == isPrivate)
                {
                    removed = true;
                    m_mockDict.TryRemove(userId.Value, out currentValue);
                }
                // Otherwise, toggle it
                else
                {
                    m_mockDict.TryUpdate(userId.Value, isPrivate, currentValue);
                    currentValue = isPrivate;
                }
            }
            else
            {
                // If they are not in the map, add them.
                m_mockDict.TryAdd(userId.Value, isPrivate);
                currentValue = isPrivate;
            }

            string output;

            if (removed)
            {
                output = $"I'm no longer mocking {await MixerUtils.GetProperUserName(userName)}. Lucky them.";
            }
            else
            {
                output = $"I'm now {(currentValue ? "privately" : "publically")} mocking {await MixerUtils.GetProperUserName(userName)} 😮";
            }
            await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, output, msg.IsWhisper);

            return;
        }