Search in sources :

Example 1 with Audit

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

the class BotDeleteMessageAudit method addBotDeleteMessageAudit.

public static BotDeleteMessageAudit addBotDeleteMessageAudit(MessageContext deleter, MessageContext deleted, String reason) {
    Audit parent = Audit.addAudit(deleter, deleted, AuditType.BOT_MSG_DELETE, getMessage(ConsoleContext.INSTANCE, deleted, reason));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.AUDIT_BOT_MSG_DEL).setColumns(AUDIT_ID, DISCORD_ID).to(parent.getID(), deleted.getSenderId()).prepare(deleter, true);
        st.execute();
        BotDeleteMessageAudit ret = getBotDeleteMessageAuditByID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 2 with Audit

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

the class LogOutAudit method addLogOutAudit.

public static LogOutAudit addLogOutAudit(MessageContext context, Player player) {
    Audit parent = Audit.addAudit(context, AuditType.LOG_OUT_AUDIT, getMessage(player));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.AUDIT_PROFILE_LOGOUTS).setColumns(AUDIT_ID).to(parent.getID()).prepare(context, true);
        st.execute();
        LogOutAudit ret = getLogOutAuditByAuditID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Example 3 with Audit

use of com.gamebuster19901.excite.bot.audit.Audit 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 4 with Audit

use of com.gamebuster19901.excite.bot.audit.Audit 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 5 with Audit

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

the class LogInAudit method addLoginAudit.

public static LogInAudit addLoginAudit(MessageContext context, Player player) {
    Audit parent = Audit.addAudit(context, AuditType.LOG_IN_AUDIT, getMessage(player));
    PreparedStatement st;
    try {
        st = Insertion.insertInto(Table.AUDIT_PROFILE_LOGINS).setColumns(AUDIT_ID).to(parent.getID()).prepare(context, true);
        st.execute();
        LogInAudit ret = getLoginAuditByAuditID(ConsoleContext.INSTANCE, parent.getID());
        ret.parentData = parent;
        return ret;
    } catch (SQLException e) {
        throw new IOError(e);
    }
}
Also used : SQLException(java.sql.SQLException) IOError(java.io.IOError) PreparedStatement(com.gamebuster19901.excite.bot.database.sql.PreparedStatement)

Aggregations

PreparedStatement (com.gamebuster19901.excite.bot.database.sql.PreparedStatement)14 IOError (java.io.IOError)14 SQLException (java.sql.SQLException)14 Audit (com.gamebuster19901.excite.bot.audit.Audit)2 MessageContext (com.gamebuster19901.excite.bot.command.MessageContext)2 Comparison (com.gamebuster19901.excite.bot.database.Comparison)2 Row (com.gamebuster19901.excite.bot.database.Row)2 ElectronicAddress (com.gamebuster19901.excite.bot.mail.ElectronicAddress)2 Nullable (javax.annotation.Nullable)2 AuditType (com.gamebuster19901.excite.bot.audit.AuditType)1 Result (com.gamebuster19901.excite.bot.database.Result)1 ResultSet (com.gamebuster19901.excite.bot.database.sql.ResultSet)1 AddFriendResponse (com.gamebuster19901.excite.bot.mail.AddFriendResponse)1 EmailAddress (com.gamebuster19901.excite.bot.mail.EmailAddress)1 RefundResponse (com.gamebuster19901.excite.bot.mail.RefundResponse)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InternetAddress (javax.mail.internet.InternetAddress)1