Windows support
This commit is contained in:
parent
d722b862ba
commit
93716017ad
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
config.json
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"webhook": {
|
||||
"id": "paste_id_here",
|
||||
"token": "paste_token_here"
|
||||
},
|
||||
"interval": 5000,
|
||||
"capture_console_only": true
|
||||
}
|
16
index.js
16
index.js
@ -5,15 +5,23 @@ var os = require("os");
|
||||
var Discord = require("discord.js");
|
||||
|
||||
var config = require("./config");
|
||||
var whoiam = exec("id -un").toString().trim();
|
||||
if (process.platform == "darwin" && config.capture_console_only) {
|
||||
var whoiam = exec("id -un").toString().trim();
|
||||
}
|
||||
|
||||
var webhook = new Discord.WebhookClient(config.webhook.id, config.webhook.token);
|
||||
|
||||
async function capture() {
|
||||
if (config.capture_console_only && exec("stat -f '%Su' /dev/console").toString().trim() != whoiam) throw "Not console";
|
||||
var filename = `${new Date().toISOString()} ${encodeURIComponent(crypto.randomBytes(16).toString('base64'))}.jpg`
|
||||
if (process.platform == "darwin" && config.capture_console_only && exec("stat -f '%Su' /dev/console").toString().trim() != whoiam) throw "Not console";
|
||||
var filename = `${new Date().toISOString().replace(/:/g, '-')}_${encodeURIComponent(crypto.randomBytes(16).toString('base64'))}.jpg`
|
||||
var filepath = os.tmpdir() + '/' + filename;
|
||||
exec(`screencapture -x -C -t jpg "${filepath}"`);
|
||||
if (process.platform == "darwin") {
|
||||
exec(`screencapture -x -C -t jpg "${filepath}"`);
|
||||
} else if (process.platform == "win32") {
|
||||
exec(`"${__dirname}/screenCapture.exe" "${filepath}"`, {windowsHide: true});
|
||||
} else {
|
||||
console.error("Platform not supported!"); process.exit(1);
|
||||
}
|
||||
var data = fs.readFileSync(filepath);
|
||||
try {
|
||||
await webhook.send({files:[{
|
||||
|
10
package.json
10
package.json
@ -1,13 +1,5 @@
|
||||
{
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ledlamp/Visual-Time-Machine.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"discord.js": "^11.4.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"os": ["darwin"]
|
||||
}
|
||||
}
|
||||
|
BIN
screenCapture.exe
Normal file
BIN
screenCapture.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user