Skip to content

Commit

Permalink
fix(core.gbapp): SEND SMS TO keyword added.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Nov 26, 2020
1 parent 10b878c commit 719f063
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/core.gbapp/services/GBAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class SysClass {
await this.min.conversationalService.sendMarkdownToMobile(this.min, null, mobile, message);
}

public async sendSmsTo(mobile, message) {
await this.min.conversationalService.sendSms(this.min, mobile, message);
}

public async set(file: string, address: string, value: any): Promise<any> {
GBLog.info(`BASIC: Defining '${address}' in '${file}' to '${value}' (SET). `);
try {
Expand Down
5 changes: 3 additions & 2 deletions packages/core.gbapp/services/GBConversationalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ export class GBConversationalService {
});
// tslint:disable-next-line:no-unsafe-any
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, (err, data) => {
if (err) {
reject(err);
if (data.messages[0]['error-text']) {
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${data.messages[0]['error-text']}`);
reject(data.messages[0]['error-text']);
} else {
resolve(data);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/core.gbapp/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ export class GBVMService extends GBService {
return `talk (step, ${$3})\n`;
});

code = code.replace(/(send sms to)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
return `sys().sendSmsTo (${$3})\n`;
});

code = code.replace(/(send file to)(\s*)(.*)/gi, ($0, $1, $2, $3) => {
return `sendFileTo (step, ${$3})\n`;
});
Expand Down

0 comments on commit 719f063

Please sign in to comment.