Search in sources :

Example 1 with RSSFinder

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;
}
Also used : Language(enums.Language) Matcher(java.util.regex.Matcher) RSSFinder(finders.RSSFinder)

Example 2 with RSSFinder

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);
    }
}
Also used : AlmanaxCalendar(finders.AlmanaxCalendar) IChannel(sx.blah.discord.handle.obj.IChannel) RSSFinder(finders.RSSFinder) TwitterFinder(finders.TwitterFinder) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Aggregations

RSSFinder (finders.RSSFinder)2 Language (enums.Language)1 AlmanaxCalendar (finders.AlmanaxCalendar)1 TwitterFinder (finders.TwitterFinder)1 Matcher (java.util.regex.Matcher)1 EventSubscriber (sx.blah.discord.api.events.EventSubscriber)1 IChannel (sx.blah.discord.handle.obj.IChannel)1