mirror of
https://github.com/Sheldan/OnePlusBot.git
synced 2026-01-02 15:56:29 +00:00
Compare commits
78 Commits
oneplusbot
...
oneplusbot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcfaf1c928 | ||
|
|
124d45ba5b | ||
|
|
4cdaf87412 | ||
|
|
13cf06e1dc | ||
|
|
e8ae0f430d | ||
|
|
cda9d1a2b8 | ||
|
|
653246f3ee | ||
|
|
0879c7cc93 | ||
|
|
4ea878dd42 | ||
|
|
562f5ae9e1 | ||
|
|
92925d176f | ||
|
|
6a5f45c416 | ||
|
|
c7e8fd315f | ||
|
|
95ad8fdd3a | ||
|
|
51775b454e | ||
|
|
aa4de8f571 | ||
|
|
eae07fd07c | ||
|
|
c492640cd7 | ||
|
|
2c49cf2918 | ||
|
|
60ac314ecc | ||
|
|
c82ef9ac18 | ||
|
|
6369ae7c01 | ||
|
|
f9b2174f84 | ||
|
|
d5c8509ab0 | ||
|
|
eaddea63b3 | ||
|
|
7dc141a8a4 | ||
|
|
6652c90edb | ||
|
|
d7f5fc21d6 | ||
|
|
bf98d5db3a | ||
|
|
57fb34920d | ||
|
|
3f959f3bbb | ||
|
|
0380720ec8 | ||
|
|
5bea74cb22 | ||
|
|
1b970ba0a8 | ||
|
|
a707b10cfd | ||
|
|
124d29769e | ||
|
|
d1aa2d5276 | ||
|
|
4d569d4ec0 | ||
|
|
81e58c3f7b | ||
|
|
c04041cb35 | ||
|
|
37e566a957 | ||
|
|
f7ca31a0c8 | ||
|
|
8da31831b0 | ||
|
|
ed5b821da3 | ||
|
|
cd875535d4 | ||
|
|
8a38dd3d1a | ||
|
|
86eac5f2a5 | ||
|
|
8644af678f | ||
|
|
6055a5e15f | ||
|
|
aa71ad3f97 | ||
|
|
2985e46979 | ||
|
|
93dfef5572 | ||
|
|
cab8cf1a8f | ||
|
|
2066a2254d | ||
|
|
75a5a1ff1a | ||
|
|
97eb1761e3 | ||
|
|
cc3d4f38ab | ||
|
|
c42b540bb6 | ||
|
|
3c56f9fb90 | ||
|
|
f0ecd2643d | ||
|
|
f943247e7d | ||
|
|
377b4ef478 | ||
|
|
a43e000d88 | ||
|
|
ba7db6a542 | ||
|
|
733d0ebd78 | ||
|
|
7e3fbe5ec6 | ||
|
|
f304b20fe7 | ||
|
|
c9d1114731 | ||
|
|
d8f37117c4 | ||
|
|
c1437373ff | ||
|
|
1e2ab7fbfa | ||
|
|
b3b16d0e74 | ||
|
|
d3d79e8803 | ||
|
|
bf448e167a | ||
|
|
1a135a9bb8 | ||
|
|
fa5abaaed4 | ||
|
|
2d98cbba81 | ||
|
|
f7502c76de |
42
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
42
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: Bug Report
|
||||
description: Found a bug that needs fixing?
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: General Troubleshooting
|
||||
description: You confirm to have made the following checks first.
|
||||
options:
|
||||
- label: I have checked for similar issues on the Issue-tracker.
|
||||
required: true
|
||||
- label: I have updated to the latest version
|
||||
required: true
|
||||
- label: I have checked the branches or the maintainers' PRs for upcoming bug fixes.
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Description"
|
||||
description: "General information about the bug"
|
||||
placeholder: "..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Steps to reproduce"
|
||||
description: "What happened when the bug occurred?"
|
||||
placeholder: "1. ..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Expected behaviour"
|
||||
description: "What should happen?"
|
||||
placeholder: "It should..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Actual behaviour"
|
||||
description: "What did happen instead?"
|
||||
placeholder: "It actually ..."
|
||||
validations:
|
||||
required: true
|
||||
36
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
36
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Feature request
|
||||
description: Want some functionality added?
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: General Information
|
||||
description: You confirm to have made the following checks first.
|
||||
options:
|
||||
- label: I have checked for similar issues on the Issue-tracker.
|
||||
required: true
|
||||
- label: I have updated to the latest version
|
||||
required: true
|
||||
- label: I have checked the branches or the maintainers' PRs for upcoming features fixes.
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Description"
|
||||
description: "General description of the feature"
|
||||
placeholder: "..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Feature worth and general use"
|
||||
description: "Why should this exist?"
|
||||
placeholder: "..."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Suggestions for implementation"
|
||||
description: "Any ideas about what the feature should behave/look like? Commands?"
|
||||
placeholder: "It should..."
|
||||
validations:
|
||||
required: false
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -34,5 +34,5 @@ jobs:
|
||||
env:
|
||||
REGISTRY_PREFIX: docker.pkg.github.com/sheldan/oneplusbot/
|
||||
VERSION: ${{ env.version }}
|
||||
ABSTRACTO_VERSION: 1.2.12
|
||||
ABSTRACTO_VERSION: 1.4.1
|
||||
ABSTRACTO_REGISTRY_PREFIX: docker.pkg.github.com/sheldan/abstracto/
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Sheldan
|
||||
Copyright (c) 2022 Sheldan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
148
PRIVACY_POLICY.md
Normal file
148
PRIVACY_POLICY.md
Normal file
@@ -0,0 +1,148 @@
|
||||
# r/oneplus Discord bot privacy policy
|
||||
|
||||
Last updated: 06.09.2021
|
||||
|
||||
## Description
|
||||
|
||||
The bot requires some information to function properly and in a reasonable way.
|
||||
The detailed list of what information is stored and processed is the following:
|
||||
|
||||
### General
|
||||
* your Discord user ID (in combination with the server ID) is used to uniquely identify you and associate various properties, such as experience, level, opened modmail threads etc
|
||||
* the IDs of the servers this bot is in
|
||||
* the IDs of the channel in the servers this bot is in
|
||||
* the names of channel groups which were given by their creator
|
||||
* the server aliases which were created for commands
|
||||
* the name of emotes which are used in the bot for convenience, if they are customized
|
||||
* towards which channel (identified by ID) certain messages by the bot are posted. e.g. logging, news, starboard
|
||||
* **no message content, username, channel name or role name is stored, except at the places where its mentioned**
|
||||
* a logfile is used in order to examine any malfunctions, the content is deleted after 7 days
|
||||
* most of the stored records have a 'created' and 'updated' timestamp, in order to assist in examining bugs and malfunctions
|
||||
* which commands have which cooldown in which channel group and in which channel group they are disabled
|
||||
* which channel is in which channel group
|
||||
* which role is allowed to execute which command
|
||||
* which features are enabled
|
||||
* which feature modes are enabled
|
||||
|
||||
### Moderation
|
||||
* the date of the latest report via the reaction report system, in order to disallow quick reports
|
||||
* mute reason, duration, mute date, who muted whom and in which message was the mute executed
|
||||
* the names of filtered invite link servers in order to find out if it would be valid to allow the invite
|
||||
* any configured allowed invite links the server ID and the actually used invite
|
||||
* this is necessary in order to determine the server via its ID and allow other unknown invite links. The invite link is necessary as there is no way to map server ID to actual server
|
||||
* configured profanity regexes
|
||||
* reported profanities, including which message contains the profanity, and the message which was used to report the profanity, and whether it was identified as a true profanity
|
||||
* messages and users which were reported via reaction reports and how many times they were reported, but not *who* reported a message
|
||||
* **the text of notes regarding users**
|
||||
* this is used to enable taking notes about users, and the content is stored directly
|
||||
* meta information regarding warnings
|
||||
* **reason for the warning**
|
||||
* date of the warning
|
||||
* the user who warned a user
|
||||
* whether the warning was decayed and when
|
||||
|
||||
### Embedded messages
|
||||
* embedded message information
|
||||
* this information includes who embedded which message in which channel and is deleted after a few days
|
||||
|
||||
### Emote usage tracking
|
||||
* the name of emotes which are being tracked in the emote usage tracking system for purely convenience reasons
|
||||
* **who** used which emote is **not** tracked
|
||||
* at which day an emote was used how many times
|
||||
|
||||
### News
|
||||
* general information about news posts
|
||||
* the source message of the command, the created news post, and the author in order to enable the update mechanism
|
||||
|
||||
### Referral system
|
||||
* the date of the latest referral post in order to enforce the referral bump mechanism
|
||||
|
||||
### Reminder
|
||||
* **the message content** in order to provide you with the reminder text
|
||||
* the date it was created, and the date it is due
|
||||
* the id of the message which contained the command
|
||||
* whether you have been reminded
|
||||
|
||||
### Starboard
|
||||
* the message which was the origin for the starboard post
|
||||
* the message which was the resulting starboard post
|
||||
* the author of the message and the amount of stars
|
||||
* who reacted to a starboard post
|
||||
* this is necessary to provide the information about 'top star giver' and to disallow duplicate starboard reactions
|
||||
|
||||
### Suggestion
|
||||
* *the message content* of the message used to create the suggestion
|
||||
* this was used for the message used to update the status of a suggestion, but this is currently disabled
|
||||
* the author of the suggestion and the message which has been posted in the suggestions channel
|
||||
* every suggestion will be deleted completely from the database a few days after it has reached a final state (rejected, denied, accepted)
|
||||
* whether you voted for a suggestion and which decision you took
|
||||
|
||||
### Leveling system
|
||||
* the amount of messages which were considered for the leveling system
|
||||
* it only considers a message once per minute, so it does not directly translate to your absolute message count
|
||||
* the amount of experience, and the experience level you have
|
||||
* whether experience gain has been disabled for you
|
||||
* the role you received because of the experience system
|
||||
* which roles are configured to be used as experience roles and at which level they are assigned
|
||||
* which roles are used to disable experience gain
|
||||
|
||||
### FAQ
|
||||
* the names of FAQ commands
|
||||
* in which channel groups a FAQ command has a response
|
||||
* the aliases of FAQ commands
|
||||
* information about the actual FAQ message
|
||||
* the **content** of the message
|
||||
* the **URL** of the image used
|
||||
* the color of the embed to be used
|
||||
* the ID of the user to be used as author
|
||||
* the amount of times a FAQ response has been used
|
||||
|
||||
### Assignable roles
|
||||
* the names of assignable role places and assignable role button text, together with the associated emote markdown (if given)
|
||||
* the assigned assignable roles for each member in order to provide the 'unique' assignable role functionality
|
||||
|
||||
## Grafana dashboard
|
||||
|
||||
There is also a [Grafana](https://grafana.com/) dashboard in order to inspect how the bot is operating.
|
||||
The information visible in this dashboard is:
|
||||
|
||||
* message events
|
||||
* Discord gateway ping
|
||||
* starboard reactions
|
||||
* amount of command executions
|
||||
* emotes currently being processed for tracking
|
||||
* embedded messages
|
||||
* invite filter activity
|
||||
* amount of experience which is currently being processed
|
||||
|
||||
All of this information cannot be linked to any user (or any server for that matter, if the bot would be in multiple servers) and is deleted after 15 days.
|
||||
|
||||
|
||||
## How can I decide which information is collected?
|
||||
It is not possible to opt-out of singular sub-services of the bot. Should you decide that your information should not be collected, please cease usage of the bot immediately (leave any guild the bot operates in).
|
||||
|
||||
_Should you decide to no longer utilize the bot, you may request your data to be erased within 30 days as per GDPR if you are a citizen of the EU. You can do this by sending an email to oneplus.appeals@pm.me with the subject: GDPR Data removal <Username#0000> <UserId>. If your request is incomplete, we cannot acknowledge it and therefore your data will not be removed. In order to identify authentic requests, please contact modmail beforehand by sending a direct message to the bot and stating your intention._
|
||||
|
||||
|
||||
## Legal information
|
||||
The bot is not an official application from OnePlus or OPPO. You agree to use the bot at your own risk. The developers of the bot are not responsible for any damage done to your device, your computer or any other property.
|
||||
|
||||
We cannot promise you, as the user, to always update you when this Privacy Policy has changed. You can check the most recent version here. Important changes will be posted in the bot changelog channel of the r/oneplus Discord server.
|
||||
|
||||
OnePlus and OPPO are legal owners of OxygenOS. Visit https://oneplus.com/brand to view information about OnePlus.
|
||||
|
||||
## Open source content
|
||||
This bot uses the following open source libraries and frameworks:
|
||||
|
||||
* [abstracto](https://github.com/Sheldan/abstracto) is used as a base for this bot, providing a lot of the functionalities
|
||||
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper used
|
||||
* [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including Dependency injection and more)
|
||||
* [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA.
|
||||
* [Freemarker](https://github.com/apache/freemarker) is used as a templating engine. This is used to provide internationalization for user facing text and enable dynamic embed configuration.
|
||||
* [Ehcache](https://github.com/ehcache/ehcache3) is used as a caching implementation.
|
||||
* [Lombok](https://github.com/rzwitserloot/lombok) is used as a framework in order to speed up creation of container classes and builders.
|
||||
* [Quartz](https://github.com/quartz-scheduler/quartz) is used as a scheduling framework in order to provide functionalities which either require a delayed or cronjob behaviour.
|
||||
* [Docker](https://github.com/docker) is used to package the application into a container and [Docker Compose](https://github.com/docker/compose) is used to orchestrate the containers
|
||||
* [Liquibase](https://github.com/liquibase/liquibase) is used to manage changes to the database
|
||||
* [Prometheus](https://prometheus.io) to scrap and collect the metrics about how the bot is operating
|
||||
* [Grafana](https://grafana.com) to visualize metrics of the bot
|
||||
16
README.md
16
README.md
@@ -1,11 +1,21 @@
|
||||
# r/oneplus Discord server bot
|
||||
|
||||
This repository contains the rewrite of the [Bot](https://github.com/Rithari/OnePlusBot), which is still in use. The features will be gradually be ported
|
||||
and most of them will be in [abstracto](https://github.com/Sheldan/abstracto), but some of the features need to be customized, as they are r/oneplus specific.
|
||||
This repository contains the rewrite of the [Bot](https://github.com/Rithari/OnePlusBot). It is developed by customizing [abstracto](https://github.com/Sheldan/abstracto), because some features are r/oneplus specific.
|
||||
|
||||
The migration of the existing data from the database is handled via one time migration, and can be found [here](https://github.com/Sheldan/OnePlusBot-migration).
|
||||
|
||||
The FAQ configuration can be found [here](https://github.com/Sheldan/OnePlusBot-faq/).
|
||||
|
||||
Custom features which were ported
|
||||
- [ ] FAQ
|
||||
- [x] FAQ
|
||||
- [x] Setup channel handling
|
||||
- [x] Referral link handling
|
||||
|
||||
# Technologies used in addition to the ones provided in abstracto
|
||||
- [grafana](https://github.com/grafana/grafana) for visualization of the bot status and metrics
|
||||
- [Loki](https://github.com/grafana/loki) to visualize and query log files
|
||||
- [pgAdmin](https://github.com/postgres/pgadmin4) to view the database
|
||||
- [prometheus](https://github.com/prometheus/prometheus) for metric collection
|
||||
- [postgres](https://github.com/postgres/postgres) as a database
|
||||
- [loki](https://github.com/grafana/loki) for log aggregation
|
||||
|
||||
34
application/database/pom.xml
Normal file
34
application/database/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>dev.sheldan.oneplus.bot.application</groupId>
|
||||
<artifactId>application</artifactId>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>database</artifactId>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/liquibase.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
18
application/database/src/main/assembly/liquibase.xml
Normal file
18
application/database/src/main/assembly/liquibase.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>liquibase</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<outputDirectory>.</outputDirectory>
|
||||
<directory>${project.basedir}/src/main/resources/migrations</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="structure/structure.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="create_grafana_user">
|
||||
<sql>
|
||||
CREATE USER ${abstractografanadbuser} WITH PASSWORD '${abstractografanadbpass}';
|
||||
GRANT CONNECT ON DATABASE abstracto TO ${abstractografanadbuser};
|
||||
GRANT USAGE ON SCHEMA abstracto TO ${abstractografanadbuser};
|
||||
GRANT SELECT ON ALL TABLES IN SCHEMA abstracto TO ${abstractografanadbuser};
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA abstracto
|
||||
GRANT SELECT ON TABLES TO ${abstractografanadbuser};
|
||||
</sql>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="grafana_user.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="1.5.4/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
1386
application/database/src/main/resources/migrations/dbchangelog.xsd
Normal file
1386
application/database/src/main/resources/migrations/dbchangelog.xsd
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.oneplus.bot.application</groupId>
|
||||
<artifactId>application</artifactId>
|
||||
<version>1.3.12</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>executable</artifactId>
|
||||
@@ -100,11 +100,36 @@
|
||||
<artifactId>starboard-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>voice-channel-context-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>dynamic-activity-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>logging-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>anti-raid-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>invite-filter-impl</artifactId>
|
||||
@@ -120,12 +145,28 @@
|
||||
<artifactId>profanity-filter-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation-impl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
|
||||
<artifactId>starboard-custom</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
|
||||
<artifactId>moderation-custom</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
|
||||
<artifactId>news</artifactId>
|
||||
@@ -144,6 +185,18 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
|
||||
<artifactId>faq</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
|
||||
<artifactId>seasonal</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -29,7 +29,26 @@
|
||||
|
||||
</appender>
|
||||
|
||||
<appender name="requests-file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_PATH}/requests_log.log</file>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>
|
||||
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>
|
||||
${LOG_PATH}/archived/requests_log_%d{dd-MM-yyyy}.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<logger name="dev.sheldan.abstracto" level="INFO"/>
|
||||
<logger name="dev.sheldan.abstracto.core.logging" level="DEBUG">
|
||||
<appender-ref ref="requests-file"/>
|
||||
</logger>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="logFileAppender"/>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
|
||||
<artifactId>oneplus-bot-customizations</artifactId>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>dynamic-activity-custom</artifactId>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/liquibase.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,18 @@
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>liquibase</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<outputDirectory>.</outputDirectory>
|
||||
<directory>${project.basedir}/src/main/resources/migrations</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="dynamic_activity-insertion">
|
||||
<insert tableName="activity">
|
||||
<column name="type" value="STREAMING"/>
|
||||
<column name="template_key" value="fans"/>
|
||||
</insert>
|
||||
<insert tableName="activity">
|
||||
<column name="type" value="STREAMING"/>
|
||||
<column name="template_key" value="help"/>
|
||||
</insert>
|
||||
<insert tableName="activity">
|
||||
<column name="type" value="STREAMING"/>
|
||||
<column name="template_key" value="modmail"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="activity.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="1.5.1/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>oneplus-bot-customizations</artifactId>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>moderation-custom</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation-int</artifactId>
|
||||
<version>${abstracto.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/liquibase.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,18 @@
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>liquibase</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<outputDirectory>.</outputDirectory>
|
||||
<directory>${project.basedir}/src/main/resources/migrations</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
@@ -0,0 +1,52 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.commands;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.moderation.config.ModerationModuleDefinition;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.config.ModerationCustomFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.service.ModModeServiceBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
public class ModMode extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private ModModeServiceBean modModeServiceBean;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
Boolean newState = (Boolean) commandContext.getParameters().getParameters().get(0);
|
||||
return modModeServiceBean.setModModeTo(commandContext.getGuild(), newState)
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter newStateParameter = Parameter.builder().name("newState").templated(true).type(Boolean.class).build();
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("modMode")
|
||||
.async(true)
|
||||
.module(ModerationModuleDefinition.MODERATION)
|
||||
.parameters(Collections.singletonList(newStateParameter))
|
||||
.help(helpInfo)
|
||||
.templated(true)
|
||||
.supportsEmbedException(true)
|
||||
.causesReaction(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return ModerationCustomFeatureDefinition.MODERATION_CUSTOM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import dev.sheldan.abstracto.moderation.config.feature.ModerationFeatureConfig;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.service.ModModeServiceBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
public class ModerationCustomFeature implements FeatureConfig {
|
||||
|
||||
public static final String WARN_NOTIFICATION_THRESHOLD = "warnNotificationThreshold";
|
||||
|
||||
@Autowired
|
||||
private ModerationFeatureConfig moderationFeatureConfig;
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return ModerationCustomFeatureDefinition.MODERATION_CUSTOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FeatureConfig> getRequiredFeatures() {
|
||||
return Arrays.asList(moderationFeatureConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||
return Arrays.asList(ModerationCustomPostTarget.WARN_THRESHOLD_NOTIFICATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
return Arrays.asList(ModModeServiceBean.MODMODE_ROLE_CONFIG_KEY,
|
||||
ModModeServiceBean.MODMODE_CHANGED_ROLE_COLOR_CONFIG_KEY, WARN_NOTIFICATION_THRESHOLD);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ModerationCustomFeatureDefinition implements FeatureDefinition {
|
||||
MODERATION_CUSTOM("moderationCustom");
|
||||
|
||||
private String key;
|
||||
|
||||
ModerationCustomFeatureDefinition(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ModerationCustomPostTarget implements PostTargetEnum {
|
||||
WARN_THRESHOLD_NOTIFICATION("warnThresholdNotification");
|
||||
|
||||
private String key;
|
||||
|
||||
ModerationCustomPostTarget(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:moderation-custom.properties")
|
||||
public class ModerationCustomProperties {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
|
||||
public class ModRoleNotFoundException extends AbstractoTemplatableException {
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "mod_role_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.models.template.display.ChannelDisplay;
|
||||
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||
import dev.sheldan.abstracto.core.service.*;
|
||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||
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.moderation.listener.WarningCreatedListener;
|
||||
import dev.sheldan.abstracto.moderation.model.listener.WarningCreatedEventModel;
|
||||
import dev.sheldan.abstracto.moderation.service.management.WarnManagementService;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.config.ModerationCustomFeature;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.config.ModerationCustomFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.config.ModerationCustomPostTarget;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.model.template.WarningThresholdNotificationModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WarningAddedListener implements WarningCreatedListener {
|
||||
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private WarnManagementService warnManagementService;
|
||||
|
||||
@Autowired
|
||||
private UserInServerManagementService userInServerManagementService;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private PostTargetService postTargetService;
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
public static final String WARN_THRESHOLD_NOTIFICATION_TEMPLATE_KEY = "warning_threshold_notification";
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(WarningCreatedEventModel model) {
|
||||
Long warnNotificationAmount = configService.getLongValueOrConfigDefault(ModerationCustomFeature.WARN_NOTIFICATION_THRESHOLD, model.getServerId());
|
||||
ServerUser warnedUser = ServerUser
|
||||
.builder()
|
||||
.userId(model.getWarnedUserId())
|
||||
.serverId(model.getServerId())
|
||||
.build();
|
||||
AUserInAServer warnedUserInAServer = userInServerManagementService.loadOrCreateUser(warnedUser);
|
||||
List<Long> activeWarnsForUser = warnManagementService.getActiveWarnsForUser(warnedUserInAServer)
|
||||
.stream().map(warning -> warning.getWarnId().getId()).collect(Collectors.toList());
|
||||
Set<Long> warnIds = new HashSet<>(activeWarnsForUser);
|
||||
// we cant be sure we receive the newly persisted warning yet, sadly
|
||||
warnIds.add(model.getWarningId());
|
||||
if(warnIds.size() == warnNotificationAmount) {
|
||||
Long serverId = model.getServerId();
|
||||
|
||||
Long channelId = model.getWarningChannelId();
|
||||
Long warnedUserId = model.getWarnedUserId();
|
||||
GuildMessageChannel channel = channelService.getMessageChannelFromServer(serverId, channelId);
|
||||
WarningThresholdNotificationModel notificationModel = WarningThresholdNotificationModel
|
||||
.builder()
|
||||
.channelDisplay(ChannelDisplay.fromChannel(channel))
|
||||
.memberDisplay(MemberDisplay.fromAUserInAServer(warnedUserInAServer))
|
||||
.messageId(model.getWarningMessageId())
|
||||
.warnCount(warnIds.size())
|
||||
.build();
|
||||
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(WARN_THRESHOLD_NOTIFICATION_TEMPLATE_KEY, notificationModel, serverId);
|
||||
FutureUtils.toSingleFutureGeneric(postTargetService.sendEmbedInPostTarget(messageToSend, ModerationCustomPostTarget.WARN_THRESHOLD_NOTIFICATION, serverId))
|
||||
.thenAccept(unused -> log.info("Warn threshold notification sent for user {} in server {}.", warnedUserId, serverId))
|
||||
.exceptionally(throwable -> {
|
||||
log.error("Failed to sent warn threshold notification for user {} in server {}.", warnedUserId, serverId, throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return DefaultListenerResult.PROCESSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return ModerationCustomFeatureDefinition.MODERATION_CUSTOM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.model.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.template.display.ChannelDisplay;
|
||||
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class WarningThresholdNotificationModel {
|
||||
private MemberDisplay memberDisplay;
|
||||
private Integer warnCount;
|
||||
private ChannelDisplay channelDisplay;
|
||||
private Long messageId;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package dev.sheldan.oneplus.bot.custom.moderation.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||
import dev.sheldan.oneplus.bot.custom.moderation.exception.ModRoleNotFoundException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ModModeServiceBean {
|
||||
public static final String MODMODE_ROLE_CONFIG_KEY = "modModeRoleId";
|
||||
public static final String MODMODE_CHANGED_ROLE_COLOR_CONFIG_KEY = "modModeNewRoleColor";
|
||||
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
|
||||
public CompletableFuture<Void> setModModeTo(Guild guild, Boolean newState) {
|
||||
if(Boolean.TRUE.equals(newState)) {
|
||||
return enableModMode(guild);
|
||||
} else {
|
||||
return disableModMoe(guild);
|
||||
}
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> enableModMode(Guild guild) {
|
||||
Color colorToSet = getColorFromConfig(MODMODE_CHANGED_ROLE_COLOR_CONFIG_KEY, guild);
|
||||
return setModRoleTo(guild, colorToSet);
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> disableModMoe(Guild guild) {
|
||||
return setModRoleTo(guild, null);
|
||||
}
|
||||
|
||||
private Color getColorFromConfig(String key, Guild guild) {
|
||||
String colorString = configService.getStringValueOrConfigDefault(key, guild.getIdLong());
|
||||
String[] parts = colorString.split(",");
|
||||
return new Color(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> setModRoleTo(Guild guild, Color color) {
|
||||
Long roleId = configService.getLongValue(MODMODE_ROLE_CONFIG_KEY, guild.getIdLong());
|
||||
Role modRole = guild.getRoleById(roleId);
|
||||
if(modRole != null) {
|
||||
return modRole.getManager().setColor(color).submit();
|
||||
} else {
|
||||
throw new ModRoleNotFoundException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<property name="moderationCustomFeature" value="(SELECT id FROM feature WHERE key = 'moderationCustom')"/>
|
||||
<property name="moderationModule" value="(SELECT id FROM module WHERE name = 'moderation')"/>
|
||||
<changeSet author="Sheldan" id="moderationCustom_modmode-commands">
|
||||
<insert tableName="command">
|
||||
<column name="name" value="modMode"/>
|
||||
<column name="module_id" valueComputed="${moderationModule}"/>
|
||||
<column name="feature_id" valueComputed="${moderationCustomFeature}"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="feature.xml" relativeToChangelogFile="true"/>
|
||||
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="moderation_custom_feature-insertion">
|
||||
<insert tableName="feature">
|
||||
<column name="key" value="moderationCustom"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="1.5.2/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,13 @@
|
||||
abstracto.featureFlags.moderationCustom.featureName=moderationCustom
|
||||
abstracto.featureFlags.moderationCustom.enabled=false
|
||||
|
||||
abstracto.systemConfigs.modModeRoleId.name=modModeRoleId
|
||||
abstracto.systemConfigs.modModeRoleId.longValue=0
|
||||
|
||||
abstracto.systemConfigs.modModeNewRoleColor.name=modModeNewRoleColor
|
||||
abstracto.systemConfigs.modModeNewRoleColor.stringValue=0,0,0
|
||||
|
||||
abstracto.systemConfigs.warnNotificationThreshold.name=warnNotificationThreshold
|
||||
abstracto.systemConfigs.warnNotificationThreshold.longValue=3
|
||||
|
||||
abstracto.postTargets.warnThresholdNotification.name=warnThresholdNotification
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.oneplus.bot.application</groupId>
|
||||
<artifactId>application</artifactId>
|
||||
<version>1.3.12</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -13,5 +13,7 @@
|
||||
|
||||
<modules>
|
||||
<module>starboard-custom</module>
|
||||
<module>dynamic-activity-custom</module>
|
||||
<module>moderation-custom</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.custom</groupId>
|
||||
<artifactId>oneplus-bot-customizations</artifactId>
|
||||
<version>1.3.12</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
46
application/oneplus-bot-modules/faq/pom.xml
Normal file
46
application/oneplus-bot-modules/faq/pom.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>oneplus-bot-modules</artifactId>
|
||||
<groupId>dev.sheldan.oneplus.bot.application.modules</groupId>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>faq</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/liquibase.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,18 @@
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>liquibase</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<outputDirectory>.</outputDirectory>
|
||||
<directory>${project.basedir}/src/main/resources/migrations</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
@@ -0,0 +1,75 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.JSONValidationService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FileService;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQModuleDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DeleteFAQ extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
|
||||
@Autowired
|
||||
private FAQServiceBean faqServiceBean;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private JSONValidationService jsonValidationService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
List<Object> parameter = commandContext.getParameters().getParameters();
|
||||
String faqCommandName = (String) parameter.get(0);
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
faqServiceBean.deleteFAQCommand(faqCommandName, server);
|
||||
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter fileAttachmentParameter = Parameter.builder().name("commandName").type(String.class).templated(true).build();
|
||||
List<Parameter> parameters = Arrays.asList(fileAttachmentParameter);
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("deleteFAQ")
|
||||
.module(FAQModuleDefinition.FAQ)
|
||||
.parameters(parameters)
|
||||
.supportsEmbedException(true)
|
||||
.help(helpInfo)
|
||||
.async(true)
|
||||
.templated(true)
|
||||
.causesReaction(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return FAQFeatureDefinition.FAQ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQModuleDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ExportFAQ extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private FAQServiceBean faqServiceBean;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
String configString;
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild().getIdLong());
|
||||
if(parameters.isEmpty()) {
|
||||
configString = faqServiceBean.exportFAQConfig(server);
|
||||
} else {
|
||||
String commandName = (String) parameters.get(0);
|
||||
configString = faqServiceBean.exportFAQConfig(commandName, server);
|
||||
}
|
||||
return FutureUtils.toSingleFutureGeneric(channelService.sendFileToChannel(configString, "faqConfig.json", commandContext.getChannel()))
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter commandNameParameter = Parameter.builder().name("commandName").type(String.class).optional(true).templated(true).build();
|
||||
List<Parameter> parameters = Arrays.asList(commandNameParameter);
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("exportFAQ")
|
||||
.module(FAQModuleDefinition.FAQ)
|
||||
.parameters(parameters)
|
||||
.supportsEmbedException(true)
|
||||
.help(helpInfo)
|
||||
.async(true)
|
||||
.templated(true)
|
||||
.causesReaction(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return FAQFeatureDefinition.FAQ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQModuleDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.faq.FAQResponseModel;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQResponseServiceBean;
|
||||
import net.dv8tion.jda.api.entities.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
public class FAQ extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private FAQResponseServiceBean faqService;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Autowired
|
||||
private ChannelManagementService channelManagementService;
|
||||
|
||||
private static final String FAQ_RESPONSE_TEMPLATE_KEY = "FAQ_response";
|
||||
private static final String FAQ_RESPONSE_NO_COMMAND_FOUND_TEMPLATE_KEY = "FAQ_response_no_command_found";
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
String commandName;
|
||||
if(!parameters.isEmpty()) {
|
||||
commandName = (String) parameters.get(0);
|
||||
GuildMessageChannel channel;
|
||||
if (parameters.size() == 2) {
|
||||
channel = (TextChannel) parameters.get(1);
|
||||
} else {
|
||||
channel = commandContext.getChannel();
|
||||
}
|
||||
return faqService.loadFAQResponse(commandName, channel)
|
||||
.thenCompose(faqResponseModel -> {
|
||||
if (!faqResponseModel.getMessages().isEmpty()) {
|
||||
List<CompletableFuture<Void>> messageFutures = new ArrayList<>();
|
||||
faqResponseModel
|
||||
.getMessages()
|
||||
.forEach(faqResponseMessageModel ->
|
||||
messageFutures.add(FutureUtils.
|
||||
toSingleFutureGeneric(channelService.
|
||||
sendEmbedTemplateInTextChannelList(FAQ_RESPONSE_TEMPLATE_KEY,
|
||||
faqResponseMessageModel, commandContext.getChannel()))));
|
||||
return FutureUtils.toSingleFutureGeneric(messageFutures);
|
||||
} else {
|
||||
return FutureUtils
|
||||
.toSingleFutureGeneric(
|
||||
channelService.
|
||||
sendEmbedTemplateInTextChannelList(FAQ_RESPONSE_NO_COMMAND_FOUND_TEMPLATE_KEY,
|
||||
faqResponseModel, commandContext.getChannel()));
|
||||
}
|
||||
})
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
} else {
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
AChannel channel = channelManagementService.loadChannel(commandContext.getChannel());
|
||||
FAQResponseModel model = faqService.getNoCommandFoundModel(server, channel);
|
||||
return FutureUtils
|
||||
.toSingleFutureGeneric(
|
||||
channelService.
|
||||
sendEmbedTemplateInTextChannelList(FAQ_RESPONSE_NO_COMMAND_FOUND_TEMPLATE_KEY,
|
||||
model, commandContext.getChannel()))
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter commandNameParameter = Parameter.builder().name("command").type(String.class).templated(true).optional(true).build();
|
||||
Parameter channelParameter = Parameter.builder().name("channel").type(TextChannel.class).optional(true).templated(true).build();
|
||||
List<Parameter> parameters = Arrays.asList(commandNameParameter, channelParameter);
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("FAQ")
|
||||
.module(FAQModuleDefinition.FAQ)
|
||||
.parameters(parameters)
|
||||
.supportsEmbedException(true)
|
||||
.help(helpInfo)
|
||||
.async(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return FAQFeatureDefinition.FAQ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.config.FeatureMode;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureMode;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQModuleDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.faquses.FAQUsageModel;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQUsageServiceBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FAQUsage extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private FAQUsageServiceBean faqUsageServiceBean;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
private static final String FAQ_USAGE_RESPONSE_TEMPLATE_KEY = "FAQUsage_response";
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
FAQUsageModel model;
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
if(parameters.isEmpty()) {
|
||||
model = faqUsageServiceBean.getFAQUsageModel(server);
|
||||
} else {
|
||||
String commandName = (String) parameters.get(0);
|
||||
model = faqUsageServiceBean.getFAQUsageModel(server, commandName);
|
||||
}
|
||||
|
||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(FAQ_USAGE_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter commandNameParameter = Parameter.builder().name("commandName").type(String.class).templated(true).optional(true).build();
|
||||
List<Parameter> parameters = Arrays.asList(commandNameParameter);
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("FAQUsage")
|
||||
.module(FAQModuleDefinition.FAQ)
|
||||
.parameters(parameters)
|
||||
.supportsEmbedException(true)
|
||||
.help(helpInfo)
|
||||
.async(true)
|
||||
.templated(true)
|
||||
.causesReaction(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return FAQFeatureDefinition.FAQ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FeatureMode> getFeatureModeLimitations() {
|
||||
return Arrays.asList(FAQFeatureMode.FAQ_USES);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.exception.AbstractoTemplatedException;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.models.JSONValidationResult;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.JSONValidationService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FileService;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQModuleDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.config.FaqCommandConfig;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQValidationServiceBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.everit.json.schema.ValidationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ImportFAQ extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
|
||||
@Autowired
|
||||
private FAQServiceBean faqServiceBean;
|
||||
|
||||
@Autowired
|
||||
private FAQValidationServiceBean faqValidationServiceBean;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private JSONValidationService jsonValidationService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
List<Object> parameter = commandContext.getParameters().getParameters();
|
||||
File jsonConfigFile = (File) parameter.get(0);
|
||||
try {
|
||||
String jsonContent = FileUtils.readFileToString(jsonConfigFile, StandardCharsets.UTF_8);
|
||||
JSONValidationResult result = faqValidationServiceBean.validateJSONForCreation(jsonContent);
|
||||
if(result.getResult().equals(JSONValidationService.Result.SUCCESSFUL)) {
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
List<FaqCommandConfig> commands = faqServiceBean.loadFAQCommandsFromJson(jsonContent);
|
||||
faqServiceBean.createOrUpdateFAQCommands(commands, server);
|
||||
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
|
||||
} else {
|
||||
|
||||
List<String> errors = jsonValidationService.getDetailedException(result.getExceptions())
|
||||
.stream()
|
||||
.map(ValidationException::getMessage)
|
||||
.collect(Collectors.toList());
|
||||
channelService.sendTextToChannel(String.join("\n", errors), commandContext.getChannel());
|
||||
return CompletableFuture.completedFuture(CommandResult.fromError("Incorrect faq config."));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("IO Exception when loading input file.", e);
|
||||
throw new AbstractoTemplatedException("Failed to load json config.", "failed_to_set_template_exception", e);
|
||||
} finally {
|
||||
try {
|
||||
fileService.safeDelete(jsonConfigFile);
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to delete downloaded json file.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter fileAttachmentParameter = Parameter.builder().name("file").type(File.class).templated(true).build();
|
||||
List<Parameter> parameters = Arrays.asList(fileAttachmentParameter);
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("importFAQ")
|
||||
.module(FAQModuleDefinition.FAQ)
|
||||
.parameters(parameters)
|
||||
.supportsEmbedException(true)
|
||||
.help(helpInfo)
|
||||
.async(true)
|
||||
.templated(true)
|
||||
.causesReaction(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return FAQFeatureDefinition.FAQ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQFeatureDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.FAQModuleDefinition;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.list.ListFAQCommandsModel;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ListFAQCommands extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private FAQServiceBean faqServiceBean;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
private static final String LIST_FAQ_COMMANDS_RESPONSE_TEMPLATE_KEY = "listFAQCommands_response";
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
ListFAQCommandsModel model = faqServiceBean.getCommandListingForServer(server);
|
||||
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(LIST_FAQ_COMMANDS_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("listFAQCommands")
|
||||
.module(FAQModuleDefinition.FAQ)
|
||||
.supportsEmbedException(true)
|
||||
.help(helpInfo)
|
||||
.async(true)
|
||||
.templated(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return FAQFeatureDefinition.FAQ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.core.config.FeatureMode;
|
||||
import dev.sheldan.abstracto.core.interactive.AutoDelayedAction;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.config.setup.GlobalChannelGroupDelayedActionConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class FAQFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Autowired
|
||||
private GlobalChannelGroupDelayedActionConfig globalChannelGroupDelayedActionConfig;
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return FAQFeatureDefinition.FAQ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AutoDelayedAction> getAutoSetupSteps() {
|
||||
return Arrays.asList(globalChannelGroupDelayedActionConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FeatureMode> getAvailableModes() {
|
||||
return Arrays.asList(FAQFeatureMode.FAQ_USES);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum FAQFeatureDefinition implements FeatureDefinition {
|
||||
FAQ("faq");
|
||||
|
||||
private String key;
|
||||
|
||||
FAQFeatureDefinition(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureMode;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum FAQFeatureMode implements FeatureMode {
|
||||
FAQ_USES("faqUses");
|
||||
|
||||
private final String key;
|
||||
|
||||
FAQFeatureMode(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.config.ModuleDefinition;
|
||||
import dev.sheldan.abstracto.core.command.config.ModuleInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FAQModuleDefinition implements ModuleDefinition {
|
||||
|
||||
public static final String FAQ = "faqModule";
|
||||
|
||||
@Override
|
||||
public ModuleInfo getInfo() {
|
||||
return ModuleInfo.builder().name(FAQ).templated(true).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentModule() {
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:faq.properties")
|
||||
public class FAQProperties {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config.setup;
|
||||
|
||||
import dev.sheldan.abstracto.core.interactive.DelayedActionConfig;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class GlobalChannelGroupDelayActionConfig implements DelayedActionConfig {
|
||||
|
||||
private Long serverId;
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "setup_global_channel_group_info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config.setup;
|
||||
|
||||
import dev.sheldan.abstracto.core.interactive.AutoDelayedAction;
|
||||
import dev.sheldan.abstracto.core.interactive.DelayedActionConfig;
|
||||
import dev.sheldan.abstracto.core.models.AServerChannelUserId;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class GlobalChannelGroupDelayedActionConfig implements AutoDelayedAction {
|
||||
@Override
|
||||
public DelayedActionConfig getDelayedActionConfig(AServerChannelUserId aServerChannelUserId) {
|
||||
return GlobalChannelGroupDelayActionConfig
|
||||
.builder()
|
||||
.serverId(aServerChannelUserId.getGuildId())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.config.setup;
|
||||
|
||||
import dev.sheldan.abstracto.core.interactive.DelayedAction;
|
||||
import dev.sheldan.abstracto.core.interactive.DelayedActionConfig;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.models.database.ChannelGroupType;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelGroupManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelGroupTypeManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean.FAQ_CHANNEL_GROUP_KEY;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class GlobalChannelGroupSetupDelayedAction implements DelayedAction {
|
||||
|
||||
@Autowired
|
||||
private ChannelGroupManagementService channelGroupManagementService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Autowired
|
||||
private ChannelGroupTypeManagementService channelGroupTypeManagementService;
|
||||
|
||||
@Value("${abstracto.faq.globalChannelGroupName}")
|
||||
private String globalChannelGroupName;
|
||||
|
||||
@Override
|
||||
public void execute(DelayedActionConfig delayedActionConfig) {
|
||||
GlobalChannelGroupDelayActionConfig config = (GlobalChannelGroupDelayActionConfig) delayedActionConfig;
|
||||
AServer server = serverManagementService.loadServer(config.getServerId());
|
||||
if(!channelGroupManagementService.doesChannelGroupExist(globalChannelGroupName, server)) {
|
||||
ChannelGroupType faqChannelGroupType = channelGroupTypeManagementService.findChannelGroupTypeByKey(FAQ_CHANNEL_GROUP_KEY);
|
||||
channelGroupManagementService.createChannelGroup(globalChannelGroupName, server, faqChannelGroupType);
|
||||
} else {
|
||||
log.info("Global channel group named {} already exists for server {}.", globalChannelGroupName, config.getServerId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handles(DelayedActionConfig delayedActionConfig) {
|
||||
return delayedActionConfig instanceof GlobalChannelGroupDelayActionConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.converter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import dev.sheldan.abstracto.core.service.BotService;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.config.*;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQChannelGroupCommand;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQCommand;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQCommandResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class FAQCommandConfigConverter {
|
||||
|
||||
@Autowired
|
||||
private Gson gson;
|
||||
|
||||
@Autowired
|
||||
private BotService botService;
|
||||
|
||||
public String serializeCommands(List<FAQCommand> asList) {
|
||||
Long botId = botService.getInstance().getSelfUser().getIdLong();
|
||||
asList.sort(Comparator.comparing(FAQCommand::getName));
|
||||
List<FaqCommandConfig> config = asList.stream().map(faqCommand -> {
|
||||
List<FAQChannelGroupCommand> responses = faqCommand.getGroupResponses();
|
||||
responses.sort(Comparator.comparing(groupCommand -> groupCommand.getChannelGroup().getChannelGroup().getGroupName()));
|
||||
List<FaqCommandResponseConfig> commandResponseConfigs = convertGroupCommands(responses, botId);
|
||||
List<String> aliases;
|
||||
if(faqCommand.getAliases() != null) {
|
||||
aliases = faqCommand.getAliases().stream().map(faqCommandAlias -> faqCommandAlias.getId().getAlias()).collect(Collectors.toList());
|
||||
} else {
|
||||
aliases = new ArrayList<>();
|
||||
}
|
||||
return FaqCommandConfig
|
||||
.builder()
|
||||
.faqCommandName(faqCommand.getName())
|
||||
.global(faqCommand.getGlobal())
|
||||
.responses(commandResponseConfigs)
|
||||
.aliases(aliases)
|
||||
.build();
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return gson.toJson(config);
|
||||
}
|
||||
|
||||
private List<FaqCommandResponseConfig> convertGroupCommands(List<FAQChannelGroupCommand> responses, Long botUserId) {
|
||||
return responses.stream().map(faqChannelGroupCommand -> {
|
||||
List<FaqCommandResponseMessageConfig> responseConfigs = convertCommandResponses(faqChannelGroupCommand.getResponses(), botUserId);
|
||||
return FaqCommandResponseConfig
|
||||
.builder()
|
||||
.channelGroupName(faqChannelGroupCommand.getChannelGroup().getChannelGroup().getGroupName())
|
||||
.messages(responseConfigs)
|
||||
.build();
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<FaqCommandResponseMessageConfig> convertCommandResponses(List<FAQCommandResponse> responses, Long botUserId) {
|
||||
return responses.stream().map(response -> convertCommandResponse(response, botUserId)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private FaqCommandResponseMessageConfig convertCommandResponse(FAQCommandResponse response, Long botUserId) {
|
||||
FaqCommandResponseEmbedConfig embedConfig = null;
|
||||
// one of those must not be null, for it to be considered a proper embed
|
||||
if(response.getDescription() != null || response.getImageURL() != null) {
|
||||
boolean useBot = response.getAuthorUserId().equals(botUserId);
|
||||
FaqCommandResponseEmbedColorConfig colorConfig = FaqCommandResponseEmbedColorConfig
|
||||
.builder()
|
||||
.red(response.getRed())
|
||||
.green(response.getGreen())
|
||||
.blue(response.getBlue())
|
||||
.build();
|
||||
FaqCommandResponseEmbedAuthorConfig authorConfig = FaqCommandResponseEmbedAuthorConfig
|
||||
.builder()
|
||||
.userId(useBot ? null : response.getAuthorUserId())
|
||||
.useBot(useBot)
|
||||
.build();
|
||||
embedConfig = FaqCommandResponseEmbedConfig
|
||||
.builder()
|
||||
.description(response.getDescription())
|
||||
.imageUrl(response.getImageURL())
|
||||
.color(colorConfig)
|
||||
.author(authorConfig)
|
||||
.build();
|
||||
}
|
||||
return FaqCommandResponseMessageConfig
|
||||
.builder()
|
||||
.position(response.getId().getPosition())
|
||||
.additionalMessage(response.getAdditionalMessage())
|
||||
.embed(embedConfig)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.converter;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.list.ListFAQCommandsCommandChannelGroupModel;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.list.ListFAQCommandsModel;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.command.list.ListFAQCommandsCommandModel;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQChannelGroupCommand;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQCommand;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class ListFAQCommandsModelConverter {
|
||||
|
||||
public ListFAQCommandsModel fromFAQCommands(List<FAQCommand> faqCommandList) {
|
||||
List<ListFAQCommandsCommandModel> commands = faqCommandList
|
||||
.stream()
|
||||
.map(this::convertCommand)
|
||||
.collect(Collectors.toList());
|
||||
return ListFAQCommandsModel
|
||||
.builder()
|
||||
.commands(commands)
|
||||
.build();
|
||||
}
|
||||
|
||||
private ListFAQCommandsCommandModel convertCommand(FAQCommand faqCommand) {
|
||||
List<ListFAQCommandsCommandChannelGroupModel> channelGroups = faqCommand
|
||||
.getGroupResponses()
|
||||
.stream()
|
||||
.map(this::convertGroupCommand)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> aliases;
|
||||
if(faqCommand.getAliases() != null) {
|
||||
aliases = faqCommand.getAliases().stream().map(faqCommandAlias -> faqCommandAlias.getId().getAlias()).collect(Collectors.toList());
|
||||
} else {
|
||||
aliases = new ArrayList<>();
|
||||
}
|
||||
return ListFAQCommandsCommandModel
|
||||
.builder()
|
||||
.commandName(faqCommand.getName())
|
||||
.aliases(aliases)
|
||||
.channelGroups(channelGroups)
|
||||
.build();
|
||||
}
|
||||
|
||||
private ListFAQCommandsCommandChannelGroupModel convertGroupCommand(FAQChannelGroupCommand faqChannelGroupCommand) {
|
||||
AChannelGroup channelGroup = faqChannelGroupCommand.getChannelGroup().getChannelGroup();
|
||||
return ListFAQCommandsCommandChannelGroupModel
|
||||
.builder()
|
||||
.responseCount(faqChannelGroupCommand.getResponses().size())
|
||||
.channelGroupName(channelGroup.getGroupName())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.exception.DuplicatedCommandNameExceptionModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DuplicatedCommandNameOrAliasException extends AbstractoTemplatableException {
|
||||
|
||||
private final DuplicatedCommandNameExceptionModel model;
|
||||
|
||||
public DuplicatedCommandNameOrAliasException(List<String> commandKeys) {
|
||||
super("Duplicated command name or alias found.");
|
||||
this.model = DuplicatedCommandNameExceptionModel
|
||||
.builder()
|
||||
.duplicatedCommandKeys(commandKeys)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "duplicated_command_or_alias_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.exception.DuplicatedFAQCommandAliasExceptionModel;
|
||||
|
||||
public class DuplicatedFAQCommandAliasException extends AbstractoTemplatableException {
|
||||
private final DuplicatedFAQCommandAliasExceptionModel model;
|
||||
|
||||
public DuplicatedFAQCommandAliasException(String commandName, String alias, String usedCommand) {
|
||||
super("Alias for FAQ command is already used as an alias in another name.");
|
||||
this.model = DuplicatedFAQCommandAliasExceptionModel
|
||||
.builder()
|
||||
.alias(alias)
|
||||
.commandName(commandName)
|
||||
.originCommandName(usedCommand)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "duplicated_faq_command_alias_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.exception.FAQCommandAliasShadowingExceptionModel;
|
||||
|
||||
public class FAQCommandAliasShadowingException extends AbstractoTemplatableException {
|
||||
|
||||
private final FAQCommandAliasShadowingExceptionModel model;
|
||||
|
||||
public FAQCommandAliasShadowingException(String commandName, String alias) {
|
||||
super("Alias shadows another existing command.");
|
||||
this.model = FAQCommandAliasShadowingExceptionModel
|
||||
.builder()
|
||||
.alias(alias)
|
||||
.commandName(commandName)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "faq_command_alias_shadowing_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.exception.FAQCommandNotFoundExceptionModel;
|
||||
|
||||
public class FAQCommandNotFoundException extends AbstractoTemplatableException {
|
||||
private final FAQCommandNotFoundExceptionModel model;
|
||||
|
||||
public FAQCommandNotFoundException(String commandName) {
|
||||
super("FAQ command not found.");
|
||||
this.model = FAQCommandNotFoundExceptionModel
|
||||
.builder()
|
||||
.commandName(commandName)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "faq_command_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.exception.FAQCommandResponseDuplicatedPositionExceptionModel;
|
||||
|
||||
public class FAQCommandResponseDuplicatedPositionException extends AbstractoTemplatableException {
|
||||
private final FAQCommandResponseDuplicatedPositionExceptionModel model;
|
||||
|
||||
public FAQCommandResponseDuplicatedPositionException(String commandName, String channelGroupName) {
|
||||
super("Two messages within a FAQ command response have the same position.");
|
||||
this.model = FAQCommandResponseDuplicatedPositionExceptionModel
|
||||
.builder()
|
||||
.channelGroupName(channelGroupName)
|
||||
.commandName(commandName)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "faq_command_response_duplicated_position_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.exception.GlobalFAQCommandConfigMismatchExceptionModel;
|
||||
|
||||
public class GlobalFAQCommandConfigMismatchException extends AbstractoTemplatableException {
|
||||
private final GlobalFAQCommandConfigMismatchExceptionModel model;
|
||||
|
||||
public GlobalFAQCommandConfigMismatchException(String faqCommandName) {
|
||||
super("The configuration for a global FAQ command does not make sense. It must be a the global FAQ channel group and the command needs to have global enabled.");
|
||||
this.model = GlobalFAQCommandConfigMismatchExceptionModel
|
||||
.builder()
|
||||
.commandName(faqCommandName)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "global_faq_command_config_mismatch_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.exception.GlobalCommandResponseExceptionModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GlobalFAQCommandResponsesException extends AbstractoTemplatableException {
|
||||
private final GlobalCommandResponseExceptionModel model;
|
||||
|
||||
public GlobalFAQCommandResponsesException(List<String> commandNames) {
|
||||
super("A global command can only have one response.");
|
||||
this.model = GlobalCommandResponseExceptionModel
|
||||
.builder()
|
||||
.commandNames(commandNames)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "global_faq_command_responses_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||
|
||||
public class NoFAQResponseFoundException extends AbstractoTemplatableException {
|
||||
|
||||
public NoFAQResponseFoundException() {
|
||||
super("No FAQ Command response found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "no_faq_response_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
||||
import dev.sheldan.abstracto.core.listener.sync.entity.AsyncChannelGroupCreatedListener;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.abstracto.core.models.listener.ChannelGroupCreatedListenerModel;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelGroupManagementService;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQChannelGroup;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.management.FAQChannelGroupManagementServiceBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FAQAsyncChannelGroupCreatedListener implements AsyncChannelGroupCreatedListener {
|
||||
|
||||
@Autowired
|
||||
private ChannelGroupManagementService channelGroupManagementService;
|
||||
|
||||
@Autowired
|
||||
private FAQChannelGroupManagementServiceBean faqChannelGroupManagementServiceBean;
|
||||
|
||||
@Value("${abstracto.faq.globalChannelGroupName}")
|
||||
private String globalChannelGroupName;
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(ChannelGroupCreatedListenerModel model) {
|
||||
AChannelGroup channelGroup = channelGroupManagementService.findChannelGroupById(model.getChannelGroupId());
|
||||
if(channelGroup.getChannelGroupType().getGroupTypeKey().equals(FAQServiceBean.FAQ_CHANNEL_GROUP_KEY)) {
|
||||
FAQChannelGroup createdChannelGroup = faqChannelGroupManagementServiceBean.createFAQChannelGroup(channelGroup);
|
||||
if(channelGroup.getGroupName().equals(globalChannelGroupName)) {
|
||||
Optional<FAQChannelGroup> globalGroup = faqChannelGroupManagementServiceBean.getGlobalChannelGroup(channelGroup.getServer());
|
||||
globalGroup.ifPresent(faqChannelGroup -> {
|
||||
log.info("Setting channel group {} to not be global for server {}.", faqChannelGroup.getId(), channelGroup.getServer().getId());
|
||||
faqChannelGroup.setGlobal(false);
|
||||
});
|
||||
log.info("Setting channel group {} to be global for server {}.", channelGroup.getId(), channelGroup.getServer().getId());
|
||||
createdChannelGroup.setGlobal(true);
|
||||
}
|
||||
return DefaultListenerResult.PROCESSED;
|
||||
}
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
|
||||
import dev.sheldan.abstracto.core.listener.sync.entity.ChannelGroupDeletedListener;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.abstracto.core.models.listener.ChannelGroupDeletedListenerModel;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelGroupManagementService;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.FAQServiceBean;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.service.management.FAQChannelGroupManagementServiceBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FAQChannelGroupDeletedListener implements ChannelGroupDeletedListener {
|
||||
|
||||
@Autowired
|
||||
private FAQChannelGroupManagementServiceBean faqChannelGroupManagementServiceBean;
|
||||
|
||||
@Autowired
|
||||
private ChannelGroupManagementService channelGroupManagementService;
|
||||
|
||||
@Override
|
||||
public DefaultListenerResult execute(ChannelGroupDeletedListenerModel model) {
|
||||
AChannelGroup channelGroup = channelGroupManagementService.findChannelGroupById(model.getChannelGroupId());
|
||||
if(channelGroup.getChannelGroupType().getGroupTypeKey().equals(FAQServiceBean.FAQ_CHANNEL_GROUP_KEY)) {
|
||||
faqChannelGroupManagementServiceBean.deleteFAQChannelGroup(channelGroup);
|
||||
return DefaultListenerResult.PROCESSED;
|
||||
}
|
||||
return DefaultListenerResult.IGNORED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.config;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class FaqCommandConfig {
|
||||
private String faqCommandName;
|
||||
private Boolean global;
|
||||
private List<String> aliases;
|
||||
private List<FaqCommandResponseConfig> responses;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.config;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class FaqCommandResponseConfig {
|
||||
private String channelGroupName;
|
||||
private List<FaqCommandResponseMessageConfig> messages;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.config;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class FaqCommandResponseEmbedAuthorConfig {
|
||||
private Long userId;
|
||||
private Boolean useBot;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.config;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class FaqCommandResponseEmbedColorConfig {
|
||||
@Builder.Default
|
||||
private Integer red = 0;
|
||||
@Builder.Default
|
||||
private Integer green = 0;
|
||||
@Builder.Default
|
||||
private Integer blue = 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.config;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class FaqCommandResponseEmbedConfig {
|
||||
private String description;
|
||||
private String imageUrl;
|
||||
private FaqCommandResponseEmbedColorConfig color;
|
||||
private FaqCommandResponseEmbedAuthorConfig author;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.config;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class FaqCommandResponseMessageConfig {
|
||||
private Integer position;
|
||||
private String additionalMessage;
|
||||
private FaqCommandResponseEmbedConfig embed;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.faq;
|
||||
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQCommandResponse;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQResponseMessageModel {
|
||||
private User author;
|
||||
private String additionalMessage;
|
||||
private String description;
|
||||
private String imageURL;
|
||||
private Integer red;
|
||||
private Integer green;
|
||||
private Integer blue;
|
||||
|
||||
public static FAQResponseMessageModel fromFAQCommandResponse(FAQCommandResponse response, User user) {
|
||||
return FAQResponseMessageModel
|
||||
.builder()
|
||||
.author(user)
|
||||
.additionalMessage(response.getAdditionalMessage())
|
||||
.description(response.getDescription())
|
||||
.blue(response.getBlue())
|
||||
.green(response.getGreen())
|
||||
.red(response.getRed())
|
||||
.imageURL(response.getImageURL())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.faq;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQResponseModel {
|
||||
@Builder.Default
|
||||
private List<FAQResponseMessageModel> messages = new ArrayList<>();
|
||||
@Builder.Default
|
||||
private List<String> availableCommands = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.faquses;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQCommandResponseUsage {
|
||||
private String channelGroupName;
|
||||
private Integer uses;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.faquses;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQCommandUsage {
|
||||
private String faqCommandName;
|
||||
private List<FAQCommandResponseUsage> faqChannelGroupUsages;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.faquses;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQUsageModel {
|
||||
private List<FAQCommandUsage> uses;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.list;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class ListFAQCommandsCommandChannelGroupModel {
|
||||
private String channelGroupName;
|
||||
private Integer responseCount;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.list;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class ListFAQCommandsCommandModel {
|
||||
private String commandName;
|
||||
private List<String> aliases;
|
||||
private List<ListFAQCommandsCommandChannelGroupModel> channelGroups;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.command.list;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Builder
|
||||
@Getter
|
||||
public class ListFAQCommandsModel {
|
||||
private List<ListFAQCommandsCommandModel> commands;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.Instant;
|
||||
|
||||
@Builder
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "faq_channel_group")
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
public class FAQChannelGroup {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@PrimaryKeyJoinColumn
|
||||
private AChannelGroup channelGroup;
|
||||
|
||||
@Column(name = "global")
|
||||
private Boolean global;
|
||||
|
||||
@Column(name = "created", nullable = false, insertable = false, updatable = false)
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "updated", insertable = false, updatable = false)
|
||||
private Instant updated;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database;
|
||||
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.embed.ChannelGroupCommandId;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "faq_channel_group_command")
|
||||
@EqualsAndHashCode
|
||||
@Getter
|
||||
@Setter
|
||||
public class FAQChannelGroupCommand implements Serializable {
|
||||
|
||||
@EmbeddedId
|
||||
private ChannelGroupCommandId groupCommandId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@MapsId("channelGroupId")
|
||||
@JoinColumn(name = "channel_group_id", referencedColumnName = "id", nullable = false)
|
||||
private FAQChannelGroup channelGroup;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@MapsId("commandId")
|
||||
@JoinColumn(name = "command_id", referencedColumnName = "id", nullable = false)
|
||||
private FAQCommand command;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "groupCommand")
|
||||
@Builder.Default
|
||||
private List<FAQCommandResponse> responses = new ArrayList<>();
|
||||
|
||||
@Column(name = "created", nullable = false, insertable = false, updatable = false)
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "uses")
|
||||
private Integer uses;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "faq_command")
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
public class FAQCommand implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "name", length = 20)
|
||||
private String name;
|
||||
|
||||
@Column(name = "global")
|
||||
private Boolean global;
|
||||
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "server_id", nullable = false)
|
||||
private AServer server;
|
||||
|
||||
@Column(name = "created", nullable = false, insertable = false, updatable = false)
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "updated", insertable = false, updatable = false)
|
||||
private Instant updated;
|
||||
|
||||
@Getter
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "command")
|
||||
@Builder.Default
|
||||
private List<FAQChannelGroupCommand> groupResponses = new ArrayList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "command")
|
||||
@Builder.Default
|
||||
private List<FAQCommandAlias> aliases = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database;
|
||||
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.embed.FAQCommandAliasId;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
|
||||
@Builder
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "faq_command_alias")
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
public class FAQCommandAlias implements Serializable {
|
||||
|
||||
@EmbeddedId
|
||||
private FAQCommandAliasId id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@MapsId("commandId")
|
||||
@JoinColumn(name = "command_id", referencedColumnName = "id", nullable = false)
|
||||
private FAQCommand command;
|
||||
|
||||
@Column(name = "created", nullable = false, insertable = false, updatable = false)
|
||||
private Instant created;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database;
|
||||
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.embed.CommandResponseId;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.Instant;
|
||||
|
||||
@Builder
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table(name = "faq_command_response")
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
public class FAQCommandResponse {
|
||||
@EmbeddedId
|
||||
private CommandResponseId id;
|
||||
|
||||
@Column(name = "description", length = 2000)
|
||||
private String description;
|
||||
|
||||
@Column(name = "additional_message", length = 2000)
|
||||
private String additionalMessage;
|
||||
|
||||
@Column(name = "image_url", length = 2000)
|
||||
private String imageURL;
|
||||
|
||||
@Column(name = "red")
|
||||
private Integer red;
|
||||
|
||||
@Column(name = "green")
|
||||
private Integer green;
|
||||
|
||||
@Column(name = "blue")
|
||||
private Integer blue;
|
||||
|
||||
@Column(name = "author_user_id")
|
||||
private Long authorUserId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumns(
|
||||
{
|
||||
@JoinColumn(updatable = false, insertable = false, name = "channel_group_id", referencedColumnName = "channel_group_id"),
|
||||
@JoinColumn(updatable = false, insertable = false, name = "command_id", referencedColumnName = "command_id")
|
||||
})
|
||||
private FAQChannelGroupCommand groupCommand;
|
||||
|
||||
@Column(name = "created", nullable = false, insertable = false, updatable = false)
|
||||
private Instant created;
|
||||
|
||||
@Column(name = "updated", insertable = false, updatable = false)
|
||||
private Instant updated;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database.embed;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Embeddable
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class ChannelGroupCommandId implements Serializable {
|
||||
@Column(name = "channel_group_id")
|
||||
private Long channelGroupId;
|
||||
@Column(name = "command_id")
|
||||
private Long commandId;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database.embed;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Embeddable
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CommandResponseId implements Serializable {
|
||||
@Column(name = "channel_group_id")
|
||||
private Long channelGroupId;
|
||||
@Column(name = "command_id")
|
||||
private Long commandId;
|
||||
@Column(name = "position")
|
||||
private Integer position;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.database.embed;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Embeddable
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FAQCommandAliasId implements Serializable {
|
||||
@Column(name = "command_id")
|
||||
private Long faqCommandId;
|
||||
@Column(name = "alias", length = 20)
|
||||
private String alias;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class DuplicatedCommandNameExceptionModel {
|
||||
private List<String> duplicatedCommandKeys;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class DuplicatedFAQCommandAliasExceptionModel {
|
||||
private String commandName;
|
||||
private String alias;
|
||||
private String originCommandName;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQCommandAliasShadowingExceptionModel {
|
||||
private String commandName;
|
||||
private String alias;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQCommandNotFoundExceptionModel {
|
||||
private String commandName;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class FAQCommandResponseDuplicatedPositionExceptionModel {
|
||||
private String commandName;
|
||||
private String channelGroupName;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class GlobalCommandResponseExceptionModel {
|
||||
private List<String> commandNames;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.models.exception;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class GlobalFAQCommandConfigMismatchExceptionModel {
|
||||
private String commandName;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.oneplus.bot.modules.faq.repository;
|
||||
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQChannelGroup;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.FAQChannelGroupCommand;
|
||||
import dev.sheldan.oneplus.bot.modules.faq.models.database.embed.ChannelGroupCommandId;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface FAQChannelGroupCommandRepository extends JpaRepository<FAQChannelGroupCommand, ChannelGroupCommandId> {
|
||||
List<FAQChannelGroupCommand> findByChannelGroup(FAQChannelGroup faqChannelGroup);
|
||||
List<FAQChannelGroupCommand> findByChannelGroup_IdIn(List<Long> channelGroupIds);
|
||||
List<FAQChannelGroupCommand> findByChannelGroupIn(List<FAQChannelGroup> faqChannelGroup);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user