Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add routine support #346

Merged
merged 3 commits into from
Feb 2, 2022
Merged

Add routine support #346

merged 3 commits into from
Feb 2, 2022

Conversation

Zabuzard
Copy link
Member

@Zabuzard Zabuzard commented Jan 18, 2022

Overview

Implements and closes #235. Adds an interface Routine implements Feature, which allows classes to be executed on a pre-defined fixed schedule by the bots core system (i.e. every 5 minutes).

Also migrated the two existing routines:

  • TemporaryModerationRoutine (for temp bans, mutes, ...)
  • ModAuditLogRoutine

Example

A quick example routine would be

class Foo implements Routine {
  @Override
  public void run(JDA jda) {
    System.out.println("hello");
  }

  @Override
  public Schedule createSchedule() {
    return new Routine.Schedule(Routine.ScheduleMode.FIXED_RATE, 0, 5, TimeUnit.SECONDS);
  }
}

with an addition in Features.java:

features.add(new Foo());

The system will now basically hand over the routine to a ScheduledExecutorService and execute its run(JDA) method on the schedule defined by its createSchedule().

Remarks

This is based on (and hence also blocked by) #345 .

@Zabuzard Zabuzard added enhancement New feature or request blocked This issue is currently blocked by another issue (see comments) priority: major labels Jan 18, 2022
@Zabuzard Zabuzard added this to the Improvement phase 1 milestone Jan 18, 2022
@Zabuzard Zabuzard self-assigned this Jan 18, 2022
This was referenced Jan 18, 2022
@Zabuzard Zabuzard mentioned this pull request Jan 21, 2022
@Zabuzard Zabuzard removed the blocked This issue is currently blocked by another issue (see comments) label Jan 27, 2022
@Zabuzard Zabuzard marked this pull request as ready for review January 27, 2022 10:36
@Zabuzard Zabuzard requested review from a team as code owners January 27, 2022 10:36
@sonarcloud
Copy link

sonarcloud bot commented Jan 27, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Zabuzard
Copy link
Member Author

Zabuzard commented Feb 2, 2022

No changes since a week, merging

@Zabuzard Zabuzard merged commit cb6f9d2 into develop Feb 2, 2022
@Zabuzard Zabuzard deleted the feature/add_routines branch February 2, 2022 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: major
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Routine support
1 participant