Compare commits

...

2 Commits

Author SHA1 Message Date
0cd23ff738 Merge branch 'master' of gitea.moe:lamp/lampdiscordbot 2022-01-10 14:05:01 -08:00
ba8d2f5cb9 fix detection url abuse 2022-01-10 14:04:57 -08:00

View File

@ -6,10 +6,11 @@ var DataStore = require("./datastore");
var ds = new DataStore("activity");
app.get("/detect/:userid", (req, res) => {
app.get("/detect/:code", (req, res) => {
res.sendFile(process.cwd() + "/track-image.png");
if (req.headers["user-agent"].includes("Discordbot")) return;
onActivity(req.params.userid);
onActivity(ds.get(req.params.code));
ds.del(req.params.code);
});
@ -82,11 +83,14 @@ async function deactivateMember(member) {
}
var magic_channel_message_id = ds.get(member.id + "magicchannelmessage");
var unique_code = Math.random().toString();
ds.put(unique_code, member.id);
var content = `${config.base_uri}/detect/${unique_code}`;
if (!magic_channel_message_id) {
var magic_channel_message = await magic_channel.send(`${config.base_uri}/detect/${member.id}?${Math.random()}`);
var magic_channel_message = await magic_channel.send({content});
ds.put(member.id + "magicchannelmessage", magic_channel_message.id)
} else {
await magic_channel.messages.edit(magic_channel_message_id, {content: `${config.base_uri}/detect/${member.id}?${Math.random()}`});
await magic_channel.messages.edit(magic_channel_message_id, {content});
}
}