Search in sources :

Example 1 with Pardon

use of com.gamebuster19901.excite.bot.audit.ban.Pardon in project ExciteBot by TheGameCommunity.

the class PardonCommand method pardon.

@SuppressWarnings("rawtypes")
private static final int pardon(MessageContext context, long baneeOrBanID) {
    if (context.isAdmin()) {
        Ban ban = Ban.getBanByAuditId(context, baneeOrBanID);
        if (ban != null) {
            return pardon(context, ban);
        }
        Banee banee = Banee.getBanee(context, baneeOrBanID);
        return pardon(context, banee);
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 1;
}
Also used : Banee(com.gamebuster19901.excite.bot.audit.ban.Banee) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Example 2 with Pardon

use of com.gamebuster19901.excite.bot.audit.ban.Pardon in project ExciteBot by TheGameCommunity.

the class Ban method addBan.

@SuppressWarnings({ "rawtypes", "deprecation" })
public static Ban addBan(MessageContext context, Banee banee, String reason, Duration banDuration, Instant banExpire, long pardon) {
    Audit parent = Audit.addAudit(context, AuditType.BAN, reason);
    PreparedStatement st;
    context.sendMessage(banee.getClass().getCanonicalName());
    try {
        st = Insertion.insertInto(AUDIT_BANS).setColumns(AUDIT_ID, BAN_DURATION, BAN_EXPIRE, BANNED_ID, BANNED_USERNAME).to(parent.getID(), banDuration, banExpire, banee.getID(), banee.getName()).prepare(context, true);
        st.execute();
        Ban ret = getBanByAuditId(context, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : Audit(com.gamebuster19901.excite.bot.audit.Audit) SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 3 with Pardon

use of com.gamebuster19901.excite.bot.audit.ban.Pardon in project ExciteBot by TheGameCommunity.

the class Pardon method addPardonByAuditID.

@Nullable
@SuppressWarnings("rawtypes")
public static Pardon addPardonByAuditID(MessageContext context, long id) {
    try {
        Audit pardoned = Audit.getAuditById(context, id);
        if (pardoned == null) {
            context.sendMessage("Could not find audit #" + id);
            return null;
        }
        AuditType type = pardoned.getType();
        if (type == BAN) {
            Ban ban = (Ban) pardoned;
            if (ban.isPardoned()) {
                context.sendMessage(type + " #" + id + " is already pardoned.");
                return null;
            }
            Audit parent = Audit.addAudit(context, PARDON, context.getAuthor().getIdentifierName() + " pardoned " + ban.getBannedUsername());
            PreparedStatement st;
            st = Insertion.insertInto(AUDIT_PARDONS).setColumns(AUDIT_ID, PARDONED_AUDIT_ID).to(parent.getID(), pardoned.getID()).prepare(context, true);
            st.execute();
            Pardon ret = getPardonByAuditID(context, parent.getID());
            ret.parentData = parent;
            return ret;
        } else {
            context.sendMessage("Audit #" + id + " is a " + type + ", not a " + BAN);
            return null;
        }
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : Audit(com.gamebuster19901.excite.bot.audit.Audit) AuditType(com.gamebuster19901.excite.bot.audit.AuditType) SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement) Nullable(javax.annotation.Nullable)

Example 4 with Pardon

use of com.gamebuster19901.excite.bot.audit.ban.Pardon in project ExciteBot by TheGameCommunity.

the class PardonCommand method pardon.

@SuppressWarnings("rawtypes")
private static final int pardon(MessageContext context, Banee banee) {
    if (context.isAdmin()) {
        Ban ban = banee.getLongestActiveBan(context);
        if (ban == null) {
            context.sendMessage(banee.getIdentifierName() + " is not banned.");
            return 1;
        }
        Pardon pardon = Pardon.addPardonByAuditID(context, ban.getID());
        if (pardon != null) {
            context.sendMessage("pardoned the longest ban (#" + ban.getID() + ") of " + banee.getIdentifierName());
        }
    } else {
        context.sendMessage("You do not have permission to execute this command");
    }
    return 1;
}
Also used : Pardon(com.gamebuster19901.excite.bot.audit.ban.Pardon) Ban(com.gamebuster19901.excite.bot.audit.ban.Ban)

Aggregations

Audit (com.gamebuster19901.excite.bot.audit.Audit)2 Ban (com.gamebuster19901.excite.bot.audit.ban.Ban)2 PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)2 IOError (java.io.IOError)2 SQLException (java.sql.SQLException)2 AuditType (com.gamebuster19901.excite.bot.audit.AuditType)1 Banee (com.gamebuster19901.excite.bot.audit.ban.Banee)1 Pardon (com.gamebuster19901.excite.bot.audit.ban.Pardon)1 Nullable (javax.annotation.Nullable)1