diff options
Diffstat (limited to 'wolfram.js')
-rw-r--r-- | wolfram.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/wolfram.js b/wolfram.js new file mode 100644 index 0000000..35c2398 --- /dev/null +++ b/wolfram.js @@ -0,0 +1,23 @@ +(async () => { + try { + const translatte = require('translatte'); + const axios = require('axios'); + const fs = require('fs'); + + let input = Buffer.from(process.argv[2], 'base64').toString(); + let w_in = (await translatte(input, {from: 'fr', to: 'en'})).text; + let key = fs.readFileSync("./wolframkey").toString(); + let response = (await axios.get(`https://api.wolframalpha.com/v1/result?appid=${key}&i=${encodeURI(w_in)}&units=metric&timeout=10`)).data + let w_out = (await translatte(response, {from: 'en', to: 'fr'})).text; + + console.log(w_out.replace(/([0-9]+)\.([0-9]+)/gm, "$1,$2")); + process.exit(); + } catch (e) { + if (e.message === "Request failed with status code 501") { + process.exit(5); + } else { + console.log("Désolé, je ne parviens pas à accéder à Internet en ce moment. Vérifiez que votre appareil dispose d'une connexion Internet stable et réessayez."); + process.exit(); + } + } +})()
\ No newline at end of file |