Bumped version to 0-3.2-SNAPSHOT and fixed broken auto reimportation because it fired as soon as the bot started
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
c4e61e17d2
commit
ab5039588f
@ -11,7 +11,7 @@ public class App {
|
|||||||
public static final String PREFIX = "+";
|
public static final String PREFIX = "+";
|
||||||
public static final String NAME = "PrésencEirb";
|
public static final String NAME = "PrésencEirb";
|
||||||
public static final String DESCRIPTION = "Tu as pensé à pointer ?";
|
public static final String DESCRIPTION = "Tu as pensé à pointer ?";
|
||||||
public static final String VERSION = "0.3-SNAPSHOT";
|
public static final String VERSION = "0.3.2-SNAPSHOT";
|
||||||
private static final Logger logger = LoggerFactory.getLogger(App.class.getCanonicalName());
|
private static final Logger logger = LoggerFactory.getLogger(App.class.getCanonicalName());
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -4,7 +4,9 @@ import discord4j.core.event.domain.message.MessageCreateEvent;
|
|||||||
import discord4j.rest.util.Color;
|
import discord4j.rest.util.Color;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import xyz.vallat.louis.App;
|
import xyz.vallat.louis.App;
|
||||||
|
import xyz.vallat.louis.managers.database.StudentManager;
|
||||||
import xyz.vallat.louis.managers.discord.DiscordManager;
|
import xyz.vallat.louis.managers.discord.DiscordManager;
|
||||||
|
import xyz.vallat.louis.timer.TimerManager;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
@ -21,8 +23,12 @@ public class Version extends Command {
|
|||||||
.setTitle(App.NAME)
|
.setTitle(App.NAME)
|
||||||
.setDescription(App.DESCRIPTION)
|
.setDescription(App.DESCRIPTION)
|
||||||
.setUrl("https://gitlab.com/lovallat/presenceirb")
|
.setUrl("https://gitlab.com/lovallat/presenceirb")
|
||||||
.setTimestamp(Instant.now())
|
.addField("Au service de", StudentManager.getStudentsFromDatabase().size() + " étudiants", false)
|
||||||
.addField("Version", App.VERSION, false);
|
.addField("Évènements programmés", String.valueOf(TimerManager.getTotalProgrammedEvents()), false);
|
||||||
|
if (event.getMessage().getAuthor().isPresent())
|
||||||
|
embed.addField("Vos évènements programmés",
|
||||||
|
String.valueOf(TimerManager.getStudentsProgrammedEvents(event.getMessage().getAuthor().get().getId().asString())), false);
|
||||||
|
embed.setTimestamp(Instant.now()).addField("Version", App.VERSION, false);
|
||||||
String imageURL = DiscordManager.getClientImage().block();
|
String imageURL = DiscordManager.getClientImage().block();
|
||||||
if (imageURL != null) embed.setThumbnail(imageURL);
|
if (imageURL != null) embed.setThumbnail(imageURL);
|
||||||
})).then().onErrorResume(t -> fatalError(event, t));
|
})).then().onErrorResume(t -> fatalError(event, t));
|
||||||
|
@ -34,6 +34,7 @@ public final class TimerManager {
|
|||||||
midday.set(Calendar.HOUR, 1);
|
midday.set(Calendar.HOUR, 1);
|
||||||
midday.set(Calendar.MINUTE, 30);
|
midday.set(Calendar.MINUTE, 30);
|
||||||
midday.set(Calendar.SECOND, 0);
|
midday.set(Calendar.SECOND, 0);
|
||||||
|
if (midday.getTime().before(Calendar.getInstance().getTime())) midday.add(Calendar.HOUR, 12);
|
||||||
|
|
||||||
Timer reimportCron = new Timer();
|
Timer reimportCron = new Timer();
|
||||||
reimportCron.schedule(new AutoReimport(), midday.getTime(),
|
reimportCron.schedule(new AutoReimport(), midday.getTime(),
|
||||||
@ -48,6 +49,7 @@ public final class TimerManager {
|
|||||||
logger.debug("Stopping all {} timers for student '{}'.", entry.getValue().size(), entry.getKey());
|
logger.debug("Stopping all {} timers for student '{}'.", entry.getValue().size(), entry.getKey());
|
||||||
for (Timer t : entry.getValue()) t.cancel();
|
for (Timer t : entry.getValue()) t.cancel();
|
||||||
}
|
}
|
||||||
|
studentsTimers.clear();
|
||||||
logger.debug("Done stopping all timers.");
|
logger.debug("Done stopping all timers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,4 +82,14 @@ public final class TimerManager {
|
|||||||
}
|
}
|
||||||
logger.debug("All {} timers have been started.", timerStarted);
|
logger.debug("All {} timers have been started.", timerStarted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getTotalProgrammedEvents() {
|
||||||
|
int total = 0;
|
||||||
|
for (Map.Entry<String, List<Timer>> e : studentsTimers.entrySet()) total += e.getValue().size();
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getStudentsProgrammedEvents(String snowflake) {
|
||||||
|
return studentsTimers.getOrDefault(snowflake, new ArrayList<>()).size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ public class AutoReimport extends TimerTask {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("Reimporting all events.");
|
logger.info("Reimporting all events.");
|
||||||
logger.info("Done reimporting {} events.", EventManager.reimportAllEvents());
|
int eventsImported = EventManager.reimportAllEvents();
|
||||||
|
logger.info("Done reimporting {} events.", eventsImported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user