From 578b8dc372894b5a96c93c35327e0b6d229f8492 Mon Sep 17 00:00:00 2001 From: Wade Wegner Date: Sun, 7 Aug 2016 13:27:50 -0500 Subject: [PATCH] Added phone to parse phone --- package.json | 1 + src/web/apis/profile.js | 5 +++-- src/web/apis/trigger.js | 2 +- src/web/routes.js | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6a1a887..264bdf3 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "express": "4.13.4", "moment": "2.13.0", "pg": "4.5.3", + "phone": "^1.0.8", "request": "2.72.0", "requestify": "0.1.17", "sleep": "^3.0.1", diff --git a/src/web/apis/profile.js b/src/web/apis/profile.js index 9e39e0c..f0d7ff6 100644 --- a/src/web/apis/profile.js +++ b/src/web/apis/profile.js @@ -1,4 +1,5 @@ var postgres = require('../db/postgres.js'); +var phone = require('phone'); module.exports = { get: function (request, response) { @@ -11,7 +12,7 @@ module.exports = { console.log(' weight: ' + weight); console.log(' isMale: ' + isMale); - console.log(' mobilePhone: ' + mobilePhone); + console.log(' mobilePhone: ' + phone(mobilePhone)[0]); var updated = false; response.render('pages/profile', {weight, isMale, mobilePhone, updated}); @@ -26,7 +27,7 @@ module.exports = { isMale = false; if (gender == "Male") { isMale = true; } - postgres.update_profile(response.locals.userName, weight, isMale, mobilePhone, function(result) { + postgres.update_profile(response.locals.userName, weight, isMale, phone(mobilePhone)[0], function(result) { var updated = true; diff --git a/src/web/apis/trigger.js b/src/web/apis/trigger.js index bff8f4c..d4dfcac 100644 --- a/src/web/apis/trigger.js +++ b/src/web/apis/trigger.js @@ -158,7 +158,7 @@ module.exports = { var authToken = process.env.TWILIO_TOKEN; var fromPhoneNumber = process.env.TWILIO_PHONENUMBER; var sendTxt = process.env.SEND_TXT; - var message = 'You just checked in! You started drinking ' + totalTimeInHours.toFixed(2) + ' hours ago and drank ' + count + ' beers. Your bac is ' + bacAfterElapsedTime.toFixed(3) + '. Txt "COOL" for commands.'; + var message = 'You just checked in! You started drinking ' + totalTimeInHours.toFixed(2) + ' hours ago and drank ' + count + ' beers. Your bac is ' + bacAfterElapsedTime.toFixed(3) + '. Send "COOL" for commands.'; console.log(userName + ': ' + message); diff --git a/src/web/routes.js b/src/web/routes.js index fbc547f..471efe4 100644 --- a/src/web/routes.js +++ b/src/web/routes.js @@ -175,11 +175,11 @@ module.exports = function(app) { if (body.toLowerCase().indexOf('cool') !== -1) { - message = 'To get your current BAC, txt "bac". To add a drink w/o Untapped txt "new {oz} {abv}".'; + message = 'To get your current BAC, send "bac". To add a drink w/o Untapped send "new {oz} {abv}".'; } else if (body.toLowerCase().indexOf('bac') !== -1) { - message = 'Prompt bac calc in progress'; + message = 'Prompt bac calc in progress.'; } else if (body.toLowerCase().indexOf('new') !== -1) { - message = 'new addition in progress'; + message = 'Ability to add new beers in progress.'; } else { message = 'We did not understand. Txt "COOL" for commands.'; }