Compare commits
No commits in common. "80007fec197fe2908cde91e437b0273480bd7cf3" and "74180dcd20861a8f7b40fb330ba196ce16d59938" have entirely different histories.
80007fec19
...
74180dcd20
@ -1,16 +0,0 @@
|
||||
name: "Build and test program"
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: "Build and test"
|
||||
runs-on: java-bookworm
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Compile
|
||||
run: gradle --build-cache compileJava
|
||||
- name: Test
|
||||
run: gradle --build-cache check
|
||||
- name: Package
|
||||
run: gradle --build-cache assemble
|
77
.gitlab-ci.yml
Normal file
77
.gitlab-ci.yml
Normal file
@ -0,0 +1,77 @@
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- package
|
||||
- release
|
||||
|
||||
# Disable the Gradle daemon for Continuous Integration servers as correctness
|
||||
# is usually a priority over speed in CI environments. Using a fresh
|
||||
# runtime for each build is more reliable since the runtime is completely
|
||||
# isolated from any previous builds.
|
||||
variables:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
|
||||
DOCKER_HOST: tcp://docker:2376
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
CONTAINER_BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
||||
|
||||
before_script:
|
||||
- export GRADLE_USER_HOME=`pwd`/.gradle
|
||||
|
||||
build:
|
||||
image: gradle:jdk15
|
||||
stage: build
|
||||
script: gradle --build-cache compileJava
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: push
|
||||
paths:
|
||||
- build
|
||||
- .gradle
|
||||
|
||||
|
||||
test:
|
||||
image: gradle:jdk15
|
||||
stage: test
|
||||
script: gradle --build-cache check
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: pull
|
||||
paths:
|
||||
- build
|
||||
- .gradle
|
||||
|
||||
package:
|
||||
image: gradle:jdk15
|
||||
stage: package
|
||||
script: gradle --build-cache assemble
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_NAME"
|
||||
policy: push
|
||||
paths:
|
||||
- build
|
||||
- .gradle
|
||||
artifacts:
|
||||
paths:
|
||||
- app/build/libs/app.jar
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- docker build . -t $CONTAINER_BRANCH_IMAGE
|
||||
- docker push $CONTAINER_BRANCH_IMAGE
|
||||
|
||||
release-master:
|
||||
stage: release
|
||||
script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- docker build . -t $CONTAINER_RELEASE_IMAGE
|
||||
- docker push $CONTAINER_RELEASE_IMAGE
|
||||
only:
|
||||
- master
|
@ -35,7 +35,7 @@ jar {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.discord4j:discord4j-core:3.1.5'
|
||||
implementation 'com.discord4j:discord4j-core:3.1.1'
|
||||
implementation 'ch.qos.logback:logback-classic:1.2.3'
|
||||
implementation 'org.postgresql:postgresql:42.2.18.jre7'
|
||||
implementation 'org.apache.commons:commons-lang3:3.11'
|
||||
|
@ -8,10 +8,10 @@ import xyz.vallat.louis.timer.TimerManager;
|
||||
|
||||
public class App {
|
||||
|
||||
public static final String PREFIX = "+";
|
||||
public static final String PREFIX = ";";
|
||||
public static final String NAME = "PrésencEirb";
|
||||
public static final String DESCRIPTION = "Tu as pensé à pointer ?";
|
||||
public static final String VERSION = "0.4.0";
|
||||
public static final String VERSION = "0.3.3";
|
||||
private static final Logger logger = LoggerFactory.getLogger(App.class.getCanonicalName());
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -50,4 +50,8 @@ public abstract class Command {
|
||||
.addField("IDENTIFIER", errorCode, false).setTimestamp(Instant.now());
|
||||
})).then();
|
||||
}
|
||||
|
||||
protected String[] getArgArray(MessageCreateEvent event) {
|
||||
return event.getMessage().getContent().substring(name.length()).split(" ");
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
public class Edt extends Command {
|
||||
|
||||
public Edt(String name) {
|
||||
super(name, "Récupère (au maximum) tes 5 prochaines cours.", name);
|
||||
super(name, "Récupère tes 5 prochaines cours (si tu en as 5 ou plus).", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,10 +27,10 @@ public class Edt extends Command {
|
||||
return messageChannel.createMessage("On dirait que tu n'es pas dans ma base de données ! Es tu inscrit ?");
|
||||
return messageChannel.createEmbed(e -> {
|
||||
List<Event> events = EventManager.getNextEventsFromStudent(s);
|
||||
if (events.size() > 5) events = events.subList(0, 5);
|
||||
if (events.size() >= 5) events = events.subList(0, 5);
|
||||
e.setTitle("Prochains cours")
|
||||
.setFooter("Liste des " + events.size() + " prochains cours", null)
|
||||
.setDescription("Voici tes " + events.size() + " prochains cours, <@!" + s.getSnowflake() + "> :")
|
||||
.setFooter("Liste des 5 prochains cours", null)
|
||||
.setDescription("Voici tes 5 prochains cours, <@!" + s.getSnowflake() + "> :")
|
||||
.setColor(Color.GREEN);
|
||||
events.forEach(ev -> e.addField(ev.getStartEvent().toString(), ev.getSummary(), false));
|
||||
e.setTimestamp(Instant.now());
|
||||
|
@ -36,10 +36,10 @@ public final class EventManager {
|
||||
connection.rollback();
|
||||
} else {
|
||||
try {
|
||||
logger.debug("'{}' events re-imported, committing.", importedEvents);
|
||||
logger.debug("'{}' events reimported, commiting.", importedEvents);
|
||||
connection.commit();
|
||||
} catch (SQLException e) {
|
||||
logger.error("An SQLException occurred, rolling back.", e);
|
||||
logger.error("An SQLExcetpion occured, rolling back.", e);
|
||||
connection.rollback();
|
||||
}
|
||||
}
|
||||
|
@ -5,18 +5,17 @@ import discord4j.core.DiscordClientBuilder;
|
||||
import discord4j.core.GatewayDiscordClient;
|
||||
import discord4j.core.event.domain.lifecycle.ReadyEvent;
|
||||
import discord4j.core.event.domain.message.MessageCreateEvent;
|
||||
import discord4j.core.event.domain.message.ReactionAddEvent;
|
||||
import discord4j.core.object.entity.User;
|
||||
import discord4j.core.object.presence.Activity;
|
||||
import discord4j.core.object.presence.Presence;
|
||||
import discord4j.core.object.reaction.ReactionEmoji;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
import xyz.vallat.louis.commands.*;
|
||||
import xyz.vallat.louis.environment.EnvironmentVariables;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static xyz.vallat.louis.App.PREFIX;
|
||||
|
||||
@ -24,16 +23,6 @@ public final class DiscordManager {
|
||||
|
||||
private static final List<Command> commands = new ArrayList<>();
|
||||
private static final Logger logger = LoggerFactory.getLogger(DiscordManager.class.getCanonicalName());
|
||||
private static final ReactionEmoji[] reactionAnswers = {
|
||||
ReactionEmoji.unicode("\uD83E\uDD16"), // robot head
|
||||
ReactionEmoji.unicode("\uD83D\uDE0B"), // smile with tongue out
|
||||
ReactionEmoji.unicode("\uD83E\uDD70"), // smile with hearts
|
||||
ReactionEmoji.unicode("\uD83E\uDD29"), // smile with stars in eyes
|
||||
ReactionEmoji.unicode("\uD83D\uDE01"), // smile
|
||||
ReactionEmoji.unicode("\uD83D\uDE07"), // innocent
|
||||
ReactionEmoji.unicode("\uD83D\uDCAF"), // 1OO
|
||||
ReactionEmoji.unicode("\uD83E\uDDBE") // robot arm
|
||||
};
|
||||
private static GatewayDiscordClient discordClient;
|
||||
|
||||
static {
|
||||
@ -61,18 +50,6 @@ public final class DiscordManager {
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
private static void registerReactionEvents() {
|
||||
discordClient.getEventDispatcher().on(ReactionAddEvent.class)
|
||||
.flatMap(ReactionAddEvent::getMessage)
|
||||
.filter(message -> message.getAuthor().isPresent()
|
||||
&& message.getAuthor().get().equals(discordClient.getSelf().block()))
|
||||
.filter(message -> message.getReactions().stream()
|
||||
.noneMatch(r -> message.getReactors(r.getEmoji()).toStream()
|
||||
.anyMatch(u -> u.equals(discordClient.getSelf().block()))))
|
||||
.flatMap(message -> message.addReaction(reactionAnswers[new Random().nextInt(reactionAnswers.length)]).then())
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
public static void login() {
|
||||
discordClient = DiscordClientBuilder.create(System.getenv(EnvironmentVariables.DISCORD_TOKEN.getValue()))
|
||||
.build().login().retry(2)
|
||||
@ -89,7 +66,6 @@ public final class DiscordManager {
|
||||
logger.info("Logged in on Discord as {}#{}.", self.getUsername(), self.getDiscriminator());
|
||||
});
|
||||
registerDiscordCommands();
|
||||
registerReactionEvents();
|
||||
}
|
||||
|
||||
public static Mono<Void> sendPrivateMessageToUser(String snowflake, String message) {
|
||||
|
Loading…
Reference in New Issue
Block a user