Esempio n. 1
0
        private async Task <string> FindOnlineFriends(List <int> friendUserIds)
        {
            string output       = "";
            bool   foundSomeone = false;

            foreach (int friendUserid in friendUserIds)
            {
                if (foundSomeone)
                {
                    output += "; ";
                }

                List <int> channelIds = CreeperCarl.GetActiveChannelIds(friendUserid);
                if (channelIds != null && channelIds.Count > 0)
                {
                    foundSomeone = true;
                    output      += $"{await MixerUtils.GetUserName(friendUserid)} is currently watching ";
                    output      += await CommandUtils.FormatChannelIds(channelIds, 50);
                }
            }
            if (!foundSomeone)
            {
                output = "None of your friends are currently online.";
            }
            return(output);
        }
Esempio n. 2
0
        static public async Task <int> GlobalWhisper(IFirehose firehose, int userId, string userName, string message)
        {
            List <int> channelIds = CreeperCarl.GetActiveChannelIds(userId);

            if (channelIds == null)
            {
                return(0);
            }
            else
            {
                // Whisper them the message in all of the channels.
                int successCount = 0;
                foreach (int channelId in channelIds)
                {
                    if (await firehose.SendWhisper(channelId, userName, message))
                    {
                        successCount++;
                    }
                }
                return(successCount);
            }
        }
Esempio n. 3
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);
            }
        }