Esempio 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();
        }