public FoldingModule(Scheduler scheduler, DiscordClient client, GaussConfig config) { this._scheduler = scheduler; this._client = client; this._config = config; try { this._previousStats = JsonUtility.Deserialize <Dictionary <int, FoldingStatus> >( Path.Join(this._config.ConfigDirectory, "foldingdata.json") ); } catch (Exception) { this._client.Logger.LogInformation(LogEvent.Folding, $"Could not restore F@H data. Starting new record."); _previousStats = new Dictionary <int, FoldingStatus>(); } var now = DateTime.UtcNow; var scheduleStart = new DateTime(now.Year, now.Month, now.Day, 12, 0, 0, kind: DateTimeKind.Utc); while (now > scheduleStart) { scheduleStart += _timeSpan; } this._client.Logger.LogInformation(LogEvent.Folding, $"F@H updates start at {scheduleStart:yyyy-MM-dd HH:mm}"); this._scheduler.AddTask( new CyclicTask( _timeSpan, scheduleStart, this.PostUpdate ) ); }
public RoleAssign(DiscordClient client, GaussConfig config) { _client = client; _config = config; this._client.GuildMemberAdded += this.OnGuildMemberAdded; }
public async static Task Main(string[] args) { var taskCompletion = new TaskCompletionSource <int>(); // Set culture to default "C" culture to ensure the bot behaves the same in terms of parsing and formatting, regardless of where it runs: CultureInfo.CurrentCulture = new CultureInfo("C", false); // Listen for SIGKILL / SIGTERM / SIGHUP to handle a graceful shutdown: AppDomain.CurrentDomain.ProcessExit += (sender, e) => { _botInstance.Disconnect(); taskCompletion.TrySetResult(1); }; Console.CancelKeyPress += (sender, e) => { _botInstance.Disconnect(); taskCompletion.TrySetResult(1); }; string configDirectory = Path.Join(GetFolderPath(SpecialFolder.UserProfile), "GaussBot"); if (args.Length > 0 && args[0] == "--configDir") { configDirectory = args[1]; } GaussConfig config = GaussConfig.ReadConfig(configDirectory); // Initiate the bot itself: _botInstance = new GaussBot(config); _botInstance.Connect(); // Wait for the program to be terminated via signal: await taskCompletion.Task; }
public ElectionModule( DiscordClient client, Scheduler scheduler, GaussConfig config, ElectionRepository repository ) { this._client = client; this._config = config; this._scheduler = scheduler; this._repository = repository; // Setup the UpdateElections function to run in the general scheduler: this._scheduler.AddTask( new TaskThunk( this.ShouldUpdateElections, this.UpdateElections ) ); }
public VCNamesModule(DiscordClient client, GaussConfig config) { this._config = config; client.VoiceStateUpdated += this.HandleVoiceStateEvent; }
public AdminCommands(GuildSettingsContext dbContext, GaussConfig config) { this._context = dbContext; this._config = config; }
public WelcomeAdminCommands(GaussConfig config) { this._config = config; }
public VCModule(DiscordClient client, GaussConfig config, UserSettingsContext settings) { this._config = config; this._settings = settings; client.VoiceStateUpdated += this.HandleVoiceStateEvent; }