UNPKG

cross-tools

Version:

Cross-platform fundamental tools for developers

1 lines 1.04 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),command_1=require("@oclif/command"),myPrompts_1=require("../util/myPrompts"),open_1=tslib_1.__importDefault(require("open")),awesome_phonenumber_1=tslib_1.__importDefault(require("awesome-phonenumber")),choices=[{title:"Send whatsapp message",value:"send-whatsapp-msg",description:"It allows you to send whwatsapp message without saving the contact nubmer."}];class Miscellaneous extends command_1.Command{async run(){const{operation:e}=await myPrompts_1.askFuzzy(choices,{});switch(e){case"send-whatsapp-msg":await this.sendWhatsMsg()}}async sendWhatsMsg(){for(;;){let{userInput:e}=await myPrompts_1.askTextInput({message:"Input destination phone number"});e=e.split(" ").join(""),e.startsWith("+")||(e="+"+e);const s=new awesome_phonenumber_1.default(e);let t=s.getNumber("e164");if(!s.isValid()){console.error("not a valid phone: "+t);continue}const a="https://api.whatsapp.com/send?phone="+t;open_1.default(a)}}}exports.default=Miscellaneous;