use of finders.RSSFinder in project KaellyBot by Kaysoro.
the class RSSCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Language lg = Translator.getLanguageFrom(message.getChannel());
// On check si la personne a bien les droits pour exécuter cette commande
if (isUserHasEnoughRights(message)) {
Matcher m = getMatcher(message);
m.find();
String value = m.group(1);
if (value.matches("\\s+true") || value.matches("\\s+0") || value.matches("\\s+on")) {
if (!RSSFinder.getRSSFinders().containsKey(message.getChannel().getStringID())) {
new RSSFinder(message.getGuild().getStringID(), message.getChannel().getStringID()).addToDatabase();
Message.sendText(message.getChannel(), Translator.getLabel(lg, "rss.request.1").replace("{game.url}", Translator.getLabel(lg, "game.url")));
} else
rssFound.throwException(message, this, lg);
} else if (value.matches("\\s+false") || value.matches("\\s+1") || value.matches("\\s+off"))
if (RSSFinder.getRSSFinders().containsKey(message.getChannel().getStringID())) {
RSSFinder.getRSSFinders().get(message.getChannel().getStringID()).removeToDatabase();
Message.sendText(message.getChannel(), Translator.getLabel(lg, "rss.request.2").replace("{game.url}", Translator.getLabel(lg, "game.url")));
} else
rssNotFound.throwException(message, this, lg);
else
new BadUseCommandDiscordException().throwException(message, this, lg);
} else
noEnoughRights.throwException(message, this, lg);
}
return false;
}
use of finders.RSSFinder in project KaellyBot by Kaysoro.
the class GuildLeaveListener method onReady.
@EventSubscriber
public void onReady(GuildLeaveEvent event) {
try {
Guild guild = Guild.getGuild(event.getGuild(), false);
if (guild != null) {
guild.removeToDatabase();
LOG.info("La guilde " + event.getGuild().getStringID() + " - " + event.getGuild().getName() + " a supprimé " + Constants.name);
for (RSSFinder finder : RSSFinder.getRSSFinders().values()) {
IChannel chan = event.getGuild().getChannelByID(Long.parseLong(finder.getChan()));
if (chan != null && chan.isDeleted()) {
finder.removeToDatabase();
LOG.info("RSS Chan \"" + chan.getName() + "\"");
}
}
for (TwitterFinder finder : TwitterFinder.getTwitterChannels().values()) {
IChannel chan = event.getGuild().getChannelByID(finder.getChannelId());
if (chan != null && chan.isDeleted()) {
finder.removeToDatabase();
LOG.info("Twitter Chan \"" + chan.getName() + "\"");
}
}
for (AlmanaxCalendar finder : AlmanaxCalendar.getAlmanaxCalendars().values()) {
IChannel chan = event.getGuild().getChannelByID(Long.parseLong(finder.getChan()));
if (chan != null && chan.isDeleted()) {
finder.removeToDatabase();
LOG.info("Almanax Chan \"" + chan.getName() + "\"");
}
}
}
Message.sendText(ClientConfig.DISCORD().getChannelByID(Constants.chanReportID), "[LOSE] **" + event.getGuild().getName() + "**, -" + event.getGuild().getUsers().size() + " utilisateurs");
} catch (Exception e) {
Reporter.report(e, event.getGuild());
LOG.error("onReady", e);
}
}
Aggregations