protected override async Task StartService(CancellationToken cancellationToken) { RedditCredentials credentials = await CredentialGetter.GetCredentials().ConfigureAwait(false); _userName = credentials.Username; do { try { _webAgent = new BotWebAgent(credentials.Username, credentials.Password, credentials.ClientId, credentials.ClientSecret, credentials.RedirectUrl); _webAgent.RateLimiter = new RateLimitManager(RateLimitMode.Pace); //This actually authenticates with reddit, that's why it's in a try/catch while loop _client = new RedditSharp.Reddit(_webAgent, true); break; } catch (Exception e) { Console.WriteLine(e); await Task.Delay(TimeSpan.FromMinutes(2)).ConfigureAwait(false); Logger.LogCritical(e.Message, e); } } while (true); StartReddit(cancellationToken); Logger.LogInformation($"{Platform} started on account '{_userName}'"); await Task.Delay(-1, cancellationToken); }
protected override async Task StartService(CancellationToken cancellationToken) { TelegramCredentials credentials = await CredentialGetter.GetCredentials().ConfigureAwait(false); _client = new TelegramBotClient(credentials.Token); _currentUser = await _client.GetMeAsync(cancellationToken).ConfigureAwait(false); _client.OnReceiveError += BotOnReceiveError; _client.OnUpdate += BotOnOnUpdate; _client.StartReceiving(cancellationToken: cancellationToken); Logger.LogInformation($"{Platform} started on account \"{_currentUser.Username}\""); await Task.Delay(-1, cancellationToken); }
protected override async Task StartService(CancellationToken cancellationToken) { _client = new DiscordSocketClient(); _client.Log += Log; DiscordCredentials credentials = await CredentialGetter.GetCredentials().ConfigureAwait(false); _client.MessageReceived += CommandProcessing; await _client.LoginAsync(credentials.TokenType, credentials.Token); await _client.StartAsync(); Logger.LogInformation($"{Platform} started on account '{_client.CurrentUser.Username}'"); await Task.Delay(-1, cancellationToken); }