Ejemplo n.º 1
0
        public async Task <Response> Handle(Message message)
        {
            if (!message.Addressed)
            {
                return(null);
            }
            var match = Regex.Match(message.Text, @"^literal (.+)$", RegexOptions.IgnoreCase);

            if (!match.Success)
            {
                return(null);
            }
            var trigger = match.Groups[1].Value;

            var dataStore = await _dataStoreProvider.GetDataStore("Factoids");

            var values = await dataStore.GetAll(trigger);

            if (!values.Any())
            {
                return(message.Respond($"Sorry, {message.From.Mention}, but I don't know about \"{trigger}.\""));
            }

            if (values.Count() > 10 || values.Sum(x => x.Value.Length) > 500)
            {
                var url = await _dataDumper.Dump("Factoids", trigger);

                return(message.Respond($"{trigger}: {url}"));
            }

            var result = String.Join(", ", values.Select(x => $"(#{x.Id}) {x.Value}"));

            return(message.Respond($"{trigger}: {result}"));
        }
Ejemplo n.º 2
0
        public async Task <Response> Handle(Message message)
        {
            if (!message.Addressed)
            {
                return(null);
            }
            var match = Regex.Match(message.Text, @"^list var ([a-z][a-z0-9_-]*)", RegexOptions.IgnoreCase);

            if (!match.Success)
            {
                return(null);
            }

            var dataStore = await _dataStoreProvider.GetDataStore("Variables");

            var variable = match.Groups[1].Value.ToLowerInvariant();
            var values   = await dataStore.GetAll(variable);

            if (!values.Any())
            {
                return(message.Respond($"There's no such variable, {message.From.Mention}!"));
            }

            if (values.Count() > 10 || values.Sum(x => x.Value.Length) > 500)
            {
                var url = await _dataDumper.Dump("Variables", variable);

                return(message.Respond($"${variable}: {url}"));
            }

            var list = String.Join(", ", values.Select(v => $"(#{v.Id}) {v.Value}"));

            return(message.Respond($"{variable}: {list}"));
        }
        public void DumpBarsFromCurrentPeriod(ITradingObject tradingObject)
        {
            if (tradingObject == null)
            {
                throw new ArgumentNullException();
            }

            if (_dumper != null)
            {
                Bar bar = GetBarOfTradingObjectForCurrentPeriod(tradingObject);
                _dumper.Dump(tradingObject);
            }
        }