I’m calling it automator, it fulfills its destiny by automatically answering all domain removal topics that it receives from start. It will also include keywords that can be searched to find domain-removal topics tagged by automator, it’s almost done
The code below is what used to do everything.
const fs = require("fs");
const crypto = require("crypto");
const nodemailer = require("nodemailer");
const transport = nodemailer.createTransport({
host: "smtp.zoho.eu",
port: 465,
secure: true,
auth: {
user: "redacted",
pass: "redacted"
}
});
const createMessage = from => `Hello ${from}!
Welcome (back?) to Glitch!
For domain removals please send an email to support@glitch.com so they can start processing your domain removal request.
I totally understand that this might be frustrating, but this is the fastest way to get your custom domain removed.
I hope your problem get solved quickly!
Thanks,
Automator.
> **Note**: This is an automated message.
-- ignore this --
keyword-tag-domain-removal`;
const sendMessage = (user, id, from) => console.log("sending", user, id, from) || transport.sendMail({
from: "'Spam', spam3@ihacks.dev",
to: user,
inReplyTo: id,
text: createMessage(from)
});
const containsDomainRemoval = t => {
t = t.trim().toLowerCase();
return t.includes("domain");
};
exports.register = function ()
{
this.register_hook("mail", "mail");
this.register_hook("rcpt", "mail");
this.register_hook("rcpt_ok", "mail");
this.register_hook("data", "mail");
this.register_hook("data_post", "mail");
this.loginfo("Hello world")
}
exports.mail = function (next, con)
{
if (con.hook === "mail")
{
con.transaction.parse_body = true;
}
if (con.hook === "data_post")
{
const user = con.transaction.mail_from.user + "@" + con.transaction.mail_from.host;
console.log(con.transaction.body.children[0].bodytext)
let msg = con.transaction.body.children[0].bodytext.match(/(.|\n)*(?=---)/g);
if (!msg) return next(OK);
msg = msg[0];
if (!msg) return next(OK);
msg = msg.trim();
if (msg.length > 2000) return next(OK);
let id = con.transaction.header.headers["message-id"];
let sub = con.transaction.header.headers["subject"];
if (!id) return next(OK);
if (!sub) return next(OK);
if (!id[0]) return next(OK);
if (!sub[0]) return next(OK);
id = id[0].substring(1, id[0].length - 2);
sub = sub[0].trim();
let inReplyTo = con.transaction.header.headers["in-reply-to"];
inReplyTo = inReplyTo[0].substring(1, inReplyTo[0].length - 2);
let from = con.transaction.header.headers["from"];
if (!from) return next(OK);
from = from[0];
if (from.includes(" via Glitch Support <glitch@discoursemail.com>\n")) from = from.substring(0, from.length - 48);
console.log(user, inReplyTo, id);
console.log(from);
console.log(sub);
console.log(msg);
if (containsDomainRemoval(sub) || containsDomainRemoval(msg))
sendMessage(user, id, from);
}
next(OK);
}