정홍주

whale, 도움말 Tokenrror fix

Showing 1 changed file with 8 additions and 7 deletions
......@@ -41,7 +41,6 @@ app.post('/hook', function (req, res) {
console.log('[request]', req.body);
console.log('[request source] ', source);
console.log('[request message]', message);
if(message.text === '김프'){
command = '김프';
USER_ID = source.userId;
......@@ -51,12 +50,14 @@ app.post('/hook', function (req, res) {
USER_ID = source.userId;
}
else if(message.text == '고래알람'){
PushTimeId = SetWhaleAlert()
PushTimeId = SetWhaleAlert(source.userId)
USER_ID = source.userId;
}
else if(message.text == '도움말'){
explain_message();
explain_message(source.userId);
USER_ID = source.userId;
}
else if(message.text == '고래알람해제'){
clearTimeout(PushTimeId)
......@@ -69,7 +70,7 @@ app.post('/hook', function (req, res) {
res.sendStatus(200);
});
function explain_message(){
function explain_message(userId){
request.post(
{
url: TARGET_URL_PUSH,
......@@ -77,7 +78,7 @@ function explain_message(){
'Authorization': `Bearer ${TOKEN}`
},
json: {
"to": `${USER_ID}`,
"to": `${userId}`,
"messages":[
{
"type":"text",
......@@ -368,7 +369,7 @@ function data_collector(data, limit){
}
return ret;
}
function SetWhaleAlert(){
function SetWhaleAlert(userId){
url2 = 'https://api.whale-alert.io/v1/transactions?api_key=' + api_key + '&cursor=' + cursor;
const options = {method: 'GET', headers: {Accept: 'application/json'}};
......@@ -421,7 +422,7 @@ function SetWhaleAlert(){
'Authorization': `Bearer ${TOKEN}`
},
json: {
"to": `${USER_ID}`,
"to": `${userId}`,
"messages":[msg2user[i]]
}
},(error, response, body) => {
......