박찬수

reply.js modified.

Showing 1 changed file with 3 additions and 28 deletions
......@@ -75,7 +75,7 @@ try {
console.log(error);
}
function Reply(eventObj){
function Reply(eventObj,replyMsg){
request.post(
{
url: TARGET_URL,
......@@ -91,7 +91,7 @@ function Reply(eventObj){
},
{
"type":"text",
"text":"May I help you?"
"text":replyMsg
}
]
}
......@@ -115,31 +115,6 @@ function GetPlayerInfo(playerID, season, eventObj){
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
Reply(eventObj);
Reply(eventObj,response.body);
});
}
\ No newline at end of file
function Emitter(){
this.events = {};
}
Emitter.prototype.on = function(type, listener){
this.events[type] = this.events[type] || [];
this.events[type].push(listener);
}
const emitter = new Emitter();
emitter.on('soccer', function(){
console.log('soccer logged.');
})
Emitter.prototype.emit = function(type){
if(this.events[type]){
this.events[type].forEach(function(listener){
listener();
});
}
}
emitter.emit('soccer');
\ No newline at end of file
......