示例#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
                );
        }
示例#2
0
        public Sonequa(ILogger <Sonequa> logger, SonequaSettings options, SentimentAnalysisService sentimentAnalysisService)
        {
            _logger  = logger;
            _options = options;
            _sentimentAnalysisService = sentimentAnalysisService;

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

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

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

                await connection.StartAsync();
            };
        }