├── _config.yml
├── generate-JAR.bat
├── config.properties
├── .gitignore
├── .travis.yml
├── src
└── main
│ ├── resources
│ ├── logback.xml
│ ├── label_EN
│ ├── label_ES
│ └── label_FR
│ └── java
│ ├── Main.java
│ ├── enums
│ └── Language.java
│ ├── commands
│ ├── classic
│ │ ├── PingCommand.java
│ │ ├── AboutCommand.java
│ │ ├── SetCommand.java
│ │ ├── GuildCommand.java
│ │ ├── ItemCommand.java
│ │ ├── RandomCommand.java
│ │ ├── DonateCommand.java
│ │ ├── InviteCommand.java
│ │ ├── JobCommand.java
│ │ ├── AllianceCommand.java
│ │ ├── MapCommand.java
│ │ ├── TutorialCommand.java
│ │ ├── MonsterCommand.java
│ │ ├── ResourceCommand.java
│ │ ├── WhoisCommand.java
│ │ ├── AlignmentCommand.java
│ │ ├── PortalCommand.java
│ │ ├── AlmanaxCommand.java
│ │ ├── DistanceCommand.java
│ │ └── HelpCommand.java
│ ├── config
│ │ ├── ServerCommand.java
│ │ ├── PrefixCommand.java
│ │ ├── LanguageCommand.java
│ │ ├── RSSCommand.java
│ │ ├── CommandCommand.java
│ │ ├── TwitterCommand.java
│ │ └── AlmanaxAutoCommand.java
│ ├── model
│ │ ├── LegacyCommand.java
│ │ └── AbstractLegacyCommand.java
│ ├── CommandManager.java
│ └── admin
│ │ └── StatCommand.java
│ ├── data
│ ├── ChannelLanguage.java
│ ├── Constants.java
│ └── Guild.java
│ ├── listeners
│ └── MessageListener.java
│ └── util
│ ├── Connexion.java
│ ├── Translator.java
│ └── ClientConfig.java
├── .gitlab-ci.yml
├── pom.xml
├── README.md
└── LICENSE
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/generate-JAR.bat:
--------------------------------------------------------------------------------
1 | call mvn clean compile
2 | call mvn assembly:single
3 | pause
--------------------------------------------------------------------------------
/config.properties:
--------------------------------------------------------------------------------
1 | discord.token=
2 | twitter.consumer_key=
3 | twitter.consumer_secret=
4 | twitter.access_token=
5 | twitter.access_token_secret=
6 | sentry.dsn=
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Mobile Tools for Java (J2ME)
4 | .mtj.tmp/
5 |
6 | # Package Files #
7 | *.jar
8 | *.war
9 | *.ear
10 |
11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12 | hs_err_pid*
13 |
14 | # properties file
15 | *.properties
16 |
17 | # IDE
18 | .idea/
19 | modules/
20 | target/
21 | *.iml
22 |
23 | # BDD
24 | *.sqlite
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - openjdk8
4 | after_success:
5 | - mvn clean test jacoco:report coveralls:report
6 | - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
7 | - chmod +x send.sh
8 | - ./send.sh success $WEBHOOK_URL
9 | after_failure:
10 | - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
11 | - chmod +x send.sh
12 | - ./send.sh failure $WEBHOOK_URL
13 |
--------------------------------------------------------------------------------
/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | dependency_scanning:
2 | image: docker:stable
3 | variables:
4 | DOCKER_DRIVER: overlay2
5 | allow_failure: true
6 | services:
7 | - docker:stable-dind
8 | script:
9 | - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
10 | - docker run
11 | --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
12 | --volume "$PWD:/code"
13 | --volume /var/run/docker.sock:/var/run/docker.sock
14 | "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
15 | artifacts:
16 | paths: [gl-dependency-scanning-report.json]
--------------------------------------------------------------------------------
/src/main/java/Main.java:
--------------------------------------------------------------------------------
1 | import data.Constants;
2 | import org.slf4j.LoggerFactory;
3 | import util.ClientConfig;
4 |
5 | /**
6 | * Created by steve on 14/07/2016.
7 | */
8 | public class Main {
9 |
10 | public static void main(String[] args) {
11 | LoggerFactory.getLogger(Main.class).info("=======================================================");
12 | LoggerFactory.getLogger(Main.class).info(" " + Constants.name + " v" + Constants.version
13 | + " for a last run");
14 | LoggerFactory.getLogger(Main.class).info("=======================================================");
15 |
16 | ClientConfig.getInstance().loginDiscord(); // To launch as a service, specify the path/to/Kaelly/
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/enums/Language.java:
--------------------------------------------------------------------------------
1 | package enums;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by steve on 07/06/2017.
7 | */
8 | public enum Language {
9 |
10 | FR("Français", "FR", List.of("fr")),
11 | EN("English", "EN", List.of("en-US", "en-GB")),
12 | ES("Español", "ES", List.of("es-ES"));
13 |
14 | private final String name;
15 | private final String abrev;
16 | private final List locales;
17 |
18 | Language(String name, String abrev, List locales){
19 | this.name = name;
20 | this.abrev = abrev;
21 | this.locales = locales;
22 | }
23 |
24 | public String getName() {
25 | return name;
26 | }
27 |
28 | public String getAbrev() {
29 | return abrev;
30 | }
31 |
32 | public List getLocales() {
33 | return locales;
34 | }
35 |
36 | @Override
37 | public String toString(){
38 | return name;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/PingCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by Kaysoro on 24/05/2019.
13 | */
14 | public class PingCommand extends AbstractLegacyCommand {
15 |
16 | public PingCommand() {
17 | super("ping", "");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "ping.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "ping.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "ping.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/AboutCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by Songfu on 29/05/2017.
13 | */
14 | public class AboutCommand extends AbstractLegacyCommand {
15 |
16 | public AboutCommand() {
17 | super("about", "");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "about.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "about.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "about.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/SetCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 12/10/2016.
13 | */
14 | public class SetCommand extends AbstractLegacyCommand {
15 |
16 | public SetCommand(){
17 | super("set", "\\s+(-more)?(.*)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "set.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "set.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "set.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/GuildCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 30/03/2018.
13 | */
14 | public class GuildCommand extends AbstractLegacyCommand {
15 |
16 | public GuildCommand(){
17 | super("guild","\\s+(.+)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "guild.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "guild.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "guild.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/ItemCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class ItemCommand extends AbstractLegacyCommand {
15 |
16 | public ItemCommand(){
17 | super("item", "\\s+(-more)?(.*)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "item.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "item.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "item.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/RandomCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class RandomCommand extends AbstractLegacyCommand {
15 |
16 | public RandomCommand(){
17 | super("rdm","(.*)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "random.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "random.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "random.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/DonateCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by Kaysoro on 20/05/2019.
13 | */
14 | public class DonateCommand extends AbstractLegacyCommand {
15 |
16 | public DonateCommand() {
17 | super("donate", "");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "donate.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "donate.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "donate.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/InviteCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by Kaysoro on 20/05/2019.
13 | */
14 | public class InviteCommand extends AbstractLegacyCommand {
15 |
16 | public InviteCommand() {
17 | super("invite", "");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "invite.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "invite.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "invite.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/JobCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class JobCommand extends AbstractLegacyCommand {
15 |
16 | public JobCommand(){
17 | super("job", "(.*)");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | protected void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "job.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "job.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "job.request");
36 | }
37 | }
--------------------------------------------------------------------------------
/src/main/java/commands/classic/AllianceCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 04/04/2018.
13 | */
14 | public class AllianceCommand extends AbstractLegacyCommand {
15 |
16 | public AllianceCommand(){
17 | super("alliance","\\s+(.+)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "alliance.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "alliance.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "alliance.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/MapCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class MapCommand extends AbstractLegacyCommand {
15 |
16 | public MapCommand(){
17 | super("map",
18 | "(\\s+-ban)?((\\s+\\w+)+)?");
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "map.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "map.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefixe) {
35 | return Translator.getLabel(lg, "map.request");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/TutorialCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class TutorialCommand extends AbstractLegacyCommand {
15 |
16 | public TutorialCommand(){
17 | super("tuto", "\\s+(.*)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "tutorial.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "tutorial.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "tutorial.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/MonsterCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class MonsterCommand extends AbstractLegacyCommand {
15 |
16 | public MonsterCommand(){
17 | super("monster", "\\s+(-more)?(.*)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "monster.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "monster.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "monster.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/config/ServerCommand.java:
--------------------------------------------------------------------------------
1 | package commands.config;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class ServerCommand extends AbstractLegacyCommand {
15 |
16 | public ServerCommand(){
17 | super("server","(\\s+.+)?");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "server.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "server.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "server.request");
36 | }
37 | }
--------------------------------------------------------------------------------
/src/main/java/commands/classic/ResourceCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 27/10/2016.
13 | */
14 | public class ResourceCommand extends AbstractLegacyCommand {
15 |
16 | public ResourceCommand(){
17 | super("resource", "\\s+(-more)?(.*)");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "resource.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "resource.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "resource.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/WhoisCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class WhoisCommand extends AbstractLegacyCommand {
15 |
16 | public WhoisCommand(){
17 | super("whois","(\\s+-more)?(\\s+[\\p{L}|-]+)(\\s+.+)?");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "whois.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "whois.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "whois.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/AlignmentCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 08/02/2018
13 | */
14 | public class AlignmentCommand extends AbstractLegacyCommand {
15 |
16 | public AlignmentCommand(){
17 | super("align", "(.*)");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "align.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "align.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "align.request");
36 | }
37 | }
--------------------------------------------------------------------------------
/src/main/java/commands/classic/PortalCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class PortalCommand extends AbstractLegacyCommand {
15 |
16 | public PortalCommand(){
17 | super("pos", "(\\s+\\p{L}+)?");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "portal.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "portal.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "portal.request");
36 | }
37 | }
--------------------------------------------------------------------------------
/src/main/java/commands/classic/AlmanaxCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class AlmanaxCommand extends AbstractLegacyCommand {
15 |
16 | public AlmanaxCommand(){
17 | super("almanax", "(\\s+\\d{2}/\\d{2}/\\d{4}|\\s+\\+\\d)?");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "almanax.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "almanax.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "almanax.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/config/PrefixCommand.java:
--------------------------------------------------------------------------------
1 | package commands.config;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class PrefixCommand extends AbstractLegacyCommand {
15 |
16 | public PrefixCommand(){
17 | super("prefix","\\s+(.+)");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "prefix.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefixe) {
30 | return "**" + prefixe + name + "** " + Translator.getLabel(lg, "prefix.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefixe) {
35 | return Translator.getLabel(lg, "prefix.request");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/DistanceCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class DistanceCommand extends AbstractLegacyCommand {
15 |
16 | public DistanceCommand(){
17 | super("dist", "\\s+\\[?(-?\\d{1,2})\\s*[,|\\s]\\s*(-?\\d{1,2})\\]?");
18 | }
19 |
20 | @Override
21 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
22 | message.getChannel().flatMap(chan -> chan
23 | .createMessage(Translator.getLabel(lg, "distance.request")))
24 | .subscribe();
25 | }
26 |
27 | @Override
28 | public String help(Language lg, String prefix) {
29 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "distance.help");
30 | }
31 |
32 | @Override
33 | public String helpDetailed(Language lg, String prefix) {
34 | return Translator.getLabel(lg, "distance.request");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/commands/config/LanguageCommand.java:
--------------------------------------------------------------------------------
1 | package commands.config;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class LanguageCommand extends AbstractLegacyCommand {
15 |
16 | public LanguageCommand(){
17 | super("lang", "(\\s+-channel)?(\\s+[A-Za-z]+)?");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "lang.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "lang.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "lang.request");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/commands/config/RSSCommand.java:
--------------------------------------------------------------------------------
1 | package commands.config;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class RSSCommand extends AbstractLegacyCommand {
15 |
16 |
17 | public RSSCommand(){
18 | super("rss","(\\s+true|\\s+false|\\s+0|\\s+1|\\s+on|\\s+off)");
19 | setUsableInMP(false);
20 | }
21 |
22 | @Override
23 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
24 | message.getChannel().flatMap(chan -> chan
25 | .createMessage(Translator.getLabel(lg, "rss.request")))
26 | .subscribe();
27 | }
28 |
29 | @Override
30 | public String help(Language lg, String prefixe) {
31 | return "**" + prefixe + name + "** " + Translator.getLabel(lg, "rss.help");
32 | }
33 |
34 | @Override
35 | public String helpDetailed(Language lg, String prefixe) {
36 | return Translator.getLabel(lg, "rss.request");
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/commands/config/CommandCommand.java:
--------------------------------------------------------------------------------
1 | package commands.config;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class CommandCommand extends AbstractLegacyCommand {
15 |
16 | public CommandCommand(){
17 | super("cmd","\\s+([\\w|-]+)\\s+(on|off|0|1|true|false)");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "command.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "command.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "command.request");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/commands/config/TwitterCommand.java:
--------------------------------------------------------------------------------
1 | package commands.config;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class TwitterCommand extends AbstractLegacyCommand {
15 |
16 | public TwitterCommand(){
17 | super("twitter", "(\\s+true|\\s+false|\\s+0|\\s+1|\\s+on|\\s+off)");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "twitter.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "twitter.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "twitter.request");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/commands/config/AlmanaxAutoCommand.java:
--------------------------------------------------------------------------------
1 | package commands.config;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 | import util.Translator;
8 |
9 | import java.util.regex.Matcher;
10 |
11 | /**
12 | * Created by steve on 14/07/2016.
13 | */
14 | public class AlmanaxAutoCommand extends AbstractLegacyCommand {
15 |
16 | public AlmanaxAutoCommand(){
17 | super("almanax-auto", "(\\s+true|\\s+false|\\s+0|\\s+1|\\s+on|\\s+off)");
18 | setUsableInMP(false);
19 | }
20 |
21 | @Override
22 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
23 | message.getChannel().flatMap(chan -> chan
24 | .createMessage(Translator.getLabel(lg, "almanax-auto.request")))
25 | .subscribe();
26 | }
27 |
28 | @Override
29 | public String help(Language lg, String prefix) {
30 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "almanax-auto.help");
31 | }
32 |
33 | @Override
34 | public String helpDetailed(Language lg, String prefix) {
35 | return Translator.getLabel(lg, "almanax-auto.request");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/data/ChannelLanguage.java:
--------------------------------------------------------------------------------
1 | package data;
2 |
3 | import enums.Language;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 | import util.Connexion;
7 |
8 | import java.sql.Connection;
9 | import java.sql.PreparedStatement;
10 | import java.sql.ResultSet;
11 | import java.sql.SQLException;
12 | import java.util.Map;
13 | import java.util.concurrent.ConcurrentHashMap;
14 |
15 | /**
16 | * Created by steve on 12/01/2017.
17 | */
18 | public class ChannelLanguage {
19 | private final static Logger LOG = LoggerFactory.getLogger(ChannelLanguage.class);
20 | private static Map channelLanguages;
21 | private Language lang;
22 | private long channelId;
23 |
24 | public ChannelLanguage(Language lang, long channelId) {
25 | this.lang = lang;
26 | this.channelId = channelId;
27 | }
28 |
29 | public synchronized static Map getChannelLanguages(){
30 | if (channelLanguages == null) {
31 | channelLanguages = new ConcurrentHashMap<>();
32 |
33 | Connexion connexion = Connexion.getInstance();
34 | Connection connection = connexion.getConnection();
35 |
36 | try {
37 | PreparedStatement query = connection.prepareStatement("SELECT lang, id_chan FROM Channel_Language");
38 | ResultSet resultSet = query.executeQuery();
39 |
40 | while (resultSet.next()){
41 | long idChan = Long.parseLong(resultSet.getString("id_chan"));
42 | Language lang = Language.valueOf(resultSet.getString("lang"));
43 | channelLanguages.put(idChan, new ChannelLanguage(lang, idChan));
44 | }
45 | } catch (SQLException e) {
46 | LOG.error("getChannelLanguages", e);
47 | }
48 | }
49 | return channelLanguages;
50 | }
51 |
52 | public Long getChannelId(){
53 | return channelId;
54 | }
55 |
56 | public Language getLang() {
57 | return lang;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/data/Constants.java:
--------------------------------------------------------------------------------
1 |
2 | package data;
3 |
4 | import enums.Language;
5 |
6 | /**
7 | * Created by steve on 28/07/2016.
8 | */
9 | public class Constants {
10 |
11 | /**
12 | * Application name
13 | */
14 | public static final String name = "Kaelly";
15 |
16 | /**
17 | * Application version
18 | */
19 | public static final String version = "1.9.9";
20 |
21 | /**
22 | * Author id
23 | */
24 | public static final long authorId = 162842827183751169L;
25 |
26 | /**
27 | * Author name
28 | */
29 | public static final String authorName = "Kaysoro#8327";
30 |
31 | /**
32 | * Author avatar
33 | */
34 | public static final String authorAvatar = "https://avatars0.githubusercontent.com/u/5544670?s=460&v=4";
35 |
36 | /**
37 | * URL for Kaelly twitter account
38 | */
39 | public static final String twitterAccount = "https://twitter.com/KaellyBot";
40 |
41 | /**
42 | * URL for github KaellyBot repository
43 | */
44 | public static final String git = "https://github.com/Kaysoro/KaellyBot";
45 |
46 | /**
47 | * Official link invite
48 | */
49 | public static final String invite = "https://discordapp.com/oauth2/authorize?&client_id=202916641414184960&scope=bot";
50 |
51 | /**
52 | * Official paypal link
53 | */
54 | public static final String paypal = "https://paypal.me/kaysoro";
55 |
56 | /**
57 | * Database name
58 | */
59 | public static final String database = "bdd.sqlite";
60 |
61 | /**
62 | * Path to the database (can be left empty)
63 | */
64 | public static final String database_path = "";
65 |
66 | /**
67 | * prefix used for command call.
68 | * WARN : it is injected into regex expression.
69 | * If you use special characters as '$', don't forget to prefix it with '\\' like this : "\\$"
70 | */
71 | public static final String prefixCommand = "!";
72 |
73 | public static final Language defaultLanguage = Language.FR;
74 |
75 | /**
76 | * Discord invite link
77 | */
78 | public static final String discordInvite = "https://discord.gg/VsrbrYC";
79 | }
--------------------------------------------------------------------------------
/src/main/java/listeners/MessageListener.java:
--------------------------------------------------------------------------------
1 | package listeners;
2 |
3 | import commands.CommandManager;
4 | import commands.model.AbstractLegacyCommand;
5 | import commands.model.LegacyCommand;
6 | import discord4j.core.event.domain.message.MessageCreateEvent;
7 | import discord4j.core.object.entity.User;
8 | import discord4j.core.object.entity.channel.MessageChannel;
9 | import enums.Language;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 | import reactor.core.publisher.Mono;
13 | import util.Translator;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | /**
19 | * Created by steve on 14/07/2016.
20 | */
21 | public class MessageListener {
22 |
23 | private final static Logger LOG = LoggerFactory.getLogger(MessageListener.class);
24 |
25 | public Mono onReady(MessageCreateEvent event) {
26 | return event.getMessage().getChannel()
27 | .doOnSuccess(channel -> {
28 | Language lg = Translator.getLanguageFrom(channel);
29 | String prefixe = AbstractLegacyCommand.getPrefix(event.getMessage());
30 |
31 | // If the authorId is a bot, message get ignored
32 | if (! event.getMessage().getAuthor().map(User::isBot).orElse(true)) {
33 | List commandsAvailable = new ArrayList<>();
34 |
35 | for (LegacyCommand command : CommandManager.getCommands())
36 | if (event.getMessage().getContent().startsWith(prefixe + command.getName()))
37 | commandsAvailable.add(command);
38 |
39 | if (!commandsAvailable.isEmpty()){
40 | commandsAvailable.sort((cmd1, cmd2) -> cmd2.getName().length() - cmd1.getName().length());
41 | LegacyCommand command = commandsAvailable.get(0);
42 |
43 | try {
44 | command.request(event, event.getMessage());
45 | } catch (Exception e) {
46 | LOG.error("onReady", e);
47 | }
48 | }
49 | }
50 | });
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/util/Connexion.java:
--------------------------------------------------------------------------------
1 | package util;
2 |
3 | import data.Constants;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 | import org.sqlite.SQLiteConfig;
7 |
8 | import java.io.File;
9 | import java.sql.*;
10 |
11 | public class Connexion {
12 | private final static Logger LOG = LoggerFactory.getLogger(Connexion.class);
13 | private static Connexion instance = null;
14 | private Connection connection = null;
15 | private Statement statement = null;
16 | private static String database_path = System.getProperty("user.dir") + File.separator;
17 |
18 | public void connect() {
19 | if (! Constants.database_path.trim().isEmpty()) {
20 | database_path = Constants.database_path + File.separator;
21 | }
22 |
23 | try {
24 | Class.forName("org.sqlite.JDBC");
25 | connection = DriverManager.getConnection("jdbc:sqlite:" + database_path + Constants.database);
26 |
27 | statement = connection.createStatement();
28 | LOG.info("Connexion à " + Constants.database + " avec succès");
29 |
30 | SQLiteConfig config = new SQLiteConfig();
31 | config.enforceForeignKeys(true);
32 | connection = DriverManager.getConnection("jdbc:sqlite:" + database_path + Constants.database, config.toProperties());
33 |
34 | } catch (ClassNotFoundException e) {
35 | LOG.error("Librairie SQLite non trouvé.");
36 | } catch (SQLException e) {
37 | LOG.error("Erreur lors de la connexion à la base de données");
38 | }
39 | }
40 |
41 | public void close() {
42 | try {
43 | connection.close();
44 | statement.close();
45 | LOG.info("Fermeture de la connexion");
46 | } catch (SQLException e) {
47 | LOG.error("Erreur lors de la fermeture de la connexion");
48 | }
49 | }
50 |
51 | public synchronized static Connexion getInstance(){
52 | if (instance == null) {
53 | instance = new Connexion();
54 | instance.connect();
55 | }
56 | return instance;
57 | }
58 |
59 | public ResultSet query(String requet) {
60 | ResultSet resultat = null;
61 | try {
62 | resultat = statement.executeQuery(requet);
63 | } catch (SQLException e) {
64 | LOG.error("Erreur dans la requête : " + requet);
65 | }
66 | return resultat;
67 | }
68 |
69 | public Connection getConnection(){
70 | return connection;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/commands/model/LegacyCommand.java:
--------------------------------------------------------------------------------
1 | package commands.model;
2 |
3 | import data.Guild;
4 | import discord4j.core.event.domain.message.MessageCreateEvent;
5 | import discord4j.core.object.entity.Message;
6 | import enums.Language;
7 |
8 | import java.util.regex.Matcher;
9 |
10 | /**
11 | * Created by steve on 14/07/2016.
12 | */
13 | public interface LegacyCommand {
14 | String getName();
15 | String getPattern();
16 | Matcher getMatcher(Message message);
17 | void request(MessageCreateEvent event, Message message);
18 |
19 | /**
20 | * Is the command usable in MP?
21 | * @return True if it can be used in MP, else false.
22 | */
23 | boolean isUsableInMP();
24 |
25 | /**
26 | * Is the command only usable by admins ?
27 | * @return True if it only can be used by admin, else false.
28 | */
29 | boolean isAdmin();
30 |
31 | /**
32 | * Is the command available by the admin ?
33 | * @return true is the command is available, else false.
34 | */
35 | boolean isPublic();
36 |
37 | /**
38 | * is the command is hidden ?
39 | * @return True if the command is hidden
40 | */
41 | boolean isHidden();
42 |
43 | /**
44 | * Change the command scope
45 | * @param isPublic is command available or not
46 | */
47 | void setPublic(boolean isPublic);
48 |
49 | /**
50 | * Is the command available by the guild admin ?
51 | * @param g Guild concerned
52 | * @return true is the command is forbidden, else false.
53 | */
54 | boolean isForbidden(Guild g);
55 |
56 | /**
57 | * Change the command scope in MP
58 | * @param isUsableInMP is command available in MP or not
59 | */
60 | void setUsableInMP(boolean isUsableInMP);
61 |
62 | /**
63 | * Change the command scope for admin user
64 | * @param isAdmin is command only available for admins or not
65 | */
66 | void setAdmin(boolean isAdmin);
67 |
68 | /**
69 | * Hide or not the command
70 | * @param isHidden is command hidden or not
71 | */
72 | void setHidden(boolean isHidden);
73 |
74 | /**
75 | * @param prefixe Prefixe for command
76 | * @return Short description of the command
77 | */
78 | String help(Language lg, String prefixe);
79 |
80 | /**
81 | * @param prefixe Prefixe for command
82 | * @return Detailed description of the command
83 | */
84 | String helpDetailed(Language lg, String prefixe);
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/commands/CommandManager.java:
--------------------------------------------------------------------------------
1 | package commands;
2 |
3 | import commands.admin.StatCommand;
4 | import commands.classic.*;
5 | import commands.config.*;
6 | import commands.model.LegacyCommand;
7 |
8 | import java.util.List;
9 | import java.util.Map;
10 | import java.util.concurrent.ConcurrentHashMap;
11 | import java.util.concurrent.CopyOnWriteArrayList;
12 |
13 | /**
14 | * Created by steve on 20/05/2017.
15 | */
16 | public class CommandManager {
17 |
18 | private static CommandManager instance;
19 |
20 | private final List commands;
21 | private final Map mapCommands;
22 |
23 | private CommandManager(){
24 | super();
25 | mapCommands = new ConcurrentHashMap<>();
26 | commands = new CopyOnWriteArrayList<>();
27 |
28 | // Basics commands
29 | addCommand(new AboutCommand());
30 | addCommand(new AlignmentCommand());
31 | addCommand(new AllianceCommand());
32 | addCommand(new AlmanaxCommand());
33 | addCommand(new AlmanaxAutoCommand());
34 | addCommand(new CommandCommand());
35 | addCommand(new DistanceCommand());
36 | addCommand(new DonateCommand());
37 | addCommand(new GuildCommand());
38 | addCommand(new HelpCommand());
39 | addCommand(new InviteCommand());
40 | addCommand(new ItemCommand());
41 | addCommand(new JobCommand());
42 | addCommand(new LanguageCommand());
43 | addCommand(new MapCommand());
44 | addCommand(new MonsterCommand());
45 | addCommand(new PingCommand());
46 | addCommand(new PortalCommand());
47 | addCommand(new PrefixCommand());
48 | addCommand(new RandomCommand());
49 | addCommand(new ResourceCommand());
50 | addCommand(new RSSCommand());
51 | addCommand(new ServerCommand());
52 | addCommand(new SetCommand());
53 | addCommand(new TutorialCommand());
54 | addCommand(new TwitterCommand());
55 | addCommand(new WhoisCommand());
56 |
57 | // Admin commands
58 | addCommand(new StatCommand());
59 | }
60 |
61 | public static CommandManager getInstance(){
62 | if (instance == null)
63 | instance = new CommandManager();
64 | return instance;
65 | }
66 |
67 | public static List getCommands(){
68 | return getInstance().commands;
69 | }
70 |
71 | private void addCommand(LegacyCommand command){
72 | commands.add(command);
73 | mapCommands.put(command.getName(), command);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.github.kaysoro
8 | Kaelly
9 | 1.9.9
10 |
11 |
12 | UTF-8
13 | 11
14 | 11
15 |
16 |
17 |
18 |
19 |
20 | maven-assembly-plugin
21 |
22 |
23 |
24 | Main
25 | true
26 |
27 |
28 |
29 | jar-with-dependencies
30 |
31 |
32 |
33 |
34 | make-assembly
35 | package
36 |
37 | single
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.xerial
47 | sqlite-jdbc
48 | 3.41.2.2
49 |
50 |
51 | com.discord4j
52 | discord4j-core
53 | 3.3.0-RC2
54 |
55 |
56 | ch.qos.logback
57 | logback-classic
58 | 1.3.15
59 |
60 |
61 | org.jfree
62 | jfreechart
63 | 1.5.3
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/main/java/commands/classic/HelpCommand.java:
--------------------------------------------------------------------------------
1 | package commands.classic;
2 |
3 | import commands.CommandManager;
4 | import commands.model.AbstractLegacyCommand;
5 | import commands.model.LegacyCommand;
6 | import data.Guild;
7 | import discord4j.core.event.domain.message.MessageCreateEvent;
8 | import discord4j.core.object.entity.Message;
9 | import discord4j.core.object.entity.channel.PrivateChannel;
10 | import enums.Language;
11 | import util.Translator;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 | import java.util.regex.Matcher;
16 |
17 | /**
18 | * Created by steve on 14/07/2016.
19 | */
20 | public class HelpCommand extends AbstractLegacyCommand {
21 |
22 | public final static String NAME = "help";
23 |
24 | public HelpCommand(){
25 | super(NAME,"(\\s+.+)?");
26 | }
27 |
28 | @Override
29 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
30 | String prefix = getPrefixMdEscaped(message);
31 | StringBuilder st = new StringBuilder();
32 | List messages = new ArrayList<>();
33 |
34 | boolean argumentFound = m.group(1) != null && m.group(1).replaceAll("^\\s+", "").length() > 0;
35 | for(LegacyCommand command : CommandManager.getCommands())
36 | if (command.isPublic() && ! command.isAdmin() && (!command.isHidden() || argumentFound)
37 | && (message.getChannel().block() instanceof PrivateChannel
38 | || ! command.isForbidden(Guild.getGuild(message.getGuild().block())))){
39 | if (! argumentFound) {
40 | String helpCmd = command.help(lg, prefix) + "\n";
41 | if (st.length() + helpCmd.length() > Message.MAX_CONTENT_LENGTH){
42 | messages.add(st.toString());
43 | st.setLength(0);
44 | }
45 | st.append(helpCmd);
46 | }
47 | else if (command.getName().equals(m.group(1).trim())) {
48 | st.append(command.helpDetailed(lg, prefix));
49 | break;
50 | }
51 | }
52 |
53 | if (st.length() > 0)
54 | messages.add(st.toString());
55 |
56 | if (argumentFound && messages.isEmpty())
57 | Translator.getLabel(lg, "help.request");
58 | else
59 | for(String msg : messages)
60 | message.getChannel().flatMap(chan -> chan.createMessage(msg)).subscribe();
61 | }
62 |
63 | @Override
64 | public String help(Language lg, String prefix) {
65 | return "**" + prefix + name + "** " + Translator.getLabel(lg, "help.help");
66 | }
67 |
68 | @Override
69 | public String helpDetailed(Language lg, String prefix) {
70 | return Translator.getLabel(lg, "help.request");
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/data/Guild.java:
--------------------------------------------------------------------------------
1 | package data;
2 |
3 | import enums.Language;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 | import util.Connexion;
7 |
8 | import java.sql.Connection;
9 | import java.sql.PreparedStatement;
10 | import java.sql.ResultSet;
11 | import java.sql.SQLException;
12 | import java.util.Map;
13 | import java.util.concurrent.ConcurrentHashMap;
14 |
15 | /**
16 | * Created by steve on 31/07/2016.
17 | */
18 | public class Guild {
19 |
20 | private final static Logger LOG = LoggerFactory.getLogger(Guild.class);
21 | private static Map guilds;
22 | private String id;
23 | private String name;
24 | private String prefix;
25 | private Language language;
26 |
27 | public Guild(String id, String name, Language lang){
28 | this(id, name, Constants.prefixCommand, lang);
29 | }
30 |
31 | private Guild(String id, String name, String prefix, Language lang){
32 | this.id = id;
33 | this.name = name;
34 | this.prefix = prefix;
35 | this.language = lang;
36 | }
37 |
38 | public synchronized static Map getGuilds(){
39 | if (guilds == null){
40 | guilds = new ConcurrentHashMap<>();
41 | String id;
42 | String name;
43 | String prefix;
44 | String lang;
45 |
46 | Connexion connexion = Connexion.getInstance();
47 | Connection connection = connexion.getConnection();
48 |
49 | try {
50 | PreparedStatement query = connection.prepareStatement("SELECT id, name, prefixe, lang FROM Guild");
51 | ResultSet resultSet = query.executeQuery();
52 |
53 | while (resultSet.next()) {
54 | id = resultSet.getString("id");
55 | name = resultSet.getString("name");
56 | prefix = resultSet.getString("prefixe");
57 | lang = resultSet.getString("lang");
58 |
59 | guilds.put(id, new Guild(id, name, prefix, Language.valueOf(lang)));
60 | }
61 | } catch (SQLException e) {
62 | LOG.error(e.getMessage());
63 | }
64 | }
65 | return guilds;
66 | }
67 |
68 | public synchronized static Guild getGuild(discord4j.core.object.entity.Guild discordGuild){
69 | Guild guild = getGuilds().get(discordGuild.getId().asString());
70 |
71 | if (guild == null){
72 | guild = new Guild(discordGuild.getId().asString(), discordGuild.getName(), Constants.defaultLanguage);
73 | }
74 |
75 | return guild;
76 | }
77 |
78 | public String getId(){
79 | return id;
80 | }
81 |
82 | public String getName(){
83 | return name;
84 | }
85 |
86 | public String getPrefix(){ return prefix; }
87 |
88 | public Language getLanguage() {
89 | return language;
90 | }
91 | }
--------------------------------------------------------------------------------
/src/main/java/util/Translator.java:
--------------------------------------------------------------------------------
1 | package util;
2 |
3 | import data.ChannelLanguage;
4 | import data.Constants;
5 | import data.Guild;
6 | import discord4j.core.object.entity.channel.GuildMessageChannel;
7 | import discord4j.core.object.entity.channel.MessageChannel;
8 | import enums.Language;
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | import java.io.BufferedReader;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | import java.io.InputStreamReader;
16 | import java.nio.charset.StandardCharsets;
17 | import java.util.Map;
18 | import java.util.Properties;
19 | import java.util.concurrent.ConcurrentHashMap;
20 | import java.util.stream.Stream;
21 |
22 | /**
23 | * Created by steve on 06/06/2017.
24 | */
25 | public class Translator {
26 |
27 | private final static Logger LOG = LoggerFactory.getLogger(Translator.class);
28 | private static Map labels;
29 |
30 | /**
31 | * Fournit la langue utilisée dans un salon textuel
32 | * @param channel Salon textuel
33 | * @return Langue de la guilde ou du salon si précisé
34 | */
35 | public static Language getLanguageFrom(MessageChannel channel){
36 | Language result = Constants.defaultLanguage;
37 | if (channel instanceof GuildMessageChannel) {
38 |
39 | Guild guild = Guild.getGuild(((GuildMessageChannel) channel).getGuild().block());
40 | result = guild.getLanguage();
41 | ChannelLanguage channelLanguage = ChannelLanguage.getChannelLanguages().get(channel.getId().asLong());
42 | if (channelLanguage != null)
43 | result = channelLanguage.getLang();
44 | }
45 | return result;
46 | }
47 |
48 | public static Language mapLocale(String locale){
49 | return Stream.of(Language.values())
50 | .filter(lg -> lg.getLocales().contains(locale))
51 | .findFirst()
52 | .orElse(Constants.defaultLanguage);
53 | }
54 |
55 | /**
56 | * Fournit un libellé dans la langue choisi, pour un code donné
57 | * @param lang Language du libellé
58 | * @param property code du libellé
59 | * @return Libellé correspondant au code, dans la langue choisie
60 | */
61 | public synchronized static String getLabel(Language lang, String property){
62 | if (labels == null){
63 | labels = new ConcurrentHashMap<>();
64 |
65 | for(Language language : Language.values())
66 | try(InputStream file = Translator.class.getResourceAsStream("/label_" + language.getAbrev())) {
67 | Properties prop = new Properties();
68 | prop.load(new BufferedReader(new InputStreamReader(file, StandardCharsets.UTF_8)));
69 | labels.put(language, prop);
70 | } catch (IOException e) {
71 | LOG.error("Translator.getLabel", e);
72 | }
73 | }
74 |
75 | String value = labels.get(lang).getProperty(property);
76 | if (value == null || value.trim().isEmpty())
77 | if (Constants.defaultLanguage != lang) {
78 | LOG.warn("Missing label in " + lang.getAbrev() + " : " + property);
79 | return getLabel(Constants.defaultLanguage, property);
80 | }
81 | else
82 | return property;
83 | return value;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/util/ClientConfig.java:
--------------------------------------------------------------------------------
1 | package util;
2 |
3 | import data.Constants;
4 | import discord4j.core.DiscordClient;
5 | import discord4j.core.GatewayDiscordClient;
6 | import discord4j.core.event.domain.message.MessageCreateEvent;
7 | import discord4j.core.object.presence.ClientActivity;
8 | import discord4j.core.object.presence.ClientPresence;
9 | import discord4j.core.shard.MemberRequestFilter;
10 | import discord4j.gateway.intent.Intent;
11 | import discord4j.gateway.intent.IntentSet;
12 | import listeners.MessageListener;
13 | import org.slf4j.Logger;
14 | import org.slf4j.LoggerFactory;
15 | import reactor.core.publisher.Mono;
16 |
17 | import java.io.File;
18 | import java.io.FileInputStream;
19 | import java.io.FileNotFoundException;
20 | import java.io.IOException;
21 | import java.net.URLDecoder;
22 | import java.nio.charset.StandardCharsets;
23 | import java.util.Properties;
24 |
25 | /**
26 | * Created by steve on 14/07/2016.
27 | */
28 | public class ClientConfig {
29 |
30 | private static ClientConfig instance = null;
31 | private static final Logger LOG = LoggerFactory.getLogger(ClientConfig.class);
32 | private static final String FILENAME = "config.properties";
33 | private DiscordClient DISCORD;
34 |
35 | private ClientConfig(){
36 | this(System.getProperty("user.dir"));
37 | }
38 |
39 | private ClientConfig(String path){
40 | super();
41 | Properties prop = new Properties();
42 | String config = path + File.separator + FILENAME;
43 |
44 | try (FileInputStream file = new FileInputStream(URLDecoder.decode(config, StandardCharsets.UTF_8))){
45 | prop.load(file);
46 | } catch(FileNotFoundException e){
47 | LOG.error("Configuration file not found");
48 | } catch (IOException e) {
49 | LOG.error("IOException encountered", e);
50 | }
51 |
52 | try {
53 | DISCORD = DiscordClient.create(prop.getProperty("discord.token"));
54 | } catch(Exception e){
55 | LOG.error("Impossible to connect to Discord: check your token in "
56 | + FILENAME + " as well as your connection.");
57 | }
58 | }
59 |
60 | public static synchronized ClientConfig getInstance(){
61 | if (instance == null)
62 | instance = new ClientConfig();
63 | return instance;
64 | }
65 |
66 | public static DiscordClient DISCORD() {
67 | return getInstance().DISCORD;
68 | }
69 |
70 | public void loginDiscord(){
71 | DISCORD().gateway()
72 | .setEnabledIntents(IntentSet.of(
73 | Intent.GUILDS,
74 | Intent.GUILD_MEMBERS,
75 | Intent.GUILD_MESSAGES,
76 | Intent.GUILD_MESSAGE_REACTIONS,
77 | Intent.DIRECT_MESSAGES))
78 | .setInitialPresence($ -> ClientPresence.online(ClientActivity.watching(Constants.discordInvite)))
79 | .setMemberRequestFilter(MemberRequestFilter.none())
80 | .withGateway(client -> Mono.when(legacyCommandListener(client)))
81 | .block();
82 | }
83 |
84 | public static synchronized ClientConfig getInstance(String path){
85 | if (instance == null)
86 | instance = new ClientConfig(path);
87 | return instance;
88 | }
89 |
90 | private Mono legacyCommandListener(GatewayDiscordClient client){
91 | final MessageListener listener = new MessageListener();
92 | return client.getEventDispatcher().on(MessageCreateEvent.class)
93 | .flatMap(listener::onReady)
94 | .then();
95 | }
96 | }
--------------------------------------------------------------------------------
/src/main/resources/label_EN:
--------------------------------------------------------------------------------
1 | about.request=Command available via `/about`, with almost identical behavior.
2 | about.help=becomes `/about`.
3 | align.request=Command available via `/align`. Multiple choices:\n- `/align get` to view guild alignments\n- `/align set` to save your alignment level\n\nYou can also view someone's alignment (right-click > Applications > Alignments).
4 | align.help=becomes `/align`.
5 | alliance.request=Command now removed: no more possible, cf. [Ankama announcement](https://www.dofus.com/en/mmorpg/news/announcements/1757992-deactivation-certain-consultation-pages-dofus-website).
6 | alliance.help=has been removed.
7 | almanax.request=Command available via `/almanax`. Multiple choices:\n- `/almanax day` to view a specific day\n- `/almanax effect` to find days with the desired effect\n- `/almanax resource` to retrieve the list of offerings for the next *X* days.
8 | almanax.help=becomes `/almanax`.
9 | almanax-auto.request=Command available via `/config almanax`. The "*Manage webhooks*" permission is required.
10 | almanax-auto.help=becomes `/config almanax`.
11 | command.request=Command now removed: the behavior of "Slash Commands" and permissions is incompatible.
12 | command.help=has been removed.
13 | distance.request=Command now removed: low usage and limited applicability.
14 | distance.help=has been removed.
15 | donate.request=Command now integrated into `/about`.
16 | donate.help=is integrated into `/about`.
17 | guild.request=Command now removed: no more possible, cf. [Ankama announcement](https://www.dofus.com/en/mmorpg/news/announcements/1757992-deactivation-certain-consultation-pages-dofus-website).
18 | guild.help=has been removed.
19 | help.request=Command available via `/help`, with almost identical behavior but more explicit, including mini-tutorials.
20 | help.help=becomes `/help`.
21 | invite.request=Command now integrated into `/about`.
22 | invite.help=is integrated into `/about`.
23 | item.request=Command available via `/item`, allowing navigation from effects to recipes, including associated sets.
24 | item.help=becomes `/item`.
25 | job.request=Command available via `/job`. Multiple choices:\n- `/job get` to view guild professions\n- `/job set` to save your artisan skills\n\nYou can also view someone's professions (right-click > Applications > Jobs).
26 | job.help=becomes `/job`.
27 | lang.request=Command now removed: interactions adapt to the user's language.
28 | lang.help=has been removed.
29 | map.request=Command available via `/map`, with almost identical behavior.
30 | map.help=becomes `/map`.
31 | monster.request=Command currently unavailable; it may return in the future.
32 | monster.help=is currently unavailable.
33 | ping.request=Command now removed: little practical usage.
34 | ping.help=has been removed.
35 | portal.request=Command available via `/pos`, with almost identical behavior; will be removed when Osamodas dimension is out.
36 | portal.help=becomes `/pos`.
37 | prefix.request=Command now removed: the behavior of "Slash Commands" no longer justifies the use of a custom prefix.
38 | prefix.help=has been removed.
39 | random.request=Command now removed: little practical usage.
40 | random.help=has been removed.
41 | resource.request=Command currently unavailable; it may return in the future.
42 | resource.help=is currently unavailable.
43 | rss.request=Command available via `/config rss`. The "*Manage webhooks*" permission is required.
44 | rss.help=becomes `/config rss`.
45 | server.request=Command available via `/config server`.
46 | server.help=becomes `/config server`.
47 | set.request=Command available via `/set`, allowing navigation between items in the viewed set and their various effects.
48 | set.help=becomes `/set`.
49 | tutorial.request=Command currently unavailable; it will return in the future.
50 | tutorial.help=is currently unavailable.
51 | twitter.request=Command available via `/config twitter`. The "*Manage webhooks*" permission is required.
52 | twitter.help=becomes `/config twitter`.
53 | whois.request=Command now removed: no more possible, cf. [Ankama announcement](https://www.dofus.com/en/mmorpg/news/announcements/1757992-deactivation-certain-consultation-pages-dofus-website).
54 | whois.help=has been removed.
55 |
--------------------------------------------------------------------------------
/src/main/resources/label_ES:
--------------------------------------------------------------------------------
1 | about.request=Comando disponible a través de `/about`, con un comportamiento casi idéntico.
2 | about.help=se convierte en `/about`.
3 | align.request=Comando disponible a través de `/align`. Varias opciones:\n- `/align get` para consultar los alineamientos del gremio\n- `/align set` para registrar tu nivel de alineamiento\n\nTambién puedes consultar el alineamiento de alguien (clic derecho > Aplicaciones > Alignments).
4 | align.help=se convierte en `/align`.
5 | alliance.request=Comando ahora eliminado: ya no es posible, cf. [Anuncio de Ankama](https://www.dofus.com/es/mmorpg/actualidad/noticias/1757993-desactivacion-algunas-paginas-consulta-sitio-dofus).
6 | alliance.help=ha sido eliminado.
7 | almanax.request=Comando disponible a través de `/almanax`. Varias opciones:\n- `/almanax day` para consultar un día específico\n- `/almanax effect` para encontrar días con el efecto deseado\n- `/almanax resource` para obtener la lista de ofrendas para los próximos *X* días.
8 | almanax.help=se convierte en `/almanax`.
9 | almanax-auto.request=Comando disponible a través de `/config almanax`. Es necesario tener el permiso "*Gestionar webhooks*".
10 | almanax-auto.help=se convierte en `/config almanax`.
11 | command.request=Comando ahora eliminado: el funcionamiento de los "Comandos Slash" y los permisos es incompatible.
12 | command.help=ha sido eliminado.
13 | distance.request=Comando ahora eliminado: poco uso y aplicabilidad limitada.
14 | distance.help=ha sido eliminado.
15 | donate.request=Comando ahora integrado en `/about`.
16 | donate.help=está integrado en `/about`.
17 | guild.request=Comando ahora eliminado: ya no es posible, cf. [Anuncio de Ankama](https://www.dofus.com/es/mmorpg/actualidad/noticias/1757993-desactivacion-algunas-paginas-consulta-sitio-dofus).
18 | guild.help=ha sido eliminado.
19 | help.request=Comando disponible a través de `/help`, con un comportamiento casi idéntico pero más explícito, incluyendo mini tutoriales.
20 | help.help=se convierte en `/help`.
21 | invite.request=Comando ahora integrado en `/about`.
22 | invite.help=está integrado en `/about`.
23 | item.request=Comando disponible a través de `/item`, que permite navegar desde los efectos hasta las recetas, incluyendo los conjuntos asociados.
24 | item.help=se convierte en `/item`.
25 | job.request=Comando disponible a través de `/job`. Varias opciones:\n- `/job get` para consultar las profesiones del gremio\n- `/job set` para registrar tus habilidades de artesano\n\nTambién puedes consultar las profesiones de alguien (clic derecho > Aplicaciones > Jobs).
26 | job.help=se convierte en `/job`.
27 | lang.request=Comando ahora eliminado: las interacciones se adaptan al idioma del usuario.
28 | lang.help=ha sido eliminado.
29 | map.request=Comando disponible a través de `/map`, con un comportamiento casi idéntico.
30 | map.help=se convierte en `/map`.
31 | monster.request=Comando actualmente no disponible; podría volver en el futuro.
32 | monster.help=está actualmente no disponible.
33 | ping.request=Comando ahora eliminado: poco uso práctico.
34 | ping.help=ha sido eliminado.
35 | portal.request=Comando disponible a través de `/pos`, con un comportamiento casi idéntico; se eliminará cuando salga la dimensión de Osamodas.
36 | portal.help=se convierte en `/pos`.
37 | prefix.request=Comando ahora eliminado: el funcionamiento de los "Comandos Slash" ya no justifica el uso de un prefijo personalizado.
38 | prefix.help=ha sido eliminado.
39 | random.request=Comando ahora eliminado: poco uso práctico.
40 | random.help=ha sido eliminado.
41 | resource.request=Comando actualmente no disponible; podría volver en el futuro.
42 | resource.help=está actualmente no disponible.
43 | rss.request=Comando disponible a través de `/config rss`. Es necesario tener el permiso "*Gestionar webhooks*".
44 | rss.help=se convierte en `/config rss`.
45 | server.request=Comando disponible a través de `/config server`.
46 | server.help=se convierte en `/config server`.
47 | set.request=Comando disponible a través de `/set`, que permite navegar entre los objetos del conjunto visualizado y sus diversos efectos.
48 | set.help=se convierte en `/set`.
49 | tutorial.request=Comando actualmente no disponible; volverá en el futuro.
50 | tutorial.help=está actualmente no disponible.
51 | twitter.request=Comando disponible a través de `/config twitter`. Es necesario tener el permiso "*Gestionar webhooks*".
52 | twitter.help=se convierte en `/config twitter`.
53 | whois.request=Comando ahora eliminado: ya no es posible, cf. [Anuncio de Ankama](https://www.dofus.com/es/mmorpg/actualidad/noticias/1757993-desactivacion-algunas-paginas-consulta-sitio-dofus).
54 | whois.help=ha sido eliminado.
55 |
--------------------------------------------------------------------------------
/src/main/resources/label_FR:
--------------------------------------------------------------------------------
1 | about.request=Commande utilisable via `/about`, le comportement est quasi similaire.
2 | about.help=devient `/about`.
3 | align.request=Commande utilisable via `/align`. Plusieurs choix possibles :\n- `/align get` pour consulter les alignements de la guilde\n- `/align set` pour enregistrer son niveau d'alignement\n\nIl est également possible de consulter l'alignement d'une personne (clique-droit > Applications > Alignments).
4 | align.help=devient `/align`.
5 | alliance.request=Commande désormais supprimée : cela n'est plus possible, cf. [communiqué d'Ankama](https://www.dofus.com/fr/mmorpg/actualites/news/1756212-desactivation-certaines-pages-consultation-site-dofus).
6 | alliance.help=est supprimée.
7 | almanax.request=Commande utilisable via `/almanax`. Plusieurs choix possibles :\n- `/almanax day` pour consulter un jour particulier\n- `/almanax effect` pour consulter les jours avec l'effet désiré\n- `/almanax resource` pour récupérer la liste des offrandes pour les *X* prochains jours.
8 | almanax.help=devient `/almanax`.
9 | almanax-auto.request=Commande utilisable via `/config almanax`. Le droit de ""*Gérer les webhooks*" est nécessaire.
10 | almanax-auto.help=devient `/config almanax`.
11 | command.request=Commande désormais supprimée : le fonctionnement des "Commandes Slash" et des permissions est incompatible.
12 | command.help=est supprimée.
13 | distance.request=Commande désormais supprimée : peu d'utilisation est peu exploitable en réalité.
14 | distance.help=est supprimée.
15 | donate.request=Commande désormais intégrée à `/about`.
16 | donate.help=est intégrée à `/about`.
17 | guild.request=Commande désormais supprimée : cela n'est plus possible, cf. [communiqué d'Ankama](https://www.dofus.com/fr/mmorpg/actualites/news/1756212-desactivation-certaines-pages-consultation-site-dofus).
18 | guild.help=est supprimée.
19 | help.request=Commande utilisable via `/help`, son comportement est quasi similaire et surtout plus explicite avec notamment des mini-tutoriels.
20 | help.help=devient `/help`.
21 | invite.request=Commande désormais intégrée à `/about`.
22 | invite.help=est intégrée à `/about`.
23 | item.request=Commande utilisable via `/item`, permettant de naviguer des effets à la recette en passant par la panoplie associée.
24 | item.help=devient `/item`.
25 | job.request=Commande utilisable via `/job`. Plusieurs choix possibles :\n- `/job get` pour consulter les métiers de la guilde\n- `/job set` pour enregistrer ses talents d'artisan\n\nIl est également possible de consulter les métiers d'une personne (clique-droit > Applications > Jobs).
26 | job.help=devient `/job`.
27 | lang.request=Commande désormais supprimée : les interactions s'adaptent à la langue de l'utilisateur.
28 | lang.help=est supprimée.
29 | map.request=Commande utilisable via `/map`, son comportement est quasi similaire.
30 | map.help=devient `/map`.
31 | monster.request=Commande pour le moment indisponible; elle reviendra peut-être prochainement.
32 | monster.help=est indisponible pour le moment.
33 | ping.request=Commande désormais supprimée : peu d'utilisation dans les faits.
34 | ping.help=est supprimée.
35 | portal.request=Commande utilisable via `/pos`, son comportement est quasi similaire; sera supprimée avec la sortie de la dimension Osamodas.
36 | portal.help=devient `/pos`.
37 | prefix.request=Commande désormais supprimée : le fonctionnement des "Commandes Slash" ne justifie plus l'usage d'un préfixe personnalisé.
38 | prefix.help=est supprimée.
39 | random.request=Commande désormais supprimée : peu d'utilisation dans les faits.
40 | random.help=est supprimée.
41 | resource.request=Commande pour le moment indisponible; elle reviendra peut-être prochainement.
42 | resource.help=est indisponible pour le moment.
43 | rss.request=Commande utilisable via`/config rss`. Le droit de ""*Gérer les webhooks*" est nécessaire.
44 | rss.help=devient `/config rss`.
45 | server.request=Commande utilisable via`/config server`.
46 | server.help=devient `/config server`.
47 | set.request=Commande utilisable via`/set`, permettant de naviguer entre les items composant la panoplie consultée et les différents effets apportés.
48 | set.help=devient `/set`.
49 | tutorial.request=Commande pour le moment indisponible; elle reviendra prochainement.
50 | tutorial.help=est indisponible pour le moment.
51 | twitter.request=Commande utilisable via`/config twitter`. Le droit de ""*Gérer les webhooks*" est nécessaire.
52 | twitter.help=devient `/config twitter`.
53 | whois.request=Commande désormais supprimée : cela n'est plus possible, cf. [communiqué d'Ankama](https://www.dofus.com/fr/mmorpg/actualites/news/1756212-desactivation-certaines-pages-consultation-site-dofus).
54 | whois.help=est supprimée.
55 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # KaellyBOT
2 |
3 |
4 |
5 | KaellyBOT aims to provide useful commands for DOFUS community (FR/EN/ES)! If you have questions, suggestions or just want to say hello, feel free to join the [discord support server](https://discord.gg/CyJCFDk) :)
6 |
7 | ## Invite KaellyBOT to your server
8 | There is a running official instance used by 13.000+ discord servers and 660.000+ users.
9 | Just [click here](https://discordapp.com/oauth2/authorize?&client_id=202916641414184960&scope=bot), follow the discord instructions and that's it!
10 |
11 | ## Commands
12 |
13 | The commands below won't work anymore sooner or later. This bot was created before slash commands arrived and the new version is heavily related to this Discord interaction system now.
14 | That being said, the commands principle remains the same, just use `/` in Discord!
15 | 
16 |
17 | ## Data privacy
18 | Only Discord user IDs are stored in database to make it run.
19 | This data is registered when a user register himself in a book like the job book; users can be easily unregistered as described in each *book command* help.
20 |
21 | **Collected information are and will never be used for commercial purposes.**
22 |
23 | ## Developer section
24 | This section is dedicated for developers. If you're not, please use the official instance described above.
25 | *Note: this repository is considered as deprecated: you can find some explanations just below.*
26 |
27 | ### Current structure
28 | - Java 8 project based on Discord4J V3.2.1
29 | - Built with Maven
30 | - Commands detection with regex
31 | - Store data into SQLite database
32 | - Start it with `java -jar Kaellybot.jar`
33 |
34 | ### Limitations
35 | With the time and the growing usage, a lot of new problems appear:
36 | - The use of file database is limited and adapted for small bots
37 | - No smart caching for stored data
38 | - No use of Reactor project to optimize the performances
39 | - Permissions needed to send a message are not well checked
40 | - Commands arguments are not well divided: all behaviour described in the command class
41 | - Almanax, RSS and Twitter events are not well managed for large bots (it breaks very often)
42 | - Usage of tmux/screen to host it
43 | - Some of these previous limitations require more RAM and so increase the cost to host it
44 | - Updates force downtime on any servers, on any features
45 | - One monolith handles every Discord shards making it clumsy when one shard is offline time to time
46 |
47 | All these factors push me to put this project as deprecated and to think about a new architecture.
48 |
49 | ### What's next?
50 | The [KaellyBot organization](https://github.com/KaellyBot/) has been created as ecosystem divided into modular repositories (based on Golang and communicating through RabbitMQ), each serving a specific purpose:
51 | * Kaelly-discord
52 | * Handles Discord interactions, commands, and events.
53 |
54 | * Kaelly-encyclopedia
55 | * Retrieves game data like items, sets, almanax from [DofusDude API](http://dofusdu.de).
56 |
57 | * Kaelly-configurator
58 | * Handles bot configurations like game server binding, webhooks notifications, etc.
59 |
60 | * Kaelly-books
61 | * Handles alignment and job registries.
62 |
63 | * Kaelly-rss
64 | * Retrieves RSS feeds from Ankama games websites
65 |
66 | * Kaelly-twitter
67 | * Retrieves tweets from official Ankama game account
68 |
69 | * Kaelly-metrics
70 | * Collects, processes, and visualizes bot metrics for insights.
71 |
72 | ... and so on. Here below the planned architecture with most of the modules.
73 | 
74 |
75 | There is still a lot to do and the beginning of a new start, I'm working actively on it! If you want to help, feel free to join the [discord support server](https://discord.gg/CyJCFDk) and discuss! :)
76 |
77 | ### What about this repository?
78 |
79 | Well, it won't be archived but probably used as documentation to explain KaellyBot history, tech choices and how to use it right now.
80 |
81 | ## License
82 | KaellyBOT is [GPL(v3) licensed](./LICENSE).
83 |
84 | ## Thank you!
85 |
86 | The development and the availability of KaellyBot 24/7 generate ongoing cost. Do not hesitate to help the project grow with a donation!
87 | [](https://www.paypal.me/kaysoro)
88 |
89 | ### Donors
90 |
91 | - Hart69
92 | - Eaglow
93 | - Darkrai25
94 | - DreamsVoid
95 | - Siid
96 | - Tynagmo
97 | - Nocks
98 | - Sacree-Sacri
99 |
100 | ## Star History
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/src/main/java/commands/admin/StatCommand.java:
--------------------------------------------------------------------------------
1 | package commands.admin;
2 |
3 | import commands.model.AbstractLegacyCommand;
4 | import discord4j.common.store.action.read.ReadActions;
5 | import discord4j.core.event.domain.message.MessageCreateEvent;
6 | import discord4j.core.object.entity.Guild;
7 | import discord4j.core.object.entity.Message;
8 | import discord4j.core.spec.MessageCreateFields;
9 | import discord4j.core.spec.MessageCreateSpec;
10 | import discord4j.discordjson.json.GuildData;
11 | import enums.Language;
12 | import org.jfree.chart.ChartFactory;
13 | import org.jfree.chart.JFreeChart;
14 | import org.jfree.data.time.Day;
15 | import org.jfree.data.time.TimeSeries;
16 | import org.jfree.data.time.TimeSeriesCollection;
17 | import org.slf4j.LoggerFactory;
18 | import reactor.core.publisher.Flux;
19 | import reactor.core.publisher.Mono;
20 | import util.Translator;
21 |
22 | import javax.imageio.ImageIO;
23 | import java.awt.image.BufferedImage;
24 | import java.io.ByteArrayInputStream;
25 | import java.io.ByteArrayOutputStream;
26 | import java.io.InputStream;
27 | import java.time.Instant;
28 | import java.time.format.DateTimeFormatter;
29 | import java.util.Collections;
30 | import java.util.Comparator;
31 | import java.util.Date;
32 | import java.util.List;
33 | import java.util.regex.Matcher;
34 | import java.util.stream.Collectors;
35 |
36 | /**
37 | * Created by steve on 23/12/2017.
38 | */
39 | public class StatCommand extends AbstractLegacyCommand {
40 |
41 | private static final int GULD_LIMIT = 10;
42 |
43 | public StatCommand(){
44 | super("stats","(\\s+-g(\\s+\\d+)?|\\s+-cmd(\\s+\\d+)?|\\s+-hist)?");
45 | setAdmin(true);
46 | }
47 |
48 | @Override
49 | public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
50 | if (m.group(1) == null || m.group(1).replaceAll("^\\s+", "").isEmpty()){
51 | long connectedShards = event.getClient().getGatewayResources().getShardCoordinator()
52 | .getConnectedCount()
53 | .blockOptional().orElse(0);
54 | long totalGuild = Mono.from(event.getClient().getGatewayResources().getStore()
55 | .execute(ReadActions.countGuilds()))
56 | .blockOptional().orElse(0L);
57 | long totalMembers = event.getClient().getGuilds()
58 | .collect(Collectors.summingLong(Guild::getMemberCount))
59 | .blockOptional().orElse(0L);
60 |
61 | String answer = Translator.getLabel(lg, "stat.request")
62 | .replace("{shards.size}", String.valueOf(connectedShards))
63 | .replace("{guilds.size}", String.valueOf(totalGuild))
64 | .replace("{users_max.size}", String.valueOf(totalMembers));
65 | message.getChannel().flatMap(chan -> chan.createMessage(answer)).subscribe();
66 | }
67 | else if (m.group(1).matches("\\s+-g(\\s+\\d+)?")){
68 | int limit = GULD_LIMIT;
69 | if (m.group(2) != null) limit = Integer.parseInt(m.group(2).trim());
70 | StringBuilder st = new StringBuilder();
71 |
72 | List guilds = Flux.from(event.getClient().getGatewayResources().getStore().execute(ReadActions.getGuilds()))
73 | .sort((guild1, guild2) -> guild2.memberCount() - guild1.memberCount())
74 | .take(limit)
75 | .collectList().block();
76 | int ladder = 1;
77 | for(GuildData guild : guilds)
78 | st.append(ladder++).append(" : **").append(guild.name()).append("**, ")
79 | .append(guild.memberCount()).append(" users\n");
80 |
81 | message.getChannel().flatMap(chan -> chan.createMessage(st.toString())).subscribe();
82 | }
83 | else if (m.group(1).matches("\\s+-hist"))
84 | message.getChannel().flatMap(chan -> chan.createMessage(decorateImageMessage(getJoinTimeGuildsGraph(event))))
85 | .subscribe();
86 | }
87 |
88 | private MessageCreateSpec decorateImageMessage(BufferedImage image) {
89 | ByteArrayOutputStream os = new ByteArrayOutputStream();
90 | try {
91 | ImageIO.write(image, "png", os);
92 | InputStream is = new ByteArrayInputStream(os.toByteArray());
93 | return MessageCreateSpec.builder()
94 | .addFile(MessageCreateFields.File.of(Instant.now().toString() + ".png", is))
95 | .build();
96 | } catch(Exception e){
97 | LoggerFactory.getLogger(StatCommand.class).error("decorateImageMessage", e);
98 | }
99 | return MessageCreateSpec.builder().content("Problem during image process").build();
100 | }
101 |
102 | /**
103 | *
104 | * @return Graphique des arrivés des guildes utilisant kaelly
105 | */
106 | private BufferedImage getJoinTimeGuildsGraph(MessageCreateEvent event){
107 |
108 | List guilds = Flux.from(event.getClient().getGatewayResources().getStore().execute(ReadActions.getGuilds()))
109 | .sort(Comparator.comparing(guild -> DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(guild.joinedAt(), Instant::from)))
110 | .collectList().blockOptional().orElse(Collections.emptyList());
111 | TimeSeriesCollection dataSet = new TimeSeriesCollection();
112 | TimeSeries series = new TimeSeries("data");
113 | int guildNumber = 1;
114 | for(GuildData guild : guilds)
115 | series.addOrUpdate(new Day(Date.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(guild.joinedAt(), Instant::from))), guildNumber++);
116 | dataSet.addSeries(series);
117 |
118 | JFreeChart chart = ChartFactory.createTimeSeriesChart(
119 | "Guilds join time history",
120 | "Date",
121 | "Discord guild number",
122 | dataSet, false, false, false);
123 |
124 | return chart.createBufferedImage(1200, 700);
125 | }
126 |
127 | @Override
128 | public String help(Language lg, String prefix) {
129 | return "";
130 | }
131 |
132 | @Override
133 | public String helpDetailed(Language lg, String prefix) {
134 | return "";
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/main/java/commands/model/AbstractLegacyCommand.java:
--------------------------------------------------------------------------------
1 | package commands.model;
2 |
3 | import data.Constants;
4 | import data.Guild;
5 | import discord4j.common.util.Snowflake;
6 | import discord4j.core.event.domain.message.MessageCreateEvent;
7 | import discord4j.core.object.entity.Message;
8 | import discord4j.core.object.entity.User;
9 | import discord4j.core.object.entity.channel.GuildMessageChannel;
10 | import discord4j.core.object.entity.channel.PrivateChannel;
11 | import discord4j.core.object.entity.channel.TextChannel;
12 | import discord4j.rest.util.Permission;
13 | import discord4j.rest.util.PermissionSet;
14 | import enums.Language;
15 | import org.slf4j.Logger;
16 | import org.slf4j.LoggerFactory;
17 | import util.Translator;
18 |
19 | import java.util.regex.Matcher;
20 | import java.util.regex.Pattern;
21 |
22 | /**
23 | * Created by steve on 14/07/2016.
24 | */
25 | public abstract class AbstractLegacyCommand implements LegacyCommand {
26 |
27 | private final static Logger LOG = LoggerFactory.getLogger(AbstractLegacyCommand.class);
28 |
29 | protected String name;
30 | protected String pattern;
31 | private boolean isPublic;
32 | private boolean isUsableInMP;
33 | private boolean isAdmin;
34 | private boolean isHidden;
35 |
36 |
37 | protected AbstractLegacyCommand(String name, String pattern){
38 | super();
39 | this.name = name;
40 | this.pattern = pattern;
41 | this.isPublic = true;
42 | this.isUsableInMP = true;
43 | this.isAdmin = false;
44 | this.isHidden = false;
45 | }
46 |
47 | @Override
48 | public final void request(MessageCreateEvent event, Message message) {
49 | Language lg = Translator.getLanguageFrom(message.getChannel().block());
50 | try {
51 | Matcher m = getMatcher(message);
52 | boolean isFound = m.find();
53 |
54 | // Caché si la fonction est désactivée/réservée aux admin et que l'auteur n'est pas super-admin
55 | if ((!isPublic() || isAdmin()) && message.getAuthor()
56 | .map(user -> user.getId().asLong() != Constants.authorId).orElse(false))
57 | return;
58 |
59 | // S'il s'agit d'une demande d'aide...
60 | if (message.getContent().matches(Pattern.quote(getPrefix(message)) + getName() + "\\s+help")){
61 | message.getChannel().flatMap(chan -> chan
62 | .createMessage(helpDetailed(lg, getPrefix(message)))).subscribe();
63 | return;
64 | }
65 |
66 | // La commande est trouvée
67 | if (isFound)
68 | request(event, message, m, lg);
69 | } catch(Exception e){
70 | LOG.error("request", e);
71 | }
72 | }
73 |
74 | /**
75 | * @param message Message from the event
76 | * @param m Matcher that permit to fetch data
77 | * @param lg Language of the channel (FR, EN, ES..)
78 | */
79 | protected abstract void request(MessageCreateEvent event, Message message, Matcher m, Language lg);
80 |
81 | @Override
82 | public boolean isForbidden(Guild g){
83 | return false;
84 | }
85 |
86 | @Override
87 | public Matcher getMatcher(Message message){
88 | String prefixe = getPrefix(message);
89 | return Pattern.compile("^" + Pattern.quote(prefixe) + name + pattern + "$")
90 | .matcher(message.getContent());
91 | }
92 |
93 | public static String getPrefix(Message message){
94 | String prefix = "";
95 | if (message.getChannel().block() instanceof GuildMessageChannel)
96 | prefix = Guild.getGuild(message.getGuild().block()).getPrefix();
97 | return prefix;
98 | }
99 |
100 | protected String getPrefixMdEscaped(Message message){
101 | if (!(message.getChannel().block() instanceof PrivateChannel))
102 | return Guild.getGuild(message.getGuild().block()).getPrefix()
103 | .replaceAll("\\*", "\\\\*") // Italic & Bold
104 | .replaceAll("_", "\\_") // Underline
105 | .replaceAll("~", "\\~") // Strike
106 | .replaceAll("\\`", "\\\\`"); // Code
107 | return "";
108 | }
109 |
110 | /**
111 | * @param message message d'origine
112 | * @return true si les permissions sont suffisantes, false le cas échéant
113 | */
114 | protected boolean isChannelHasExternalEmojisPermission(Message message){
115 | return message.getChannel().blockOptional().filter(messageChannel -> messageChannel instanceof PrivateChannel ||
116 | ((TextChannel) messageChannel).getEffectivePermissions(message.getClient().getSelfId())
117 | .blockOptional().orElse(PermissionSet.none())
118 | .contains(Permission.USE_EXTERNAL_EMOJIS)).isPresent();
119 | }
120 |
121 | /**
122 | * Retourne true si l'utilisateur a les droits nécessaires, false le cas échéant
123 | * @param message Message reçu
124 | * @return true si l'utilisateur a les droits nécessaires, false le cas échéant
125 | */
126 | protected boolean isUserHasEnoughRights(Message message){
127 | return message.getChannel().blockOptional()
128 | .filter(messageChannel -> !(messageChannel instanceof PrivateChannel) && (message.getAuthor()
129 | .map(user -> user.getId().asLong() == Constants.authorId).orElse(false)
130 | || ((GuildMessageChannel) messageChannel).getEffectivePermissions(message.getAuthor()
131 | .map(User::getId).orElse(Snowflake.of(0L))).blockOptional().orElse(PermissionSet.none())
132 | .contains(Permission.MANAGE_GUILD))).isPresent();
133 | }
134 |
135 | @Override
136 | public String getName() {
137 | return name;
138 | }
139 |
140 | @Override
141 | public String getPattern() {
142 | return pattern;
143 | }
144 |
145 | @Override
146 | public void setPublic(boolean isPublic){
147 | this.isPublic = isPublic;
148 | }
149 |
150 | @Override
151 | public boolean isPublic(){ return isPublic; }
152 |
153 | @Override
154 | public boolean isUsableInMP(){ return isUsableInMP; }
155 |
156 | @Override
157 | public void setUsableInMP(boolean isUsableInMP) {
158 | this.isUsableInMP = isUsableInMP;
159 | }
160 |
161 | @Override
162 | public boolean isAdmin() {
163 | return isAdmin;
164 | }
165 |
166 | @Override
167 | public void setAdmin(boolean isAdmin) {
168 | this.isAdmin = isAdmin;
169 | }
170 |
171 | @Override
172 | public boolean isHidden() {
173 | return isHidden;
174 | }
175 |
176 | @Override
177 | public void setHidden(boolean isHidden) {
178 | this.isHidden = isHidden;
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------