use of com.gamebuster19901.excite.bot.mail.MailResponse in project ExciteBot by TheGameCommunity.
the class Mailbox method analyzeMail.
private static LinkedHashSet<MailResponse> analyzeMail(Wii responder, MimeMessage prompt) throws MessagingException {
LinkedHashSet<MailResponse> responses = new LinkedHashSet<MailResponse>();
Session session = Session.getInstance(new Properties());
Address[] from = prompt.getFrom();
LOGGER.log(Level.FINEST, "Analyzing mail from: " + (from != null ? from[0] : from));
if (from == null) {
responses.add(new NoResponse(prompt));
return responses;
}
ElectronicAddress senderEmail = new EmailAddress(prompt.getFrom()[0]);
Wii sender = Wii.getWii(senderEmail);
if (sender instanceof InvalidWii) {
LOGGER.log(Level.FINEST, "Ignoring non-wii mail");
responses.add(new NoResponse(prompt));
return responses;
} else {
boolean wasKnown;
if (!(wasKnown = sender.isKnown())) {
try {
Insertion.insertInto(WIIS).setColumns(WII_ID).to(sender.getWiiCode().toString()).prepare(ConsoleContext.INSTANCE).execute();
} catch (SQLException e) {
throw new MessagingException("Database error", e);
}
}
String[] appheaders = prompt.getHeader(APP_ID_HEADER);
String app = "";
if (appheaders.length > 0) {
app = appheaders[0];
}
Rewardable attachment = InvalidChallenge.INSTANCE;
if (app.equals(EXCITEBOTS)) {
attachment = analyzeIngameMail(prompt, sender);
}
// if(sender.getOwner() instanceof UnknownDiscordUser) { //if wii is not registered
// if(app.equals(FRIEND_REQUEST) /*&& !wasKnown*/) {
MailResponse friendResponse = new AddFriendResponse(responder, sender, prompt);
LOGGER.finest("Sending friend request to " + sender.getEmail());
MailResponse codeResponse = new DiscordCodeResponse(responder, sender, prompt);
LOGGER.finest("Sending verification discord code to " + sender.getEmail());
responses.add(friendResponse);
responses.add(codeResponse);
if (attachment.getReward() > 0) {
// responses.add(new RefundResponse(responder, prompt, attachment));
}
// }
/*else { //excitebot is not currently accepting mail from anything other than Excitebots
LOGGER.log(Level.FINEST, "Excitebot is not currently accepting mail from anything other than Excitebots");
responses.add(new NoResponse(prompt));
}*/
}
return responses;
}
use of com.gamebuster19901.excite.bot.mail.MailResponse in project ExciteBot by TheGameCommunity.
the class Wii method register.
public void register(MessageContext owner) throws SQLException, MessagingException {
Table.updateWhere(owner, WIIS, DISCORD_ID, owner.getSenderId(), new Comparison(WII_ID, EQUALS, wiiCode.code));
Table.updateWhere(owner, WIIS, REGISTRATION_CODE, null, new Comparison(WII_ID, EQUALS, wiiCode.code));
WiiRegistrationAudit.addWiiRegistrationAudit(owner, this, false);
EmbedBuilder embed = new EmbedBuilder();
embed.setColor(Color.GREEN);
embed.setTitle("Registration Successful");
embed.setDescription("You have succesfully registered the following wii:\n\n" + this.getIdentifierName());
ElectronicAddress exciteEmail = Mailbox.ADDRESS;
owner.sendMessage(embed.build());
LinkedHashSet<MailResponse> wiiMail = Mailbox.packResponses(new TextualMailResponse((Wii) exciteEmail, this, null).setText("This wii has been registered with\n Excitebot.\n" + "registrant: " + owner.getDiscordAuthor().getIdentifierName() + "\n\n" + "If this is not you, contact a TCG\nadmin immediately.\n\n" + "-The Game Community"));
Mailbox.sendResponses(wiiMail);
}
Aggregations