UNPKG

@dderevjanik/termux-api

Version:

This library allows you to interact with your Android device from Node.js using termux-api

30 lines (29 loc) 907 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.smsSend = smsSend; const child_process_1 = require("child_process"); /** * Send a SMS message to the specified recipient number(s) */ async function smsSend(options) { const opts = { slot: 0, // number: "", ...options, }; if (opts.numbers.length === 0) { throw new Error("Error: No recipient number(s) provided"); } return new Promise((resolve, reject) => { const command = `termux-sms-send -n "${opts.numbers.join(",")}" -s ${opts.slot} "${opts.text}"`; (0, child_process_1.exec)(command, (error, stdout, stderr) => { if (error) { return reject(`Error: ${error.message}`); } if (stderr) { return reject(`Error: ${stderr}`); } resolve(); }); }); }