Example #1
0
        void ParserOnXdccList(object aSender, EventArgs <Model.Domain.Channel, string, string> aEventArgs)
        {
            if (aEventArgs.Value1.Parent == Server)
            {
                // dont send the same request to often
                _latestXdccListRequests.RemoveExpiredItems();
                if (_latestXdccListRequests.Contains(aEventArgs.Value2 + "@" + aEventArgs.Value3))
                {
                    double seconds = _latestXdccListRequests.GetMissingSeconds(aEventArgs.Value2 + "@" + aEventArgs.Value3);
                    _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") blocked for " + seconds + " seconds");
                    return;
                }

                var entry = _xdccListQueue.FirstOrDefault(x => x.User == aEventArgs.Value2);
                if (entry == null)
                {
                    _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") adding");
                    entry = new XdccListEntry(aEventArgs.Value2, aEventArgs.Value3);
                    _xdccListQueue.Add(entry);
                }
                else
                {
                    entry.IncreaseTime();
                    if (entry.Commands.All(s => s != aEventArgs.Value3))
                    {
                        _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") enqueuing");
                        entry.Commands.Enqueue(aEventArgs.Value3);
                    }
                    else
                    {
                        _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") skipping");
                    }
                }
            }
        }
        void ParserOnXdccList(object aSender, EventArgs<Model.Domain.Channel, string, string> aEventArgs)
        {
            if (aEventArgs.Value1.Parent == Server)
            {
                // dont send the same request to often
                _latestXdccListRequests.RemoveExpiredItems();
                if (_latestXdccListRequests.Contains(aEventArgs.Value2 + "@" + aEventArgs.Value3))
                {
                    double seconds = _latestXdccListRequests.GetMissingSeconds(aEventArgs.Value2 + "@" + aEventArgs.Value3);
                    _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") blocked for " + seconds + " seconds");
                    return;
                }

                var entry = _xdccListQueue.FirstOrDefault(x => x.User == aEventArgs.Value2);
                if (entry == null)
                {
                    _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") adding");
                    entry = new XdccListEntry(aEventArgs.Value2, aEventArgs.Value3);
                    _xdccListQueue.Add(entry);
                }
                else
                {
                    entry.IncreaseTime();
                    if (entry.Commands.All(s => s != aEventArgs.Value3))
                    {
                        _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") enqueuing");
                        entry.Commands.Enqueue(aEventArgs.Value3);
                    }
                    else
                    {
                        _log.Info("XdccList(" + aEventArgs.Value2 + ", " + aEventArgs.Value3 + ") skipping");
                    }
                }
            }
        }