Exemplo n.º 1
0
        private async Task HandleAddOrRemove(ChatMessage msg, bool add)
        {
            // Get the target they want to add
            string friendUserName = CommandUtils.GetSecondSingleWordArgument(msg.Text);

            if (friendUserName == null)
            {
                await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"Who are we {(add ? "adding" : "removing")} as a friend? Specify a user name after the command.", true);

                return;
            }
            int?friendUserId = await MixerUtils.GetUserId(friendUserName);

            if (!friendUserId.HasValue)
            {
                await CommandUtils.SendMixerUserNotFound(m_firehose, msg, friendUserName);

                return;
            }

            // Add the friend to their list
            bool addedToFriends   = UpdateList(msg.UserId, friendUserId.Value, add, true);
            bool addedToFollowers = UpdateList(friendUserId.Value, msg.UserId, add, false);
            await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"You're {(add ? (!addedToFriends && !addedToFollowers ? "still" : "now") : "no longer")} friends with @{await MixerUtils.GetProperUserName(friendUserName)}{(add ? "! ❤️" : ". 💔")}", true);

            SaveSettings();
        }
Exemplo n.º 2
0
        private async Task HandleFindCommand(ChatMessage msg)
        {
            string userName = CommandUtils.GetSingleWordArgument(msg.Text);

            if (userName == null)
            {
                await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"Find who? 🔍 You must specify a user name to find!", CommandUtils.ShouldForceIsWhisper(msg));

                return;
            }

            int?userId = await MixerUtils.GetUserId(userName);

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

                return;
            }

            // Find the user.
            List <int> channelIds = CreeperCarl.GetActiveChannelIds(userId.Value);

            if (channelIds == null)
            {
                await CommandUtils.SendCantFindUser(m_firehose, msg, userName);
            }
            else
            {
                // Go async to get the names.
                var _ignored = Task.Run(async() =>
                {
                    // Build the string.
                    string output = $"I found {await MixerUtils.GetProperUserName(userName)} in the following channels: " + await CommandUtils.FormatChannelIds(channelIds, 250) + ".";
                    await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, output, CommandUtils.ShouldForceIsWhisper(msg));
                }).ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        private async Task HandleSummon(ChatMessage msg)
        {
            string summonUserName = CommandUtils.GetSingleWordArgument(msg.Text);

            if (summonUserName == null)
            {
                await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"Let me know who you want so summon. Give me a user name after the command.", msg.IsWhisper);

                return;
            }
            string channelName = await MixerUtils.GetChannelName(msg.ChannelId);

            if (channelName == null)
            {
                await CommandUtils.SendMixerUserNotFound(m_firehose, msg, summonUserName, true);

                return;
            }

            // Get the summon user's id.
            int?actionReceiverId = await MixerUtils.GetUserId(summonUserName);

            if (!actionReceiverId.HasValue)
            {
                await CommandUtils.SendCantFindUser(m_firehose, msg, summonUserName);

                return;
            }

            // Make sure they are friends, otherwise we don't want to do this.
            if (!(await CommandUtils.CheckForMutualFriendsAndMessageIfNot(m_firehose, msg, actionReceiverId.Value, "summon")))
            {
                return;
            }

            // Check to see if the user is running the extension.
            //if (await CheckIfUserHasAnActiveExtension(summonUserName))
            //{
            //    // The user has an active extension
            //    if (await PostSummonToExtension(summonUserName, msg.UserName, channelName))
            //    {
            //        await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"I send an extension summon to {summonUserName}", msg.IsWhisper);
            //    }
            //    else
            //    {
            //        await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"That's not right... I failed to send extension summon to {summonUserName}.", msg.IsWhisper);
            //    }
            //}
            //else
            //{
            // The user doesn't have the extension! Whisper them.
            string properChannelName = await MixerUtils.GetProperUserName(channelName);

            int whispers = await CommandUtils.GlobalWhisper(m_firehose, summonUserName, $"{msg.UserName} summons you to @{properChannelName}'s channel! https://mixer.com/{properChannelName}");

            if (whispers == 0)
            {
                await CommandUtils.SendCantFindUser(m_firehose, msg, summonUserName);
            }
            else
            {
                await CommandUtils.SendResponse(m_firehose, msg.ChannelId, msg.UserName, $"I summoned {await MixerUtils.GetUserName(actionReceiverId.Value)} in {whispers} channel{(whispers > 1 ? "s" : "")}.", msg.IsWhisper);
            }
            //}
        }
Exemplo n.º 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;
        }