1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
const user = process.argv[2];
const number = require('../app.json')['signal'][user];
const fs = require('fs');
if (typeof number !== "string") throw new Error("Unable to find info");
const child_process = require("child_process");
(async () => {
console.log("Ready");
let system = require('../data/' + (user === "raindrops" ? "gdapd" : (user === "Moonglow" ? "hrbom" : "other")) + "/general.json");
let fronters = require('../data/' + (user === "raindrops" ? "gdapd" : (user === "Moonglow" ? "hrbom" : "other")) + "/fronters.json");
console.log(system.name);
console.log(fronters.members.length + " member(s) at front");
let name = system.name;
let avatar1 = system.avatar_url;
let avatar2 = null;
if (fronters.members.length === 1) {
name = fronters.members[0].display_name ?? fronters.members[0].name;
avatar1 = fronters.members[0].avatar_url ?? avatar1;
} else if (fronters.members.length >= 2) {
name = (fronters.members[0].display_name ?? fronters.members[0].name) + " and " + (fronters.members[1].display_name ?? fronters.members[1].name);
avatar1 = fronters.members[0].avatar_url ?? avatar1;
avatar2 = fronters.members[1].avatar_url ?? avatar2;
}
let pfp;
if (avatar2) {
let img1 = Buffer.from(await (await fetch(avatar1)).arrayBuffer());
let img2 = Buffer.from(await (await fetch(avatar2)).arrayBuffer());
fs.writeFileSync("/tmp/chm-" + user + "-1", img1);
fs.writeFileSync("/tmp/chm-" + user + "-2", img2);
child_process.execSync("convert /tmp/chm-" + user + "-1 -gravity center -resize 512x512 -crop 50%x100% /tmp/chm-" + user + "-1.webp");
child_process.execSync("convert /tmp/chm-" + user + "-2 -gravity center -resize 512x512 -crop 50%x100% /tmp/chm-" + user + "-2.webp");
child_process.execSync("montage -mode concatenate -tile x1 /tmp/chm-" + user + "-1.webp /tmp/chm-" + user + "-2.webp /tmp/chm-" + user + ".webp");
pfp = fs.readFileSync("/tmp/chm-" + user + ".webp");
fs.unlinkSync("/tmp/chm-" + user + "-1");
fs.unlinkSync("/tmp/chm-" + user + "-2");
fs.unlinkSync("/tmp/chm-" + user + "-1.webp");
fs.unlinkSync("/tmp/chm-" + user + "-2.webp");
fs.unlinkSync("/tmp/chm-" + user + ".webp");
} else {
pfp = Buffer.from(await (await fetch(avatar1)).arrayBuffer());
}
fs.writeFileSync("/tmp/chm-" + user + "-pfp-final", pfp);
child_process.execFileSync("signal-cli", [ "-a", number, "updateProfile", "--given-name", name, "--family-name", "", "--avatar", "/tmp/chm-" + user + "-pfp-final" ]);
child_process.execFileSync("signal-cli", [ "-a", number, "updateAccount", "--device-name", "Ponycule to Signal integration (v" + new Date().toISOString().split("T")[0].replaceAll("-", ".") + ")" ]);
child_process.execFileSync("signal-cli", [ "-a", number, "sendSyncRequest" ]);
fs.unlinkSync("/tmp/chm-" + user + "-pfp-final");
})();
|