public void ConfigureServices(IServiceCollection services) { #region Echoer Bot var echoBotOptions = new BotOptions <EchoerBot>(); Configuration.GetSection("EchoerBot").Bind(echoBotOptions); services.AddTelegramBot(echoBotOptions) .AddUpdateHandler <TextMessageEchoer>() .Configure(); services.AddTask <BotUpdateGetterTask <EchoerBot> >(); #endregion #region Greeter Bot services.AddTelegramBot <GreeterBot>(Configuration.GetSection("GreeterBot")) .AddUpdateHandler <StartCommand>() .AddUpdateHandler <PhotoForwarder>() .AddUpdateHandler <HiCommand>() .Configure(); services.AddTask <BotUpdateGetterTask <GreeterBot> >(); #endregion }
public InvestingService(IInvestmentRepository investmentRepository, IStockRepository stockRepository, IOptions <BotOptions> options) { _investmentRepository = investmentRepository; _stockRepository = stockRepository; _options = options.Value; }
private static IHost GetHost() => new HostBuilder() .ConfigureHostConfiguration(builder => { builder.AddEnvironmentVariables(); }) .ConfigureAppConfiguration((context, builder) => { builder.AddJsonFile("appsettings.json", false, true) .AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", true, true); }) .ConfigureLogging((context, builder) => { builder.AddConfiguration(context.Configuration); }) .ConfigureServices((context, services) => { services.Configure <DataOptions>(context.Configuration.GetSection(nameof(DataOptions))); services.AddSingleton <DataContext>(); var botOptions = new BotOptions(); context.Configuration.GetSection(nameof(BotOptions)).Bind(botOptions); services.AddSingleton <ITelegramBotClient>(new TelegramBotClient(botOptions.Token)); services.AddSingleton <IUpdateHandler, UpdateHandler>(); services.AddHostedService <TelegramHostedService>(); }) .Build();
public static string GetSubmissionBotShowCommand(BotOptions options, uint gameID) { StringBuilder builder = new StringBuilder(options.SubmissionBotShowCommand); builder.Replace("{{id}}", gameID.ToString()); return(builder.ToString()); }
public DanglingQuestionsAutoPurgeWorker(IServiceProvider serviceProvider, IOptions <BotOptions> options, ILogger <DanglingQuestionsAutoPurgeWorker> logger) { _serviceProvider = serviceProvider; _options = options.Value; _logger = logger; }
public StatsCommandModule( IOptions <BotOptions> options, CommandQueue commandQueue) { _options = options.Value; _commandQueue = commandQueue; }
/// <summary> /// Optional override to create listeners (like tcp, http) for this service instance. /// </summary> /// <returns>The collection of listeners.</returns> protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners() { this.configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .Build(); this.botOptions = this.configuration.GetSection("Bot").Get <BotOptions>(); this.bot = new Bot(this.botOptions, this.logger, this.Context); var serviceReplicaListeners = new List <ServiceReplicaListener>(); foreach (string endpointName in new[] { "ServiceEndpoint", "SignalingPort", "LocalEndpoint" }) { serviceReplicaListeners.Add(new ServiceReplicaListener( serviceContext => new HttpSysCommunicationListener(serviceContext, endpointName, (url, listener) => { ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting web listener on {url}"); return(this.CreateHueBotWebHost(url)); }), endpointName)); } return(serviceReplicaListeners.ToArray()); }
public TelegramBotService(ILogger <TelegramBotService> logger, IOptions <BotOptions> botOptions) { _logger = logger; _botOptions = botOptions.Value; _client = new TelegramBotClient(_botOptions.Token); }
public AdminModule( ILogger<AdminModule> logger, IOptions<BotOptions> options) { _logger = logger; _options = options.Value; }
public BankingModule(IBankingService bankingService, IInvestingService investingService, IOptions <BotOptions> options) { _bankingService = bankingService; _investingService = investingService; _options = options.Value; }
/// <summary> /// DI constructor /// </summary> public SecurityController(IOptions <BotOptions> config, IDirectLineRestService directLineRestClient, ILogger <SecurityController> logger) { _config = config.Value; _directLineRestClient = directLineRestClient; _logger = logger; }
public static ChatUserContext FromClaims(IEnumerable <Claim> claims, BotOptions config) { List <Claim> claimsList = claims.ToList(); //Get id string id = UserHelper.GetBestClaimValue("id", claimsList, config.ClaimsId, true); //Get name string firstName = UserHelper.GetBestClaimValue("firstName", claimsList, config.ClaimsFirstName, true); string lastName = UserHelper.GetBestClaimValue(claimsList, config.ClaimsLastName); //Get role string role = UserHelper.GetBestClaimValue(claimsList, config.ClaimsRole); ChatUserRole roleEnum = ChatUserRole.Consumer; if (!string.IsNullOrEmpty(role) && config.ClaimsRoleAdminValues.Contains(role)) { roleEnum = ChatUserRole.Admin; } UserRoleCache.UserRoles[$"dl_{id}"] = roleEnum; var userContext = new ChatUserContext() { Id = $"dl_{id}", Name = $"{firstName} {lastName}", Role = roleEnum }; return(userContext); }
private Dictionary <string, string> CreateCertificateNameMap(BotOptions botOptions) { var certificateNameMap = new Dictionary <string, string>(); if (string.IsNullOrEmpty(botOptions.UserAppId)) { throw new Exception("User app id not found."); } else { certificateNameMap.Add(botOptions.UserAppId, botOptions.UserAppCertName); } if (string.IsNullOrEmpty(botOptions.AuthorAppId)) { throw new Exception("Author app id not found."); } else { certificateNameMap.Add(botOptions.AuthorAppId, botOptions.AuthorAppCertName); } if (string.IsNullOrEmpty(botOptions.GraphAppId)) { throw new Exception("Graph app id not found."); } else { certificateNameMap.Add(botOptions.GraphAppId, botOptions.GraphAppCertName); } return(certificateNameMap); }
public static WebPageResponse GetData(string pageUrl, BotOptions botOptions) { HttpWebClientV2 client = InitHttpClient(botOptions); Exception exception = null; HttpResponseInfo result = null; var counter = 0; do { try { result = client.GetResponse(pageUrl); } catch (Exception e) { exception = e; Console.WriteLine(e); } counter++; } while (counter < 10 && result == null); if (result == null || result.StatusCode != HttpStatusCode.OK) { return(null); } return(new WebPageResponse { ByteContent = result.Content.ReadAsByte(), Content = result.Content.ReadAsString(), HttpStatusCode = result.StatusCode, Url = new Uri(pageUrl) }); }
public MessagesController(BotOptions botOptions) { if (botOptions == null) { throw new ArgumentNullException(nameof(botOptions)); } BotOptions = botOptions; }
public DiscordErrorLogger( DiscordClient client, IOptions <BotOptions> options ) { _client = client; _options = options.Value; }
public UserNotesHandler(IUserDataStore userDataStore, IOptionsSnapshot <BotOptions> botOptions, IOptionsSnapshot <UserNotesOptions> notesOptions, ILogger <UserNotesHandler> logger) { // store all services this._log = logger; this._botOptions = botOptions.Value; this._notesOptions = notesOptions.Value; this._userDataStore = userDataStore; }
private static HttpWebClientV2 InitHttpClient(BotOptions botOptions) { return(new() { UseProxy = botOptions.UseProxy, DecompressionMethod = botOptions.HttpClientContext.PageDecompression, UserAgent = botOptions.HttpClientContext.UserAgent, }); }
public ContextMiddleware(IOptions <BotOptions> config, BotRoutingDataManager routingDataManager, ILogger <ContextMiddleware> logger) { _config = config.Value; _routingDataManager = routingDataManager; _logger = logger; }
public NextGameHandler(IGroupConfigStore groupConfigStore, IOptionsSnapshot <BotOptions> botOptions, IOptionsSnapshot <NextGameOptions> nextGameOptions, ILogger <NextGameHandler> log) { // store all services this._log = log; this._botOptions = botOptions.Value; this._groupConfigStore = groupConfigStore; this._nextGameOptions = nextGameOptions.Value; }
public BotInitializeWorker(DiscordSocketClient client, IOptions <BotOptions> options, ILogger <BotInitializeWorker> logger, ILogger <DiscordSocketClient> discordLogger) { _client = client; _logger = logger; _discordLogger = discordLogger; _options = options.Value; }
public QueuesSystemHandler(IIdQueueStore idQueueStore, IUserDataStore userDataStore, IOptionsSnapshot <QueuesSystemOptions> queuesOptions, IOptionsSnapshot <BotOptions> botOptions, ILogger <QueuesSystemHandler> logger) { // store all services this._log = logger; this._botOptions = botOptions.Value; this._queuesOptions = queuesOptions.Value; this._idQueueStore = idQueueStore; this._userDataStore = userDataStore; }
/// <summary> /// Add bot feature. /// </summary> /// <param name="services">The service collection.</param> /// <param name="botOptionsAction">The action for bot options.</param> /// <returns>The updated service collection.</returns> public static IServiceCollection AddBot(this IServiceCollection services, Action <BotOptions> botOptionsAction) { var options = new BotOptions(); botOptionsAction(options); services.AddSingleton(options); return(services.AddSingleton <Bot>()); }
public AnswerQuestionEventHandler(IMediator mediator, IFaqService faqService, TelemetryClient telemetryClient, IOptions <BotOptions> options) { _mediator = mediator; _faqService = faqService; _telemetryClient = telemetryClient; _options = options.Value; }
//HOWTO: make it possible to visualize search progress - let WPF to see each State and decisions? public BotMove FindBestMove(SquareBoard board, Side botSide, CancellationToken cancellation, BotOptions options = default) { this.options = options ?? new BotOptions(); this.botSide = botSide; this.playerSide = SideUtil.Opposite(botSide); this.cancellation = cancellation; return(Negamax(board, this.options.MaxDepth, Int32.MinValue + 1, Int32.MaxValue, botSide, CancellationToken.None)); }
public BankingService(DiscordSocketClient discord, IBankAccountRepository bankAccountRepository, IOptions <BotOptions> options) { _discord = discord; _bankAccountRepository = bankAccountRepository; _options = options.Value; _discord.MessageReceived += OnMessageReceived; }
public Task <Unit> Handle(BotInitializeCommand request, CancellationToken cancellationToken) { _botOptions = _configuration.GetSection(BotOptions.Bot).Get <BotOptions>(); _telegramBotService.Start( botToken: _botOptions.BotToken, chatId: _botOptions.ChatId); return(Task.FromResult(Unit.Value)); }
public CommandMiddleware(IOptions <BotOptions> config, BotRoutingDataManager routingDataManager, IMassTransitServiceBus serviceBus, IDeviceRestService deviceRestService, ChatReportDataManager reportDataManager, ILogger <CommandMiddleware> logger) : base(logger) { _config = config.Value; _serviceBus = serviceBus; _deviceRestService = deviceRestService; _routingDataManager = routingDataManager; _reportDataManager = reportDataManager; _logger = logger; }
public VoiceHandler( Ops.INlpService nlpService, IOptions <BotOptions <BusVbot> > botOptions, ILogger <VoiceHandler> logger ) { _nlpService = nlpService; _botOptions = botOptions.Value; _logger = logger; }
protected LinkWalkerBotService(IOfferStorageWorker storage, ILog eventLogger, BotOptions botOptions) { _storage = storage; _eventLogger = eventLogger; _processors = new List <Task>(); BotOptions = botOptions; _queueLinks = new ConcurrentQueue <string>(); _webWorker = new T(); _htmlParser = new HtmlParser(); }