示例#1
0
        private List <Audio> GetStorageFiles(Options options)
        {
            var parts = options.Source.Replace("gs://", "").Split('/');

            if (parts.Length < 2)
            {
                return(new List <Audio>());
            }

            string bucket = $"{string.Join('/', parts.Take(parts.Length - 1))}";
            string name   = parts[parts.Length - 1];

            if (!name.Contains("*"))
            {
                return new List <Audio>
                       {
                           new Audio(options.Source, GetOutputFile(options, name), RecognitionAudio.FromStorageUri(options.Source))
                       }
            }
            ;

            var storageClient = StorageClient.Create(GoogleCredential.FromFile(options.KeyPath));

            string[] fileNames = storageClient.ListObjects(bucket).Select(f => f.Name).ToArray();

            WildCard wildCard = new WildCard(name, RegexOptions.IgnoreCase);

            return(fileNames
                   .Where(fileName => !fileName.EndsWith("/") && wildCard.IsMatch(fileName))
                   .Select(fileName =>
            {
                string source = $"gs://{bucket}/{fileName}";
                return new Audio(source, GetOutputFile(options, fileName), RecognitionAudio.FromStorageUri(source));
            }).ToList());
        }
示例#2
0
        protected override void PrivateHandle(UserInfo info, List <string> args)
        {
            IEnumerable <UserPerChannelInfo> whoList;
            var filterInvisible = true;

            if (!info.PassAccepted)
            {
                IrcDaemon.Replies.SendPasswordMismatch(info);
                return;
            }

            ChannelInfo channel;
            var         mask = string.Empty;

            if (args.Count < 1 || args[0] == "0")
            {
                whoList = IrcDaemon.Nicks.SelectMany(n => n.Value.UserPerChannelInfos);
            }
            else if (args.Count > 0 && IrcDaemon.Channels.TryGetValue(args[0], out channel))
            {
                whoList = channel.UserPerChannelInfos.Values;
                if (!channel.UserPerChannelInfos.ContainsKey(info.Nick))
                {
                    filterInvisible = false;
                }
            }
            else
            {
                mask = args[0];
                var wildCard = new WildCard(mask, WildcardMatch.Anywhere);
                whoList = IrcDaemon.Nicks.Values.Where(u => wildCard.IsMatch(u.Usermask)).SelectMany(n => n.UserPerChannelInfos);
            }

            if (filterInvisible)
            {
                whoList = whoList.Where(w => !w.UserInfo.Modes.Exist <ModeInvisible>());
            }

            if (args.Count > 1 && args[1] == "o")
            {
                whoList = whoList.Where(w => w.UserInfo.Modes.Exist <ModeOperator>() || w.UserInfo.Modes.Exist <ModeLocalOperator>());
            }

            foreach (var who in whoList)
            {
                IrcDaemon.Replies.SendWhoReply(info, who);
            }

            IrcDaemon.Replies.SendEndOfWho(info, mask);
        }
示例#3
0
 public void IsMatchMultiPatternStaticTest()
 {
     IsMatchSinglePatternTest((input, pattern) => WildCard.IsMatch(input, pattern, WildCardOptions.MultiPattern));
     IsMatchMultiPatternTest((input, pattern) => WildCard.IsMatch(input, pattern, WildCardOptions.MultiPattern));
 }
示例#4
0
 public void IsMatchStaticTest()
 {
     IsMatchSinglePatternTest((input, pattern) => WildCard.IsMatch(input, pattern));
     IsMatchSinglePatternOnlyTest((input, pattern) => WildCard.IsMatch(input, pattern));
 }