-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/cool-messages
- Loading branch information
Showing
15 changed files
with
145 additions
and
167 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @Together-Java/moderators @Together-Java/maintainers | ||
* @Together-Java/maintainers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...cation/src/main/java/org/togetherjava/tjbot/features/basic/MemberCountDisplayRoutine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.togetherjava.tjbot.features.basic; | ||
|
||
import net.dv8tion.jda.api.JDA; | ||
import net.dv8tion.jda.api.entities.channel.concrete.Category; | ||
|
||
import org.togetherjava.tjbot.config.Config; | ||
import org.togetherjava.tjbot.features.Routine; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Predicate; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* Shows the guild member count on selected category, which updates everyday. | ||
*/ | ||
public class MemberCountDisplayRoutine implements Routine { | ||
private final Predicate<String> memberCountCategoryPredicate; | ||
|
||
/** | ||
* Creates an instance on member count display routine. | ||
* | ||
* @param config the config to use | ||
*/ | ||
public MemberCountDisplayRoutine(Config config) { | ||
memberCountCategoryPredicate = | ||
Pattern.compile(config.getMemberCountCategoryPattern() + "( - \\d+ Members)?") | ||
.asMatchPredicate(); | ||
} | ||
|
||
private void updateCategoryName(Category category) { | ||
int totalMemberCount = category.getGuild().getMemberCount(); | ||
String baseName = category.getName().split("-")[0].trim(); | ||
|
||
category.getManager() | ||
.setName("%s - %d Members".formatted(baseName, totalMemberCount)) | ||
.queue(); | ||
} | ||
|
||
@Override | ||
public Schedule createSchedule() { | ||
return new Schedule(ScheduleMode.FIXED_RATE, 0, 24, TimeUnit.HOURS); | ||
} | ||
|
||
@Override | ||
public void runRoutine(JDA jda) { | ||
jda.getGuilds() | ||
.forEach(guild -> guild.getCategories() | ||
.stream() | ||
.filter(category -> memberCountCategoryPredicate.test(category.getName())) | ||
.findAny() | ||
.ifPresent(this::updateCategoryName)); | ||
} | ||
} |
82 changes: 0 additions & 82 deletions
82
application/src/main/java/org/togetherjava/tjbot/features/chatgpt/AIResponseParser.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.