(spoilers: the cool friend is me)
key insight:
for a given url you can just make the url
http://web.archive.org/web/<TS>/<URL>
where TS is a timestamp YYYYMMDDTTTTTT
and URL is the URL you want to access
http://discordapp.com/developers/applications/me
New Application > name it > Save Changes
Bot > Add Bot > get auth token
Bot > Bot Permissions > figure out the permissions integer for the perms you'll need
menu: General Information > copy Client ID
https://discordapp.com/oauth2/authorize?&client_id=CLIENTID&scope=bot&permissions=N
invite it to your server!
make a basic node project with an auth.json file containing "token": your seekrit bot token
install discord.io: https://github.com/izy521/discord.io
var Discord = require('discord.io');
var log = require('winston');
var auth = require('./auth.json');
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function(e) {
log.info('Connected');
log.info('Logged in as: ');
log.info(bot.username + '- (' + bot.id + ')');
});
bot.on('message', function(u, uid, cid, m, e) {
if (m.substring(0, 7) == "Hi Bot,") {
var args = m.substring(8).split(' ');
var cmd = args[0];
switch(cmd) {
case 'ping':
bot.sendMessage({to: cid, message: "pong!"});
break;
}
}
}
if ((m.includes('http://') || m.includes('https://')) && !(hiddenFromTheEye(m, e))) {
statement(m, cid);
}
function statement(m, cid) {
var now = new Date();
var matches = m.match(/(https?:[^\s]+)/g);
var baselink = "<http://web.archive.org/web/" +
now.toISOString().replace(/[-T:\.Z]/gi,'').substr(0,8) + "000000/"
matches.forEach(function(url) {
fetch("http://web.archive.org/save/" + url)
.catch(err => log.warn('error saving: ' + err))
.then(checkStatus)
.then(archivist.sendMessage({to: cid, message: baselink + url + ">"}));
});
}
function hiddenFromTheEye(m, e) {
if (m.includes('web.archive.org')) {
return true;
}
if (e["d"]["member"]["roles"].includes("621559754699046915")) {
return true;
}
}