Skip to content

Commit

Permalink
emergencyAction: emergency calling feature added
Browse files Browse the repository at this point in the history
  • Loading branch information
stories2 committed Feb 16, 2019
1 parent bcc8100 commit f061f1b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions functions/Action/emergencyAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
exports.selectEmergencyType = function (request, response, callbackFunc) {
const action = JSON.parse(JSON.stringify(request.action))
const responseManager = request.responseManager
global.log.debug("emergencyAction", "selectEmergencyType", "user data: " + JSON.stringify(request.user) + " action data: " + JSON.stringify(request.action))

var buttonsList = action["response"][global.define.DEFAULT_RESPONSE_TYPE_ZERO]["basicCard"]["buttons"]
action["response"][global.define.DEFAULT_RESPONSE_TYPE_ZERO]["basicCard"]["buttons"] = []

for(var key in buttonsList) {
action["response"][global.define.DEFAULT_RESPONSE_TYPE_ZERO]["basicCard"]["buttons"].push(buttonsList[key])
}

responseManager.pushTemplate(action["response"][global.define.DEFAULT_RESPONSE_TYPE_ZERO])
for(var index in action["quickReplies"]) {
responseManager.pushQuickReply(action["quickReplies"][index])
}
callbackFunc()
}
3 changes: 3 additions & 0 deletions functions/Core/actionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ exports.executeOrder = function (request, response, actionIndex, callbackFunc) {
const systemAction = require('../Action/systemAction')
const weatherAction = require('../Action/weatherAction')
const publicTransportAction = require('../Action/publicTransportAction')
const emergencyAction = require('../Action/emergencyAction')

const actionTable = {
"1": basicAction.hello,
Expand All @@ -190,6 +191,8 @@ exports.executeOrder = function (request, response, actionIndex, callbackFunc) {

"2000": publicTransportAction.selectPublicTransport,

"3000": emergencyAction.selectEmergencyType,

"9000": systemAction.showSystemInfo,

"10000": thuSuAction.todayPantiesColor
Expand Down

0 comments on commit f061f1b

Please sign in to comment.