Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최재은
/
밀당강의봇
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김예미
2019-06-03 00:27:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
466f060fa56048baa6dda1186538a6732474fc8d
466f060f
1 parent
4e4b9f88
Edit Template 4 - payload.substr
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
37 deletions
controller.js
template.js
controller.js
View file @
466f060
let
request
=
require
(
'request'
),
template
=
require
(
'./template'
);
// Views - handle Message, handle Postback
// Handles message events
exports
.
handleMessage
=
(
sender_psid
,
received_message
)
=>
{
let
payload
=
recieved_message
.
payload
;
if
(
payload
===
'CHOICE_BY_PROF'
){
handlePostback_choiceByProf
(
sender_psid
,
received_message
);
}
else
if
(
payload
===
'CHOICE_BY_LECT'
){
handlePostback_choiceByLect
(
sender_psid
,
recieved_message
);
}
else
if
(
payload
===
'HELP'
){
handlePostback_help
(
sender_psid
,
recieved_message
);
}
}
exports
.
handlePostback
=
(
sender_psid
,
received_postback
)
=>
{
...
...
@@ -26,14 +15,11 @@ exports.handlePostback = (sender_psid, received_postback) => {
if
(
payload
===
'Greeting'
){
response
=
template
.
greetingTemplate
();
callSendAPI
(
sender_psid
,
response
);
}
let
first_choice
=
payload
.
first_choice
;
if
(
first_choice
===
'CHOICE_BY_PROF'
){
}
else
if
(
payload
.
substr
(
0
,
14
)
===
'CHOICE_BY_PROF'
){
handlePostback_choiceByProf
(
sender_psid
,
received_postback
);
}
else
if
(
first_choice
===
'CHOICE_BY_LECT'
){
}
else
if
(
payload
.
substr
(
0
,
14
)
===
'CHOICE_BY_LECT'
){
handlePostback_choiceByLect
(
sender_psid
,
recieved_postback
);
}
else
if
(
first_choice
===
'
HELP'
){
}
else
if
(
payload
.
substr
(
0
,
14
)
===
'CHOICE_BY_
HELP'
){
handlePostback_help
(
sender_psid
,
recieved_postback
);
}
}
...
...
@@ -41,7 +27,7 @@ exports.handlePostback = (sender_psid, received_postback) => {
const
handlePostback_choiceByProf
=
(
sender_psid
,
received
)
=>
{
let
response
;
let
stat
=
received
.
payload
.
s
tat
;
let
stat
=
received
.
payload
.
s
ubstr
(
14
)
;
if
(
stat
===
'stat_0'
){
response
=
template
.
getProfNameTemplate
(
received
);
...
...
@@ -56,7 +42,7 @@ const handlePostback_choiceByProf = (sender_psid, received) => {
const
handlePostback_choiceByLect
=
(
sender_psid
,
recieved
)
=>
{
let
response
;
let
stat
=
recieved
.
stat
;
let
stat
=
recieved
.
payload
.
substr
(
14
)
;
if
(
stat
===
'stat_0'
){
response
=
template
.
getLectNameTemplate
(
received
);
...
...
@@ -75,7 +61,7 @@ const handlePostback_choiceByLect = (sender_psid, recieved) => {
const
handlePostback_help
=
(
sender_psid
,
received
)
=>
{
let
response
;
let
stat
=
received
.
stat
;
let
stat
=
received
.
payload
.
substr
(
14
)
;
if
(
stat
===
'stat_0'
){
response
=
template
.
howToTemplate
(
received
);
...
...
template.js
View file @
466f060
...
...
@@ -13,26 +13,17 @@ exports.greetingTemplate = () => {
{
"type"
:
"postback"
,
"title"
:
greetingTitle
[
0
],
"payload"
:{
first_choice
:
"CHOICE_BY_PROF"
,
stat
:
"stat_0"
}
"payload"
:
"CHOICE_BY_PROFstat_0"
},
{
"type"
:
"postback"
,
"title"
:
greetingTitle
[
1
],
"payload"
:{
first_choice
:
"CHOICE_BY_LECT"
,
stat
:
"stat_0"
}
"payload"
:
"CHOICE_BY_LECTstat_0"
},
{
"type"
:
"postback"
,
"title"
:
greetingTitle
[
2
],
"payload"
:{
first_choice
:
"HELP"
,
stat
:
"stat_0"
}
"payload"
:
"CHOICE_BY_HELPstat_0"
}
]
}
...
...
@@ -52,11 +43,12 @@ exports.getProfNameTemplate = (received) => {
{
"type"
:
"postback"
,
"title"
:
"처음으로"
,
"payload"
:{
first_choice
:
'Greeting'
,
stat
:
'stat_0'
,
rate
:{}
}
"payload"
:
'Greeting'
},
{
"type"
:
"postback"
,
"title"
:
"stat_1로"
,
"payload"
:
"CHOICE_BY_PROFstat_1"
}
]
}
...
...
Please
register
or
login
to post a comment