Skip to content

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 force-pushed the feature/add_routines branch from ba52734 to b43d104 Compare January 21, 2022 15:45
@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 force-pushed the feature/add_routines branch from b43d104 to 065b892 Compare January 27, 2022 10:35
@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
@Zabuzard Zabuzard force-pushed the feature/add_routines branch from 065b892 to 510b799 Compare January 27, 2022 18:26
@sonarqubecloud
Copy link

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