mirror of
https://github.com/narkoz/hacker-scripts
synced 2025-08-22 18:37:10 +00:00
code cleanup
cleaned up code in 'KumarAsshole.java'. fixed confusing indentation and newlines for better readability.
This commit is contained in:
parent
9cb4a2e49d
commit
91f0a00c55
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -19,15 +18,13 @@ public class KumarAsshole {
|
|||||||
public void read() {
|
public void read() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
|
||||||
|
//modify below properties to your details
|
||||||
//modify below properties to your details
|
String host = "smtp.gmail.com";
|
||||||
String host = "smtp.gmail.com";
|
String username = "yourmailaddress@example.com goes here";
|
||||||
String username = "yourmailaddress@example.com goes here";
|
String password = "your password goes here ";
|
||||||
String password = "your password goes here ";
|
String Kumar_mail = "the mail address to be replied to !";
|
||||||
String Kumar_mail = "the mail address to be replied to !";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Session session = Session.getDefaultInstance(props, null);
|
Session session = Session.getDefaultInstance(props, null);
|
||||||
|
|
||||||
Store store = session.getStore("imaps");
|
Store store = session.getStore("imaps");
|
||||||
@ -39,21 +36,16 @@ public class KumarAsshole {
|
|||||||
Message messages[] = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
|
Message messages[] = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
|
||||||
|
|
||||||
for (int i = 0; i < messages.length; i++) {
|
for (int i = 0; i < messages.length; i++) {
|
||||||
|
|
||||||
if (messages[i].getFrom()[0].toString().contains(Kumar_mail)) {
|
if (messages[i].getFrom()[0].toString().contains(Kumar_mail)) {
|
||||||
|
|
||||||
String bodytext = null;
|
String bodytext = null;
|
||||||
Object content = messages[i].getContent();
|
Object content = messages[i].getContent();
|
||||||
if (content instanceof String) {
|
if (content instanceof String) {
|
||||||
bodytext = (String) content;
|
bodytext = (String) content;
|
||||||
|
|
||||||
} else if (content instanceof Multipart) {
|
} else if (content instanceof Multipart) {
|
||||||
|
|
||||||
Multipart mp = (Multipart) content;
|
Multipart mp = (Multipart) content;
|
||||||
|
|
||||||
BodyPart bp = mp.getBodyPart(mp.getCount() - 1);
|
BodyPart bp = mp.getBodyPart(mp.getCount() - 1);
|
||||||
bodytext = (String) bp.getContent();
|
bodytext = (String) bp.getContent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile("sorry|help|wrong", Pattern.CASE_INSENSITIVE);
|
Pattern pattern = Pattern.compile("sorry|help|wrong", Pattern.CASE_INSENSITIVE);
|
||||||
@ -61,7 +53,6 @@ public class KumarAsshole {
|
|||||||
// check all occurance
|
// check all occurance
|
||||||
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
|
|
||||||
Properties props1 = new Properties();
|
Properties props1 = new Properties();
|
||||||
Address[] tomail;
|
Address[] tomail;
|
||||||
|
|
||||||
@ -73,22 +64,17 @@ public class KumarAsshole {
|
|||||||
msg.setSubject("Database fixes");
|
msg.setSubject("Database fixes");
|
||||||
msg.setText("No problem. I've fixed it. \n\n Please be careful next time.");
|
msg.setText("No problem. I've fixed it. \n\n Please be careful next time.");
|
||||||
Transport t = null;
|
Transport t = null;
|
||||||
t = session.getTransport("smtps");
|
t = session.getTransport("smtps");
|
||||||
t.connect(host, username, password);
|
t.connect(host, username, password);
|
||||||
t.sendMessage(msg, msg.getAllRecipients());
|
t.sendMessage(msg, msg.getAllRecipients());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inbox.close(true);
|
inbox.close(true);
|
||||||
store.close();
|
store.close();
|
||||||
|
|
||||||
}catch(Exception e)
|
} catch(Exception e) {
|
||||||
{
|
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user