mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-18 06:05:49 +00:00
Compare commits
8 Commits
abstracto-
...
abstracto-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e643080516 | ||
|
|
b747516881 | ||
|
|
0a4238c9f5 | ||
|
|
99fe84914b | ||
|
|
f9b85feeaf | ||
|
|
51edb50eee | ||
|
|
43a78a4989 | ||
|
|
e3e0ad98ba |
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>anti-raid</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>assignable-roles-int</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>custom-command</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>dynamic-activity</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>invite-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>logging</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ReactionReportRepository extends JpaRepository<ReactionReport, Long> {
|
||||
|
||||
List<ReactionReport> findByReportedUserAndCreatedLessThan(AUserInAServer aUserInAServer, Instant maxCreated);
|
||||
List<ReactionReport> findByReportedUserAndCreatedGreaterThan(AUserInAServer aUserInAServer, Instant maxCreated);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ReactionReportManagementServiceBean implements ReactionReportManage
|
||||
@Override
|
||||
public Optional<ReactionReport> findRecentReactionReportAboutUser(AUserInAServer aUserInAServer, Duration maxAge) {
|
||||
Instant maxCreation = Instant.now().minus(maxAge);
|
||||
List<ReactionReport> foundReports = repository.findByReportedUserAndCreatedLessThan(aUserInAServer, maxCreation);
|
||||
List<ReactionReport> foundReports = repository.findByReportedUserAndCreatedGreaterThan(aUserInAServer, maxCreation);
|
||||
return foundReports.isEmpty() ? Optional.empty() : Optional.of(foundReports.get(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>profanity-filter</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ public class ExportEmoteStats extends AbstractConditionableCommand {
|
||||
.emotes(usedEmotes)
|
||||
.guild(commandContext.getGuild())
|
||||
.downloadDate(Instant.now())
|
||||
.serverId(commandContext.getGuild().getIdLong())
|
||||
.requester(commandContext.getAuthor())
|
||||
.statsSince(toUseForModel)
|
||||
.build();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class DownloadEmoteStatsModel {
|
||||
* The {@link Member} who requested the export
|
||||
*/
|
||||
private Member requester;
|
||||
private Long serverId;
|
||||
/**
|
||||
* A list of {@link UsedEmote} which are part of the export
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>voice-channel-context</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>voice-channel-context</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package dev.sheldan.abstracto.webservices.common.service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.webservices.common.exception.SuggestQueriesException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@CacheConfig(cacheNames = "general-use-cache")
|
||||
public class SuggestQueriesServiceBean implements SuggestQueriesService {
|
||||
|
||||
@Autowired
|
||||
private OkHttpClient okHttpClient;
|
||||
|
||||
@Value("${abstracto.feature.webservices.common.suggestionsURL}")
|
||||
private String suggestionUrl;
|
||||
|
||||
@Autowired
|
||||
private Gson gson;
|
||||
|
||||
@Autowired
|
||||
private SuggestQueriesServiceBean self;
|
||||
|
||||
private List<String> getSuggestionsFromResponse(String response) {
|
||||
JsonElement rootJson = JsonParser.parseString(response);
|
||||
if(!rootJson.isJsonArray()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
JsonArray mainArray = rootJson.getAsJsonArray();
|
||||
if(mainArray.size() < 2 || !mainArray.get(1).isJsonArray() || mainArray.get(1).getAsJsonArray().size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
JsonArray suggestionArray = mainArray.get(1).getAsJsonArray();
|
||||
return Arrays.asList(gson.fromJson(suggestionArray, String[].class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "{#query, #service}")
|
||||
public List<String> getSuggestionsForQuery(String query, String service) {
|
||||
Request request = new Request.Builder()
|
||||
.url(String.format(suggestionUrl, service, query))
|
||||
.get()
|
||||
.build();
|
||||
Response response;
|
||||
try {
|
||||
response = okHttpClient.newCall(request).execute();
|
||||
if(!response.isSuccessful()) {
|
||||
if(log.isDebugEnabled()) {
|
||||
log.error("Failed to retrieve suggestions. Response had code {} with body {}.",
|
||||
response.code(), response.body());
|
||||
}
|
||||
throw new SuggestQueriesException(response.code());
|
||||
}
|
||||
return getSuggestionsFromResponse(response.body().string());
|
||||
} catch (IOException e) {
|
||||
throw new AbstractoRunTimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getYoutubeSuggestionsForQuery(String query) {
|
||||
if(query == null || "".equals(query)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return self.getSuggestionsForQuery(query, "yt");
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,10 @@ public class UrbanServiceBean implements UrbanService {
|
||||
|
||||
@Override
|
||||
public UrbanDefinition getUrbanDefinition(String query) throws IOException {
|
||||
Request request = new Request.Builder().url(String.format(requestUrl, query)).get().build();
|
||||
Request request = new Request.Builder()
|
||||
.url(String.format(requestUrl, query))
|
||||
.get()
|
||||
.build();
|
||||
Response response = okHttpClient.newCall(request).execute();
|
||||
if(!response.isSuccessful()) {
|
||||
if(log.isDebugEnabled()) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandAutoCompleteService;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
@@ -16,12 +17,14 @@ import dev.sheldan.abstracto.core.service.FeatureModeService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.webservices.common.service.SuggestQueriesService;
|
||||
import dev.sheldan.abstracto.webservices.config.WebServicesSlashCommandNames;
|
||||
import dev.sheldan.abstracto.webservices.config.WebserviceFeatureDefinition;
|
||||
import dev.sheldan.abstracto.webservices.youtube.config.YoutubeWebServiceFeatureMode;
|
||||
import dev.sheldan.abstracto.webservices.youtube.model.YoutubeVideo;
|
||||
import dev.sheldan.abstracto.webservices.youtube.model.command.YoutubeVideoSearchCommandModel;
|
||||
import dev.sheldan.abstracto.webservices.youtube.service.YoutubeSearchService;
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -57,6 +60,12 @@ public class YoutubeVideoSearch extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
private InteractionService interactionService;
|
||||
|
||||
@Autowired
|
||||
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
|
||||
|
||||
@Autowired
|
||||
private SuggestQueriesService suggestQueriesService;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
String query = (String) commandContext.getParameters().getParameters().get(0);
|
||||
@@ -100,6 +109,15 @@ public class YoutubeVideoSearch extends AbstractConditionableCommand {
|
||||
.thenApply(o -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) {
|
||||
if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), SEARCH_QUERY_PARAMETER)) {
|
||||
return suggestQueriesService.getYoutubeSuggestionsForQuery(event.getFocusedOption().getValue());
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
@@ -108,6 +126,7 @@ public class YoutubeVideoSearch extends AbstractConditionableCommand {
|
||||
.name(SEARCH_QUERY_PARAMETER)
|
||||
.type(String.class)
|
||||
.remainder(true)
|
||||
.supportsAutoComplete(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
parameters.add(queryParameter);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.google.api.services.youtube.model.SearchResult;
|
||||
import dev.sheldan.abstracto.webservices.youtube.exception.YoutubeAPIException;
|
||||
import dev.sheldan.abstracto.webservices.youtube.exception.YoutubeVideoNotFoundException;
|
||||
import dev.sheldan.abstracto.webservices.youtube.model.YoutubeVideo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -13,6 +14,7 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class YoutubeSearchServiceBean implements YoutubeSearchService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
abstracto.feature.webservices.common.suggestionsURL=http://suggestqueries.google.com/complete/search?client=firefox&ds=%s&q=%s
|
||||
|
||||
abstracto.featureFlags.youtube.featureName=youtube
|
||||
abstracto.featureFlags.youtube.enabled=false
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>webservices</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sheldan.abstracto.webservices.common.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.templating.Templatable;
|
||||
import dev.sheldan.abstracto.webservices.common.model.exception.SuggestQueriesExceptionModel;
|
||||
|
||||
public class SuggestQueriesException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final SuggestQueriesExceptionModel model;
|
||||
|
||||
public SuggestQueriesException(Integer responseCode) {
|
||||
super(String.format("Request failure towards suggest queries %s.", responseCode));
|
||||
this.model = SuggestQueriesExceptionModel
|
||||
.builder()
|
||||
.responseCode(responseCode)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "suggest_queries_request_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.webservices.common.model.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class SuggestQueriesExceptionModel implements Serializable {
|
||||
private Integer responseCode;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.sheldan.abstracto.webservices.common.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SuggestQueriesService {
|
||||
List<String> getSuggestionsForQuery(String query, String service);
|
||||
List<String> getYoutubeSuggestionsForQuery(String query);
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
@Autowired
|
||||
private List<CommandParameterHandler> parameterHandlers;
|
||||
|
||||
@Autowired
|
||||
@Autowired(required = false)
|
||||
private List<CommandAlternative> commandAlternatives;
|
||||
|
||||
@Autowired
|
||||
@@ -109,15 +109,16 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
public static final String COMMAND_CONFIRMATION_MESSAGE_TEMPLATE_KEY = "command_confirmation_message";
|
||||
public static final String COMMAND_PROCESSED = "command.processed";
|
||||
public static final String STATUS_TAG = "status";
|
||||
public static final String TYPE_TAG = "type";
|
||||
public static final CounterMetric COMMANDS_PROCESSED_COUNTER = CounterMetric
|
||||
.builder()
|
||||
.name(COMMAND_PROCESSED)
|
||||
.tagList(Arrays.asList(MetricTag.getTag(STATUS_TAG, "processed")))
|
||||
.tagList(Arrays.asList(MetricTag.getTag(STATUS_TAG, "processed"), MetricTag.getTag(TYPE_TAG, "message")))
|
||||
.build();
|
||||
public static final CounterMetric COMMANDS_WRONG_PARAMETER_COUNTER = CounterMetric
|
||||
.builder()
|
||||
.name(COMMAND_PROCESSED)
|
||||
.tagList(Arrays.asList(MetricTag.getTag(STATUS_TAG, "parameter.wrong")))
|
||||
.tagList(Arrays.asList(MetricTag.getTag(STATUS_TAG, "parameter.wrong"), MetricTag.getTag(TYPE_TAG, "message")))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
@@ -148,14 +149,16 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
Optional<CommandAlternative> foundAlternativeOptional = commandAlternatives
|
||||
.stream()
|
||||
.filter(commandAlternative -> commandAlternative.matches(result.getParameter()))
|
||||
.findFirst();
|
||||
if(foundAlternativeOptional.isPresent()) {
|
||||
CommandAlternative foundAlternative = foundAlternativeOptional.get();
|
||||
log.info("Found alternative {} to execute for command.", foundAlternative.getClass());
|
||||
foundAlternative.execute(result.getParameter(), message);
|
||||
if(commandAlternatives != null) {
|
||||
Optional<CommandAlternative> foundAlternativeOptional = commandAlternatives
|
||||
.stream()
|
||||
.filter(commandAlternative -> commandAlternative.matches(result.getParameter()))
|
||||
.findFirst();
|
||||
if(foundAlternativeOptional.isPresent()) {
|
||||
CommandAlternative foundAlternative = foundAlternativeOptional.get();
|
||||
log.info("Found alternative {} to execute for command.", foundAlternative.getClass());
|
||||
foundAlternative.execute(result.getParameter(), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -552,7 +555,9 @@ public class CommandReceivedHandler extends ListenerAdapter {
|
||||
metricService.registerCounter(COMMANDS_PROCESSED_COUNTER, "Commands processed");
|
||||
metricService.registerCounter(COMMANDS_WRONG_PARAMETER_COUNTER, "Commands with incorrect parameter");
|
||||
this.parameterHandlers = parameterHandlers.stream().sorted(comparing(CommandParameterHandler::getPriority)).collect(Collectors.toList());
|
||||
this.commandAlternatives = commandAlternatives.stream().sorted(comparing(Prioritized::getPriority)).collect(Collectors.toList());
|
||||
if(commandAlternatives != null) {
|
||||
this.commandAlternatives = commandAlternatives.stream().sorted(comparing(Prioritized::getPriority)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -82,6 +82,11 @@ public class ListenerExecutorConfig {
|
||||
return executorService.setupExecutorFor("slashCommandListener");
|
||||
}
|
||||
|
||||
@Bean(name = "slashCommandAutoCompleteExecutor")
|
||||
public TaskExecutor slashCommandAutoCompleteExecutor() {
|
||||
return executorService.setupExecutorFor("slashCommandAutoCompleteListener");
|
||||
}
|
||||
|
||||
@Bean(name = "emoteDeletedExecutor")
|
||||
public TaskExecutor emoteDeletedExecutor() {
|
||||
return executorService.setupExecutorFor("emoteDeletedListener");
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.interaction.context.message;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.CommandReceivedHandler;
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.interaction.InteractionResult;
|
||||
import dev.sheldan.abstracto.core.interaction.context.message.listener.MessageContextCommandListener;
|
||||
import dev.sheldan.abstracto.core.metric.service.CounterMetric;
|
||||
import dev.sheldan.abstracto.core.metric.service.MetricService;
|
||||
import dev.sheldan.abstracto.core.metric.service.MetricTag;
|
||||
import dev.sheldan.abstracto.core.models.listener.interaction.MessageContextInteractionModel;
|
||||
import dev.sheldan.abstracto.core.service.FeatureConfigService;
|
||||
import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
||||
@@ -17,6 +21,8 @@ import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -48,11 +54,20 @@ public class MessageContextCommandListenerBean extends ListenerAdapter {
|
||||
@Autowired
|
||||
private FeatureModeService featureModeService;
|
||||
|
||||
@Autowired
|
||||
private MetricService metricService;
|
||||
|
||||
public static final CounterMetric MESSAGE_CONTEXT_COMMANDS_PROCESSED_COUNTER = CounterMetric
|
||||
.builder()
|
||||
.name(CommandReceivedHandler.COMMAND_PROCESSED)
|
||||
.tagList(Arrays.asList(MetricTag.getTag(CommandReceivedHandler.STATUS_TAG, "processed"), MetricTag.getTag(CommandReceivedHandler.TYPE_TAG, "context.message")))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public void onMessageContextInteraction(@NotNull MessageContextInteractionEvent event) {
|
||||
if(listenerList == null) return;
|
||||
CompletableFuture.runAsync(() -> self.executeListenerLogic(event), messageContextCommandExecutor).exceptionally(throwable -> {
|
||||
log.error("Failed to execute listener logic in async button event.", throwable);
|
||||
log.error("Failed to execute listener logic in async message context event.", throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@@ -68,6 +83,7 @@ public class MessageContextCommandListenerBean extends ListenerAdapter {
|
||||
List<MessageContextCommandListener> validListener = filterFeatureAwareListener(listenerList, model);
|
||||
Optional<MessageContextCommandListener> listenerOptional = findListener(validListener, model);
|
||||
if(listenerOptional.isPresent()) {
|
||||
metricService.incrementCounter(MESSAGE_CONTEXT_COMMANDS_PROCESSED_COUNTER);
|
||||
listener = listenerOptional.get();
|
||||
listener.execute(model);
|
||||
InteractionResult result = InteractionResult.fromSuccess();
|
||||
@@ -116,4 +132,9 @@ public class MessageContextCommandListenerBean extends ListenerAdapter {
|
||||
return listenerList;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void filterPostProcessors() {
|
||||
metricService.registerCounter(MESSAGE_CONTEXT_COMMANDS_PROCESSED_COUNTER, "Message context commands processed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package dev.sheldan.abstracto.core.interaction.slash;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.Command;
|
||||
import dev.sheldan.abstracto.core.command.CommandReceivedHandler;
|
||||
import dev.sheldan.abstracto.core.command.condition.ConditionResult;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.command.service.CommandService;
|
||||
import dev.sheldan.abstracto.core.command.service.PostCommandExecution;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.metric.service.CounterMetric;
|
||||
import dev.sheldan.abstracto.core.metric.service.MetricService;
|
||||
import dev.sheldan.abstracto.core.metric.service.MetricTag;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -19,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -36,6 +42,10 @@ public class SlashCommandListenerBean extends ListenerAdapter {
|
||||
@Qualifier("slashCommandExecutor")
|
||||
private TaskExecutor slashCommandExecutor;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("slashCommandAutoCompleteExecutor")
|
||||
private TaskExecutor slashCommandAutoCompleteExecutor;
|
||||
|
||||
@Autowired
|
||||
private SlashCommandListenerBean self;
|
||||
|
||||
@@ -45,6 +55,15 @@ public class SlashCommandListenerBean extends ListenerAdapter {
|
||||
@Autowired
|
||||
private List<PostCommandExecution> executions;
|
||||
|
||||
@Autowired
|
||||
private MetricService metricService;
|
||||
|
||||
public static final CounterMetric SLASH_COMMANDS_PROCESSED_COUNTER = CounterMetric
|
||||
.builder()
|
||||
.name(CommandReceivedHandler.COMMAND_PROCESSED)
|
||||
.tagList(Arrays.asList(MetricTag.getTag(CommandReceivedHandler.STATUS_TAG, "processed"), MetricTag.getTag(CommandReceivedHandler.TYPE_TAG, "slash")))
|
||||
.build();
|
||||
|
||||
public List<Command> getSlashCommands() {
|
||||
if(commands == null || commands.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
@@ -59,7 +78,7 @@ public class SlashCommandListenerBean extends ListenerAdapter {
|
||||
public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) {
|
||||
if(commands == null || commands.isEmpty()) return;
|
||||
CompletableFuture.runAsync(() -> self.executeListenerLogic(event), slashCommandExecutor).exceptionally(throwable -> {
|
||||
log.error("Failed to execute listener logic in async button event.", throwable);
|
||||
log.error("Failed to execute listener logic in async slash command event.", throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@@ -68,6 +87,7 @@ public class SlashCommandListenerBean extends ListenerAdapter {
|
||||
public void executeListenerLogic(SlashCommandInteractionEvent event) {
|
||||
Optional<Command> potentialCommand = findCommand(event);
|
||||
potentialCommand.ifPresent(command -> {
|
||||
metricService.incrementCounter(SLASH_COMMANDS_PROCESSED_COUNTER);
|
||||
try {
|
||||
commandService.isCommandExecutable(command, event).thenAccept(conditionResult -> {
|
||||
self.executeCommand(event, command, conditionResult);
|
||||
@@ -85,6 +105,29 @@ public class SlashCommandListenerBean extends ListenerAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandAutoCompleteInteraction(@NotNull CommandAutoCompleteInteractionEvent event) {
|
||||
if(commands == null || commands.isEmpty()) return;
|
||||
CompletableFuture.runAsync(() -> self.executeAutCompleteListenerLogic(event), slashCommandAutoCompleteExecutor).exceptionally(throwable -> {
|
||||
log.error("Failed to execute listener logic in async auto complete interaction event.", throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void executeAutCompleteListenerLogic(CommandAutoCompleteInteractionEvent event) {
|
||||
Optional<Command> potentialCommand = findCommand(event);
|
||||
potentialCommand.ifPresent(command -> {
|
||||
try {
|
||||
List<String> replies = command.performAutoComplete(event);
|
||||
event.replyChoiceStrings(replies).queue(unused -> {},
|
||||
throwable -> log.error("Failed to response to complete of command {} in guild {}.", command.getConfiguration().getName(), event.getGuild().getIdLong()));
|
||||
} catch (Exception exception) {
|
||||
log.error("Error while executing autocomplete of command {}.", command.getConfiguration().getName(), exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = AbstractoRunTimeException.class)
|
||||
public void executeCommand(SlashCommandInteractionEvent event, Command command, ConditionResult conditionResult) {
|
||||
CompletableFuture<CommandResult> commandOutput;
|
||||
@@ -121,8 +164,17 @@ public class SlashCommandListenerBean extends ListenerAdapter {
|
||||
.findAny();
|
||||
}
|
||||
|
||||
private Optional<Command> findCommand(CommandAutoCompleteInteractionEvent event) {
|
||||
return commands
|
||||
.stream()
|
||||
.filter(command -> command.getConfiguration().getSlashCommandConfig().isEnabled())
|
||||
.filter(command -> command.getConfiguration().getSlashCommandConfig().matchesInteraction(event.getInteraction()))
|
||||
.findAny();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void filterPostProcessors() {
|
||||
metricService.registerCounter(SLASH_COMMANDS_PROCESSED_COUNTER, "Slash Commands processed");
|
||||
executions = executions
|
||||
.stream()
|
||||
.filter(PostCommandExecution::supportsSlash)
|
||||
|
||||
@@ -124,11 +124,7 @@ public class SlashCommandServiceBean implements SlashCommandService {
|
||||
optionalParameters.add(new OptionData(type, parameter.getSlashCompatibleName() + "_" + i, parameterDescription, false));
|
||||
}
|
||||
} else {
|
||||
if(!parameter.isOptional()) {
|
||||
requiredParameters.add(new OptionData(type, parameter.getSlashCompatibleName(), parameterDescription, true));
|
||||
} else {
|
||||
optionalParameters.add(new OptionData(type, parameter.getSlashCompatibleName(), parameterDescription, false));
|
||||
}
|
||||
requiredParameters.add(new OptionData(type, parameter.getSlashCompatibleName(), parameterDescription, !parameter.isOptional(), parameter.getSupportsAutoComplete()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.sheldan.abstracto.core.interaction.slash.parameter;
|
||||
|
||||
import net.dv8tion.jda.api.interactions.AutoCompleteQuery;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SlashCommandAutoCompleteServiceBean implements SlashCommandAutoCompleteService{
|
||||
@Override
|
||||
public boolean matchesParameter(AutoCompleteQuery query, String parameterName) {
|
||||
return query.getName().equalsIgnoreCase(parameterName);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,16 @@
|
||||
<heap unit="entries">2000</heap>
|
||||
</resources>
|
||||
</cache>
|
||||
<!-- TODO no nice way yet to have this configuration split up -->
|
||||
<cache uses-template="default" alias="general-use-cache">
|
||||
<expiry>
|
||||
<ttl unit="seconds">7200</ttl>
|
||||
</expiry>
|
||||
|
||||
<resources>
|
||||
<heap unit="entries">2000</heap>
|
||||
</resources>
|
||||
</cache>
|
||||
<cache-template name="default">
|
||||
<expiry>
|
||||
<ttl unit="seconds">600</ttl>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -4,8 +4,11 @@ import dev.sheldan.abstracto.core.FeatureAware;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface Command extends FeatureAware {
|
||||
@@ -13,5 +16,6 @@ public interface Command extends FeatureAware {
|
||||
default CommandResult execute(CommandContext commandContext) {return CommandResult.fromSuccess();}
|
||||
default CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {return CompletableFuture.completedFuture(CommandResult.fromSuccess());}
|
||||
default CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) { return CompletableFuture.completedFuture(CommandResult.fromSuccess());}
|
||||
default List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) { return new ArrayList<>(); }
|
||||
CommandConfiguration getConfiguration();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ public class Parameter implements Serializable {
|
||||
@Builder.Default
|
||||
private Integer listSize = 0;
|
||||
@Builder.Default
|
||||
private Boolean supportsAutoComplete = false;
|
||||
@Builder.Default
|
||||
private List<ParameterValidator> validators = new ArrayList<>();
|
||||
@Builder.Default
|
||||
private Map<String, Object> additionalInfo = new HashMap<>();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.interaction.slash.parameter;
|
||||
|
||||
import net.dv8tion.jda.api.interactions.AutoCompleteQuery;
|
||||
|
||||
public interface SlashCommandAutoCompleteService {
|
||||
boolean matchesParameter(AutoCompleteQuery query, String parameterName);
|
||||
}
|
||||
@@ -20,6 +20,9 @@ public class ServerChannelMessage {
|
||||
}
|
||||
|
||||
public static ServerChannelMessage fromMessage(Message message) {
|
||||
if(message == null) {
|
||||
return null;
|
||||
}
|
||||
return ServerChannelMessage
|
||||
.builder()
|
||||
.serverId(message.getGuild().getIdLong())
|
||||
@@ -29,6 +32,9 @@ public class ServerChannelMessage {
|
||||
}
|
||||
|
||||
public static ServerChannelMessage fromCachedMessage(CachedMessage cachedMessage) {
|
||||
if(cachedMessage == null) {
|
||||
return null;
|
||||
}
|
||||
return ServerChannelMessage
|
||||
.builder()
|
||||
.serverId(cachedMessage.getServerId())
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>coverage</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
@@ -35,7 +35,7 @@
|
||||
<scm>
|
||||
<url>https://maven.pkg.github.com/Sheldan/abstracto</url>
|
||||
<developerConnection>scm:git:git@github.com:Sheldan/abstracto.git</developerConnection>
|
||||
<tag>abstracto-application-1.4.0</tag>
|
||||
<tag>abstracto-application-1.4.2</tag>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
@@ -58,7 +58,6 @@
|
||||
<properties>
|
||||
<maven.build.timestamp.format>yyyy/MM/dd HH:mm</maven.build.timestamp.format>
|
||||
<jda.version>5.0.0-alpha.12</jda.version>
|
||||
<jda.utilities.version>3.0.4</jda.utilities.version>
|
||||
<asciidoctor.maven.plugin.version>2.0.0-RC.1</asciidoctor.maven.plugin.version>
|
||||
<asciidoctorj.pdf.version>1.5.3</asciidoctorj.pdf.version>
|
||||
<asciidoctorj.version>2.3.0</asciidoctorj.version>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>1.4.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
Reference in New Issue
Block a user