Ejemplo n.º 1
0
        public Sonequa(ILogger <Sonequa> logger, SonequaSettings options)
        {
            _logger  = logger;
            _options = options;

            connectionCredentials = new ConnectionCredentials(_options.BotUsername, _options.BotToken);

            _logger.LogInformation("use SonequaWebUrl:" + _options.SonequaWebUrl);

            connection = new HubConnectionBuilder()
                         .WithUrl(_options.SonequaWebUrl)
                         .Build();

            connection.Closed += async error =>
            {
                await Task.Delay(new Random().Next(0, 5) * 1000);

                await connection.StartAsync();
            };

            var sentimentProcessor = new ProcessorCognitive(
                new AzureKeyCredential(options.CognitiveAzureKey),
                new Uri(options.CognitiveEndPoint)
                );

            _sentiment = new Sentiment.Sentiment(
                sentimentProcessor
                );
        }
 protected int GetReflectionHistoryLength(SonequaBot.Sentiment.Sentiment sentiment)
 {
     return(GetReflectionHistory(sentiment).GetAll().Count);
 }
 protected SentimentHistory GetReflectionHistory(SonequaBot.Sentiment.Sentiment sentiment)
 {
     return((SentimentHistory)typeof(SonequaBot.Sentiment.Sentiment)
            .GetField("_history", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(sentiment));
 }