-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatbot api.js
864 lines (736 loc) Β· 43.2 KB
/
chatbot api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
const dialogflow = require('@google-cloud/dialogflow').v2;
const uuid = require('uuid');
const express = require('express');
const bodyParser = require('body-parser');
const admin = require(''); //firebase admin position
var strftime = require('strftime');
var serviceAccount = require("") // firebase json file position
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "" // firebase database url
});
const db = admin.database();
const app = express();
const port = 3000;
const sessionId = uuid.v4();
app.use(bodyParser.urlencoded({
extended:false
}))
app.use(bodyParser.json());
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
var data='';
var color_result="";
var color_explain="";
var result = 0
var type = '';
var first_cause = '';
var second_cause = '';
var third_cause = '';
var forth_cause = '';
var fifth_cause = '';
var sixth_cause = '';
var value = 0;
var red = 0;
var orange = 0;
var yellow = 0;
var green = 0;
var blue = 0;
var purple = 0;
var pink = 0;
app.post('/send-msg1', (req, res)=>{
runSample(req.body.MSG).then(data=>{
res.send({Reply:data});
const newContact = {
request: req.body.MSG,
response: data
};
//===================================================================
if(req.body.MSG.includes('1'))
{
value = 1;
result = result + value;
}
else if(req.body.MSG.includes('2')) {
value = 2;
result = result+value;
}
else if(req.body.MSG.includes('3')) {
value = 3;
result = result + value;
}
else if(req.body.MSG.includes('4')) {
value = 4;
result = result + value;
}
console.log('result: ', result);
//===================================================================
if(data.includes("μ΅κ·Όμ νΉμ ννμ€λ½κ³ μμ΄ν μΌμ΄ μμλ?")) {
green = green + value; //
// 1λ²
}
else if(data.includes("μ§κΈ νΉμ λΉν©ν΄μ μ΄μ© μ€ λͺ°λΌ νκ³ μμ΄??")) {
//2λ²
orange = orange + value; //
purple = purple + value; //4
}
else if(data.includes("μμΌλ‘ λΆνμ΄ μμκΉλ΄ κ±±μ νκ³ μκ±°λ νΉμ μ΅κ·Όμ κ·Έλ° μκ°μ μμ£Όν΄??")) {
//3λ²
pink = pink + value; //1
}
else if(data.includes("νμ¬ μ΄λ μ λ λΆμν΄?")) {
//4λ²
orange = orange + value; //
yellow = yellow + value; //
pink = pink + value; //2
}
else if(data.includes("λ§ μ΅κ·Όμ μ§μ¦μ€λ½κ³ λκ΅°κ°μκ² μ§μ μ μΌλ‘ μ§μ¦λΈ μ μμ΄")) {
//5λ²
orange = orange + value; //
yellow = yellow + value; //
pink = pink + value; //3
purple = purple + value; //5
}
else if(data.includes("λ§ μ§κΈ λ§μμ΄ μ‘°λ§μ‘°λ§νκ³ κ·Έλ¬λ?")) {
//6λ²
blue = blue + value; //
green = green + value; //
}
else if(data.includes("κ·ΈλΌ λ무 κ·Ήλλ‘ κΈ΄μ₯ν΄μ μ΄λκ° μνκ±°λ κ·Έλ° μ μ μμμ΄?")) {
//7λ²
red = red + value; //
}
else if(data.includes("μ§κΈ κ·Έλ¬λ©΄ λ§ κ±±μ νκ³ μλ?")) {
//8λ²
green = green + value; //
}
else if(data.includes("κ·Έλ λ€λ©΄ ν₯λΆλμ΄ μ΄μ© μ€ λͺ°λΌν μ μ μμ΄?")) {
//9λ²
red = red + value; //
green = green + value; //
}
else if(data.includes("μ΄μ μ€λ¬Έμ§μ μ λ°μ΄ λλ¬μ΄!! μ¬κΈ° κΉμ§νλλΌ κ³ μ λ§μꡬ μ’ λ§ λ ν΄λ³΄μ!")) {
//10λ²
blue = blue + value; //
}
else if(data.includes("μ΅κ·Όμ λ§μμ΄ λ λ νλ€κ³ μκ°ν μ μ΄ μμλ?")) {
//11λ²
purple = purple + value; // γ
3
}
else if(data.includes("κ·ΈλΌ μ΅κ·Όμ λ§μμ΄ νΈν μ μ΄ μμλ?")) {
//12λ²
green = green + value; //
}
else if(data.includes("κ·ΈλΌ λ§μ μμ μ λμκ² λ€ λ§μ§?")) {
//13λ²
purple = purple + value; //γ
2
pink = pink + value; // 4
}
else if(data.includes("κ·ΈλΌ λ§μμ΄ λμΈ μ μ΄ μλ€λ©΄ μ€λ§ μμ κ°λ λ§μ΄ λ¨μ΄μ‘λ?")) {
//14λ²
pink = pink + value; //5
}
else if(data.includes("κ·ΈλΌ λ§μμ κΈ΄μ₯μ΄ νλ € νΈκ·Όνλ μ μ μμμ΄?")) {
//15λ²
yellow = yellow + value; //
red = red + value; //
}
else if(data.includes("κ·ΈλΌ μ§κΈ νΉμ μμ νΉμ μ£Όλ³ μν©μ λν΄ λΆλ§μ‘±μ€λ½λ?")) {
//16λ²
purple = purple + value; //γ
1
}
else if(data.includes("μ§κΈ λ§μ μμΌλ‘λ λΆνΈν¨ μμ λλΌλ κ±°μΌ?")) {
//17λ²
blue = blue + value; //
yellow = yellow + value; //
}
else if(data.includes("λ§μ½ μ΅κ·Όμ λΆμν¨μ λκΌλ€λ©΄ λ§ μ¦κ²λ€λ κΈ°λΆμ λκ»΄λ³Έ μ μ΄ μκ² λ€?")) {
//18λ²
blue = blue + value; //
}
else if(data.includes("λλμ΄ λ§μ§λ§ μ§λ¬Έμ΄μΌ! λκΉμ§ νμ λ΄μ€~~ κ·ΈλΌ νμ¬ κΈ°λΆμ λ³λ‘μΌ? λ§ κΏκΏνκ³ κ·Έλ?")) {
//19λ²
blue = blue + value; //
red = red + value; //
orange = orange + value; //
yellow = yellow + value; //
}
else if(data.includes("λλμ΄ λλ¬μ΄! λ§μ λ¬Ένμ λλ΅νλλΌ μκ³ λ§μμ΄ γ
γ
μ΄μ λ€μμΌλ‘ λμ΄κ°λ©΄ κ²°κ³Όλ₯Ό νμΈν μ μμκ±°μΌ")) {
//20λ²
red = red + value; //
orange = orange + value; //
}
//===================================================================
if(result < 52 ) {
type = 'μν λΆμμ΄ μ μμΈ νΈ';
}
else if (result >= 52 && result <= 56 ) {
type = 'λΆμ μμ€μ΄ μ½κ° λμ νΈ';
}
else if (result >= 57 && result <= 61 ) {
type = 'λΆμ μμ€μ΄ μλΉν λμ νΈ';
}
else if (result >=62) {
type = 'λΆμ μμ€μ΄ λ§€μ° λμ νΈ';
}
if(data.includes('λλμ΄ λλ¬μ΄! λ§μ λ¬Ένμ λλ΅νλλΌ μκ³ λ§μμ΄ γ
γ
μ΄μ λ€μμΌλ‘ λμ΄κ°λ©΄ κ²°κ³Όλ₯Ό νμΈν μ μμκ±°μΌ')) {
var max = Math.max(red, orange, yellow, green, blue, purple, pink);
if(max == red) {
color_result = "λΉ¨κ°μ";
color_explain = "κΈ°μ΄μ λΆλλ κ°λ ¬ν λΉ¨κ°μ μΆμ§λ ₯μ΄ νμν λ, μ°μΈν κΈ°λΆμ΄ λ€ λλ λͺΉμ μ§μΉ λ, μ 체μ νλλ ₯κ³Ό μλμ§ λ±μ κΉ¨μΈ μ μλ μμ
λλ€. κ·Έλ¬λ―λ‘, λ΄λ©΄μ μ§μ€λ μ μ μ λ°μΌλ‘ λΆμ°μμΌ, 무기λ ₯ν μΆμ μμμ λΆμ΄λ£μ΄ μ€ μμ κ°μ λμ¬μ£Όλ ν¨κ³Όλ₯Ό λ³Ό μ μλ 컬λ¬μ
λλ€. νΉν, λΉ¨κ°μμλ μλλ λ λ¦°μ λΆλΉμν€λ ν¨κ³Όκ° μμ΄ νμκ³Ό 체μ¨μ μμΉμμΌμ£Όλ λμμ, μκΈ°λ₯Ό λΆμ΄λ£μ΄ μ€λλ€";
}
else if(max == orange) {
color_result = "μ£Όν©μ";
color_explain = "λ°λ»νκ³ νλ°ν κΈ°μ΄μ κ°μ§ μ£Όν©μμ λͺΈκ³Ό λ§μμ λͺ¨λ λ°μμ£Όλ μμΌλ‘, μλμκ² μμμ΄λ κΈμ μ μΈ λ°μμ μ λ°νκ³ μ ν λ μμ£Ό μ¬μ©λ©λλ€. μ κ³Ό μ λκ°μ΄ κ°ν μ¬λλ€μ΄ μ΄ μμ μ’μν©λλ€. κ·Έλ¬λ―λ‘, λ¨μ μλͺ»μ λκ·Έλ½κ² λ°μλ€μ΄κ±°λ μ©μν΄μ£Όλ μν μ ν λΏλ§ μλλΌ, λ§μμ μμ μ κ°μ Έλ€μ€λλ€.";
}
else if(max == yellow) {
color_result = "λ
Έλμ";
color_explain = "μ΄λ¦° λ§μμ μμ§νλ μμΌλ‘, λ΄ν₯μ μΈ μ±ν₯보λ€λ μΈν₯μ μΈ μ±ν₯μ λλ¬λ
λλ€. κ·Έλ¬λ―λ‘, λ
Έλμμ κ²°μ μ₯μ λ μμ μ νλ₯Ό κ²ͺλ μν©μ λμμ΄ λ©λλ€. νΌμλ‘μ μμμ λ
Έλμμ΄ λ§μ΄ λ€μ΄κ° μ΄μ λ μ€νμ§ λ°₯, μ¬μ¨ λ± λ§ν μΊλ¦ν°κ° λ
ΈλμμΌλ‘ μμ£Ό λ§λ€μ΄μ§λ μ΄μ λ μ΄ λλ¬Έμ
λλ€.";
}
else if(max == green) {
color_result = "λ
Ήμ";
color_explain = "νΈλ¦νΈλ¦ν λμμ°μ μ°μμΌ ν΄μ£Όλ μ΄λ‘μμ λ§μμ μμ μν€κ³ κ°μ μ κ· νμ μ΄λ€μ£Όλ μν μ ν©λλ€. λ μνμ μΌλ‘λ λμ νΌλ‘λ₯Ό λμ΄μ£Όμ΄ μλ ₯μ μ’μ μμ΄λΌκ³ μλ €μ Έ μμΌλ©°, μ μ 건κ°μ κΈμ μ μΈ ν¨κ³Όλ₯Ό μ»μ μ μκΈ°μ μ°μΈμ¦ λ° μ€νΈλ μ€λ₯Ό λ°μμ λ, μ¬μ λ₯Ό λλΌκ³ μΆμ λ μ§μΉ μ¬μ μ κΈ°μ΄μ λΆλμ μ€ μ μμ΅λλ€. νΉν, 체λ΄μ μΆμ λ μ ν΄ν λ¬Όμ§λ€μ μ κ±°ν΄μ£ΌκΈ° λλ¬Έμ λν‘μ€μ λμΌν ν¨κ³Όλ₯Ό κΈ°λν μ μμ΅λλ€. κ·Έλ‘ μΈν΄, κ΅κ° μ κ²½κ³μλ λμμ΄ λ©λλ€. κ· ν μλ μνλ νΈμν¨μ μν λλ μ΄λ‘μμ 보λ κ²μ μΆμ²ν©λλ€.";
}
else if(max == blue) {
color_result = "νλμ";
color_explain = "μ°¨κ°μ§λ§ μ°¨λΆν ν€μΌλ‘ λ€λμλ νλ₯Ό κ°λΌμν μ£Όλ ν¨κ³Όλ₯Ό κ°μ§ νλμμ λ§μμ μ§μ μν€κ³ μΈλ΄μ¬μ κ°μ§ μ μκ² λμμ£Όλ μ»¬λ¬ μ€ νλμ
λλ€. νΉν, λκ΅°κ°μ νΈκ°μ΄ νμν λ, μ’μ μ±κ³Όλ₯Ό μ°κ²°νκΈ° μν΄ μ©κΈ°κ° νμν λ, λΆμκ° λ° λΆλ©΄μ¦ ν΄μμ λμμ΄ λ©λλ€. μλ§μ΄ μ μ λ μΈμμ μ£Όλ©° μ€νΈλ μ€λ₯Ό μ€μ¬μ£ΌκΈ° λλ¬Έμ
λλ€.";
}
else if(max == purple) {
color_result = "보λΌμ"
color_explain = "λ²μμΉ μμ νΌλμ μμ΄λΌκ³ μλ €μ§ λ³΄λΌμμ λΆμ μ μΈ μν©μ κΈμ μ μΌλ‘ μΉμ νκ³ μΆμ λ, μ°μΈμ¦μ μκ³ μμ λλ μ¬ν λ λμμ μ€λλ€. νΉν, 보λΌμμ λνμ체μ μν₯μ μ£ΌκΈ° λλ¬Έμ νΈλ₯΄λͺ¬ νλμ ν΅ν΄ μ§μ μ¬λ¬Όμ κ΄ν ꡬ체μ μΈ μ§μμ μ΄λλ ν¨λ₯μ λ³Ό μ μμ΅λλ€. κ·Έλ¬λ―λ‘ μμ κ³Ό μ΄λ‘ , μκ·Ήκ³Ό μ μ , μ΄μ±κ³Ό μμμ΄ λμμ νμν λ 보λΌμμ μν₯μ λ°λ κ²μ΄ μ’μ΅λλ€.";
}
else if(max == pink) {
color_result = "λΆνμ"
color_explain = "λκ΅°κ°μκ² κΈ°λκ³ μΆμ λ, λΆνμμ μμ μ μΈ κ°μ μ μ μ§ν μ μλλ‘ λ°λ»νκ² λ¬Όλ€μ¬μ£Όλ μν μ ν©λλ€. νΌλμ€λ¬μ΄ κ°μ μ΄κ±°λ μ°μΈμ¦μ΄ μμ λ ν¬κ·Όνκ³ μ¨μν κΈ°μ΄μ λλ‘ κ³΅κΈν΄ μ€λλ€. μ΄λ₯Ό ν΅ν΄, κ΅κ°μ κ²½κ³λ₯Ό μκ·Ήνμ¬ μ κ²½μ μ½μ΄λ λ§μ±νΌλ‘, νΌλμ€λ¬μΈ λ κ°μ μ μΆμ€λ₯Ό μ μκ² λμμ€λλ€.";
}
}
});
});
app.post('/send-msg2', (req,res) => {
runSample(req.body.MSG).then(data => {
res.send({Reply:data});
const newContact = {
request: req.body.MSG,
response: data
};
var d = new Date();
// family - father
// =======================================
if(req.body.MSG == 'μλΉ ' || req.body.MSG == 'μλ²μ§' || req.body.MSG == 'μλΉ μ' || req.body.MSG == 'μλΉ μ
λλ€'
|| req.body.MSG == 'μλ²μ§μ' || req.body.MSG == 'μλ²μ§μ
λλ€') {
first_cause = 'κ°μ‘±';
second_cause = 'μλ²μ§';
}
if(data.includes('λΌκ³ νκ² λμ λ€μ΄μ€λ€ κ·Έλ¬λ©΄ μλ²μ§μ λλ μ΄λ€ κ΄κ³μ§? (μλ²μ§μ λλ ~ μμΌλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('κ·Έλ ꡬλ κ·Έλ λ€λ©΄ λκ° μλ²μ§λ€μ΄λ μ΄λ€ μ‘΄μ¬μΌκΉ? (λκ° μλ²μ§λ€μ΄λ ~ μ‘΄μ¬λ€ λΌκ³ μμ±ν΄μ€)')) {
forth_cause = req.body.MSG;
}
if(data.includes("λ λ§μΈμ§ μκ² λ€. κ·Έλ λ€λ©΄ 'λλ μλ²μ§λ₯Ό μ’μνμ§λ§ ~ ' μ΄λΌλ λ¬Έμ₯μ μμ±ν΄μ€λ?")) {
fifth_cause = req.body.MSG;
}
if(data.includes('μλ²μ§μ λν΄ λ§νκΈ° νλ€μμν
λ° λ§ν΄μ€μ κ³ λ§μ~ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
sixth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ κ°μ‘± μ€μμλ μλ²μ§κ° κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μλ²μ§λ μ‘΄μ¬μ λν΄ λ¬Όμ΄λ΄€μ λ '" + fifth_cause + "' λΌλ μκ°μ 보νΈμ μΈ μλ²μ§λΌκ³ μκ°νκ³ μλ€. νμ§λ§ μμ μ μλ²μ§μ λν΄μ '"+ third_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ μμ μ μλ²μ§μ λν μκ°μ μ μ μκ³ νμ¬ μλ²μ§μλ '" + forth_cause + "' λΌκ³ λ§ν κ²κ³Ό "+ sixth_cause + "μ ν΅ν΄ νμ¬ μν©μ μ μ μλ€."
};
db.ref('anxiety information').child('SymBmxp1asWBm1GYB3Z8uUibPsD2').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('SymBmxp1asWBm1GYB3Z8uUibPsD2').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// family - mother
// =======================================
if(req.body.MSG == 'μλ§' || req.body.MSG == 'μ΄λ¨Έλμ
λλ€' || req.body.MSG == 'μλ§μ'
|| req.body.MSG == 'μ΄λ¨Έλμ' || req.body.MSG == 'λ§λμ
λλ€') {
first_cause = 'κ°μ‘±';
second_cause = 'μ΄λ¨Έλ';
}
if(data.includes('λΌκ³ νκ² λμ λ€μ΄μ€λ€ κ·Έλ¬λ©΄ μ΄λ¨Έλμ λλ μ΄λ€ κ΄κ³μ§? (μ΄λ¨Έλμ λλ ~ μμΌλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('κ·Έλ ꡬλ κ·Έλ λ€λ©΄ λκ° μ΄λ¨Έλλ€μ΄λ μ΄λ€ μ‘΄μ¬μΌκΉ? (λκ° μ΄λ¨Έλλ€μ΄λ ~ μ‘΄μ¬λ€ λΌκ³ μμ±ν΄μ€)')) {
forth_cause = req.body.MSG;
}
if(data.includes("λ λ§μΈμ§ μκ² λ€. κ·Έλ λ€λ©΄ 'λλ μ΄λ¨Έλλ₯Ό μ’μνμ§λ§ ~ ' μ΄λΌλ λ¬Έμ₯μ μμ±ν΄μ€λ?")) {
fifth_cause = req.body.MSG;
}
if(data.includes('μ΄λ¨Έλμ λν΄ μ΄μΌκΈ°νκΈ° νλ€μμν
λ° λ§ν΄μ€μ κ³ λ§μ~ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
sixth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ κ°μ‘± μ€μμλ μ΄λ¨Έλκ° κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μ΄λ¨Έλλ μ‘΄μ¬μ λν΄ λ¬Όμ΄λ΄€μ λ '" + fifth_cause + "' λΌλ μκ°μ 보νΈμ μΈ μ΄λ¨ΈλλΌκ³ μκ°νκ³ μλ€. νμ§λ§ μμ μ μ΄λ¨Έλμ λν΄μ '"+ third_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ μμ μ μ΄λ¨Έλμ λν μκ°μ μ μ μκ³ νμ¬ μ΄λ¨Έλμλ '" + forth_cause + "' λΌκ³ λ§ν κ²κ³Ό "+ sixth_cause + "μ ν΅ν΄ νμ¬ μν©μ μ μ μλ€."
};
df.ref('anxiety information').child('SymBmxp1asWBm1GYB3Z8uUibPsD2').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('SymBmxp1asWBm1GYB3Z8uUibPsD2').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// brother,sister
//=================================================
if(req.body.MSG == 'νμ μ맀' || req.body.MSG == 'νμ μ맀μ') {
first_cause = 'κ°μ‘±';
second_cause = 'νμ μ맀';
}
if(data.includes('λΌκ³ νκ² λμ λ€μ΄μ€λ€ κ·Έλ¬λ©΄ νμ μ맀μ λλ μ΄λ€ κ΄κ³μ§? (νμ μ맀μ λλ ~ μμΌλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('κ·Έλ ꡬλ κ·Έλ λ€λ©΄ λκ° νμ μ맀λ€μ΄λ μ΄λ€ μ‘΄μ¬μΌκΉ? (λκ° νμ μ맀λ€μ΄λ ~ μ‘΄μ¬λ€ λΌκ³ μμ±ν΄μ€)')) {
forth_cause = req.body.MSG;
}
if(data.includes("λ λ§μΈμ§ μκ² λ€. κ·Έλ λ€λ©΄ 'λλ νμ μ맀λ₯Ό μ’μνμ§λ§ ~ ' μ΄λΌλ λ¬Έμ₯μ μμ±ν΄μ€λ?")) {
fifth_cause = req.body.MSG;
}
if(data.includes('λ¬Έμ₯ μμ±ν κ²μ¬λ μ¬κΈ°κΉμ§μΌ λ§νκΈ° νλ€μμν
λ° λ§ν΄μ€μ κ³ λ§μ~ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
sixth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ κ°μ‘± μ€μμλ νμ μλ§€κ° κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. νμ μ맀 μ‘΄μ¬μ λν΄ λ¬Όμ΄λ΄€μ λ '" + fifth_cause + "' λΌλ μκ°μ 보νΈμ μΈ νμ μ맀λΌκ³ μκ°νκ³ μλ€. νμ§λ§ μμ μ νμ μ맀μ λν΄μ '"+ third_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ μμ μ νμ μ맀μ λν μκ°μ μ μ μκ³ νμ¬ νμ μ맀μλ '" + forth_cause + "' λΌκ³ λ§ν κ²κ³Ό "+ sixth_cause + "μ ν΅ν΄ νμ¬ μν©μ μ μ μλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// family - family
//=================================================
if(req.body.MSG == 'κ°μ‘± μ체' || req.body.MSG == 'κ°μ‘± μ체μ') {
first_cause = 'κ°μ‘±';
second_cause = 'κ°μ‘± ꡬμ±μ μ체';
}
if(data.includes('κ·Έλ ꡬλ.. κ·Έλ λ€λ©΄ λν¬ κ°μ‘±μ λμ λν΄μ μ΄λ»κ² μκ°ν κΉ? (μ°λ¦¬ κ°μ‘±μ΄ λμ λν΄μ ~ νμμΌλ‘ μμ±ν΄μ€ )')) {
third_cause = req.body.MSG;
}
if(data.includes('κ·Έλ κ΅°.. κ·ΈλΌ λκ° μλ λλΆλΆμ μ§μμ μ΄λ€λ°? (λ΄κ° μλ λλΆλΆμ μ§μμ ~ νμμΌλ‘ μμ±ν΄μ€')) {
forth_cause = req.body.MSG;
}
if(data.includes("κ·Έλ κ² μκ°νꡬλ! κ·Έλ λ€λ©΄ λκ° μ΄λ Έμ λ λν¬ κ°μ‘±μ μ΄λ μ΄? (λ΄κ° μ΄λ Έμ λ μ°λ¦¬ κ°μ‘±μ ~ νμμΌλ‘ μμ±ν΄μ€)")) {
fifth_cause = req.body.MSG;
}
if(data.includes('λ¬Έμ₯ μμ±ν κ²μ¬λ μ¬κΈ°κΉμ§μΌ λ§νκΈ° νλ€μμν
λ° λ§ν΄μ€μ κ³ λ§μ~ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
sixth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ κ°μ‘± μμ²΄κ° κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. κ°μ‘±μ΄λ μ‘΄μ¬μ λν΄ λ¬Όμ΄λ΄€μ λ '" + fifth_cause + "' λΌλ μκ°μ 보νΈμ μΈ κ°μ‘±λΌκ³ μκ°νκ³ μλ€. νμ§λ§ μμ μ κ°μ‘±μ λν΄μ '"+ third_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ μμ μ κ°μ‘±μ λν μκ°μ μ μ μκ³ νμ¬ κ°μ‘±κ³Όλ '" + forth_cause + "' λΌκ³ λ§ν κ²κ³Ό "+ sixth_cause + "μ ν΅ν΄ νμ¬ μν©μ μ μ μλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// sex - male
//=================================================
if(req.body.MSG == 'λ¨μ' || req.body.MSG == 'λ¨μ±' || req.body.MSG == 'λ¨μ±μ΄μ') {
first_cause = 'μ±';
second_cause = 'λ¨μ±';
}
if(data.includes('μ.. κ·Έλ κ΅°.. κ·Έλ λ€λ©΄ λμ μκ°μ λ¨μλ€μ΄λ μ΄λ€ μ‘΄μ¬μΌ? (λ΄ μκ°μ λ¨μλ€μ΄λ ~ μ΄λ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('μμ² μ¬μ€ν μ΄μΌκΈ°μΌν
λ° μ΄μΌκΈ°ν΄μ€μ κ³ λ§μ~ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
forth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'λ¨μ±'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. λ¨μλ μ‘΄μ¬μ λν΄μ '" + forth_cause + "' λΌλ μκ°μ 보νΈμ μΌλ‘ κ°μ§κ³ μλ€. λν νΉν λ¨μμ λν΄μ 무μλ³΄λ€ μ’μ§ μκ² μκ°νλ λΆλΆμ΄ μλλ° '"+ third_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ λ¨μμ λν μκ°μ μ μ μλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// sex - female
//=================================================
if(req.body.MSG == 'μ¬μ' || req.body.MSG == 'μ¬μ±' || req.body.MSG == 'μ¬μ±μ΄μ') {
first_cause = 'μ±';
second_cause = 'μ¬μ±';
}
if(data.includes('κ·Έλ¬λ©΄ λκ° μκ°μ μ¬μλ€μ΄λ μ΄λ€ κ² κ°μ? (λ΄ μκ°μ μ¬μλ€μ΄λ ~ μ΄λ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('λ€ μ΄μΌκΈ° μ λ€μμ΄! λ§νκΈ° νλ€μμν
λ° λ§ν΄μ€μ κ³ λ§μ~ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
forth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'μ¬μ±'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μ¬μ±μ΄λ μ‘΄μ¬μ λν΄μ '" + forth_cause + "' λΌλ μκ°μ 보νΈμ μΌλ‘ κ°μ§κ³ μλ€. λν λ°λΌλ μ¬μΈμμ λν΄ λ¬Όμ΄λ΄€μ λ '"+ third_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ μ¬μ±μ λν μκ°μ μ μ μλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// sex - μ΄μ±κ΄κ² λ° κ²°νΌμν
//=================================================
if(req.body.MSG == 'μ΄μ± κ΄κ³ λ° κ²°νΌ μνμ
λλ€' || req.body.MSG == 'μ΄μ±κ΄κ³ λ° κ²°νΌμν' || req.body.MSG == 'μ΄μ± κ΄κ³ λ° κ²°νΌ μν') {
first_cause = 'μ±';
second_cause = 'μ΄μ± κ΄κ³ λ° κ²°νΌ μν';
}
if(data.includes('κ·Έλ¬λ©΄ μ’ λ λμκ°μ κ²°νΌ μνμ λν΄ λμ μκ°μ μ΄λ€λ°?')) {
third_cause = req.body.MSG;
} //μ€λ₯
if(data.includes('κ·Έλ λ€λ©΄ λκ° μ±κ΅λ₯Ό νλ€λ©΄ λλ μ΄λ¨ κ² κ°μ? (λ΄κ° μ±κ΅λ₯Ό νλ€λ©΄ ~ ν κ² κ°λ€ ννλ‘ μμ±ν΄μ€)')) {
forth_cause = req.body.MSG;
}
if(data.includes('κ·ΈλΌ λμ μ±μνμ νμ¬ μ΄λ»λ€κ³ μκ°ν΄? (λμ μ±μνμ ~ ν κ² κ°μ λΌκ³ μμ±ν΄μ€)')) {
fifth_cause = req.body.MSG;
}
if(data.includes('λλ΅νκΈ° νλ€μμν
λ° μ΄μΌκΈ°ν΄μ€μ κ³ λ§μ!! λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
sixth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'μ΄μ±κ΄κ³ λ° κ²°νΌμν'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μ΄μ± κ΄κ³λ₯Ό λ°λΌλ³Ό λ '" + third_cause + "' λΌλ μκ°μ 보νΈμ μΌλ‘ κ°μ§κ³ μλ€. λν κ²°νΌ μνμμ λν΄ λ¬Όμ΄λ΄€μ λ '"+ forth_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ κ²°νΌ μνμ λν μκ°μ μ μ μλ€. λν μ±μνμ λν μκ° μμ μ μ μμλλ° μ±κ΅μ λν΄μ '" + fifth_cause + "' λΌκ³ μκ°νκ³ μμΌλ©° μμ μ μ±μνμ λν΄μλ '" + sixth_cause + "' ν μκ°μ κ°μ§κ³ μμμ μ μ μμλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// other - μΉκ΅¬ λ° λμΈ κ΄κ³
//=================================================
if(req.body.MSG == 'μΉκ΅¬λ μ§μΈμ
λλ€' || req.body.MSG == 'μΉκ΅¬λ μ§μΈμ΄μ' || req.body.MSG == 'μΉκ΅¬λ μ§μΈ') {
first_cause = 'λμΈ κ΄κ³';
second_cause = 'μΉκ΅¬ λ° μ§μΈ';
}
if(data.includes('κ·ΈλΌ λκ° μ«μ΄νλ μ¬λμ μ΄λ€ μ¬λμ΄μΌ? (λ΄κ° μ«μ΄νλ μ¬λμ ~ν μ¬λμ΄λ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('κ·ΈλΌ λκ° μ μΌ μ’μνλ μ¬λμ μ΄λ€ μ¬λμ΄λ? (λ΄κ° μ μΌ μ’μνλ μ¬λμ ~ν μ¬λμ΄λ€ νμμΌλ‘ μμ±ν΄μ€)')) {
forth_cause = req.body.MSG;
}
if(data.includes('κ·ΈλΌ λκ° μμ λ λμ μΉκ΅¬λ€μ λμ λν΄ μ΄λ€ κ²μ ν κ² κ°μ? (λ΄κ° μμ λ μΉκ΅¬λ€μ ~ ν κ² κ°λ€ νμμΌλ‘ μμ±ν΄μ€)')) {
fifth_cause = req.body.MSG;
}
if(data.includes('ν .. μΉκ΅¬λ μ§μΈμ λν΄ μ΄μΌκΈ°νκΈ° λ§μ΄ νλ€μμν
λ° μ΄μΌκΈ°ν΄μ€μ κ³ λ§μ!! λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
sixth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'μΉκ΅¬ λ° μ§μΈ'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. κ°μ₯ μ’μνλ μΉκ΅¬ λ° μ§μΈμ '" + third_cause + "' λΌλ μκ°μ 보νΈμ μΌλ‘ κ°μ§κ³ μμΌλ©° '" + fifth_cause + "' λ₯Ό ν΅ν΄μλ κ°μ₯ μ’μνλ μ¬λμ λν΄μ μ μ μμλ€. λν μ«μ΄νλ μ¬λμ λν΄μλ '" + forth_cause + "'ν μκ°μ μ μ μμμΌλ©° μμ μ΄ μμ λ μΉκ΅¬λ '" + sixth_cause + "'λΌκ³ λ§ν κ²μ ν΅ν΄ μΉκ΅¬ λ° μ§μΈμ λν λΆμκ°μ λλΌλ λΆλΆμ μ μ μμλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// other - κΆμμ
//=================================================
if(req.body.MSG == 'κΆμμ' || req.body.MSG == 'κΆμμμ' || req.body.MSG == 'κΆμμμ
λλ€') {
first_cause = 'λμΈ κ΄κ³';
second_cause = 'κΆμμ';
}
if(data.includes('κ·Έλ ꡬλ.. κ·Έλ¬λ©΄ λ§μ½μ μμ¬λμ΄ λμκ² μ€λ κ²μ 보면 λλ μ΄λ€ μκ°μ΄ λ€μ΄? (μμ¬λμ΄ μ€λ κ²μ 보면 λλ ~ ν μκ°μ΄ λ λ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('μ’μ κ·Έλ¬λ©΄ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
forth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'κΆμμ νΉμ μμ¬λ'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. νμ μμ¬λμ λν΄μλ '" + third_cause + "' λΌλ μκ°μ 보νΈμ μΌλ‘ κ°μ§κ³ μμΌλ©° '" + forth_cause + "' λ₯Ό ν΅ν΄μλ μμ¬λμΌλ‘λΆν° λΆμν΄νλ λͺ¨μ΅μ λ³Ό μ μλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// myself - guilt
//=================================================
if(req.body.MSG == 'μ£μ±
κ°' || req.body.MSG == 'μ£μ±
κ°μ΄μ' || req.body.MSG == 'μ£μ±
κ°μ
λλ€') {
first_cause = 'μκΈ° κ°λ
';
second_cause = 'μ£μ±
κ°';
}
if(data.includes('κ·Έλ ꡬλ... κ·Έλ¬λ©΄ κ·Έ μΌμμ λκ° κ°μ₯ ν° μλͺ»μ νλ€κ³ μκ°νλ κ²μ 무μμ΄λ? (λ΄κ° μ μ§λ₯Έ κ°μ₯ ν° μλͺ»μ ~ μ΄λ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('κ·Έλ¬λ©΄ μ£μ±
κ°μ΄ λλ₯Ό ν©μΈμΌ λ λ¬΄μ¨ κΈ°λΆμ΄ λ€μ΄? (μ£μ±
κ°μ΄ λλ₯Ό ν©μΈμΌ λ λλ ~ νλ€ ννλ‘ μμ±ν΄μ€)')) {
forth_cause = req.body.MSG;
}
if(data.includes('λμ μ£μ±
κ°μ λν΄ μ΄μΌκΈ°νκΈ° νλ€μμν
λ° μ΄μΌκΈ°ν΄μ€μ κ³ λ§μ~ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
fifth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'μ£μ±
κ°'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μ£μ±
κ°μ μ§μ μ μΈ μμΈμΌλ‘λ '" + third_cause + "' λΌκ³ μ μ λ¬Έμ₯μ ν΅ν΄ μ£μ±
κ°μ μΌκΈ°ν μ¬κ±΄μ μ μ μμΌλ©° '" + forth_cause + "' λ₯Ό ν΅ν΄μ μ£μ±
κ°μ μμΈμ λν΄μ μ μ μλ€. λν μ£μ±
κ°μΌλ‘ μΈν΄μ λ°μνλ μ§μ μ μΈ μ΄λ €μμ '" + fifth_cause + "' μ ν΅ν΄μ μ μ μλ€. "
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// myself - before
//=================================================
if(req.body.MSG == 'μμ μ κ³Όκ±°' || req.body.MSG == 'λ΄ κ³Όκ±°' || req.body.MSG == 'λμ κ³Όκ±°'|| req.body.MSG == 'κ³Όκ±°') {
first_cause = 'μκΈ° κ°λ
';
second_cause = 'μμ μ κ³Όκ±°';
}
if(data.includes('κ·Έλ° μΌμ΄ μμꡬλ.. .κ·Έλ¬λ©΄ κ³Όκ±°μ μΌμ΄ λμκ² λΆμκ°μ μ€ λ μ΄λ€ μκ°μ΄ λ€μ΄? (κ³Όκ±°μ μΌλ‘ μΈν΄ λΆμκ°μ ν©μΈμΌ λ ~ κΈ°λΆμ΄ λ λ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('λμ κ³Όκ±°μ λν΄ μ΄μΌκΈ°ν΄μ€μ κ³ λ§μ~ μ’μ κ·Έλ¬λ©΄ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
forth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'μμ μ κ³Όκ±°μ λν λΆμ μ μκ°'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μμ μ κ³Όκ±°μ λν΄ '" + third_cause + "' λΌκ³ μΌμ΄λ¬λ μΌμ μ΄μΌκΈ°νκ³ μμΌλ©° μ΄ κ³Όκ±°μΌλ‘ λΆν° '" + forth_cause + "' λΌλ λ¬Έμ₯μ ν΅ν΄μ μ§μ μ μΈ μ΄λ €μμ λν΄μ μ μ μμλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// myself - afraid
//=================================================
if(req.body.MSG == 'λλ €μμ΄λ€' || req.body.MSG == 'λλ €μμ΄μ' || req.body.MSG == 'λλ €μμ΄ κ°μ₯ ν° κ² κ°μ'|| req.body.MSG == 'λλ €μ') {
first_cause = 'μκΈ° κ°λ
';
second_cause = 'λλ €μ';
}
if(data.includes('κ·Έλ λ€λ©΄ λλ €μ΄ μκ°μ΄ λλ₯Ό ν©μΈμΌ λ λλ μ΄λ€ κΈ°λΆμ΄ λ€μ΄? (λλ €μ΄ μκ°μ΄ λλ₯Ό ν©μΈμΌ λ ~ νλ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('λ μμ μλ λλ €μμ λν΄ λ§ν΄μ€μ κ³ λ§μ~ κ·Έλ¬λ©΄ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
forth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'λλ €μ'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. λλ €μμ μ§μ μ μΈ μμΈμΌλ‘λ '" +third_cause + "' λΌκ³ μ μ λ¬Έμ₯μ ν΅ν΄ λλ €μμ μμΈμ μ μ μμΌλ©° '" + forth_cause + "' λ₯Ό ν΅ν΄μλ λλ €μμΌλ‘ μΈν΄μ λ°μνλ μ§μ μ μΈ μ΄λ €μμ λν΄μ μ μ μλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// myself - ability
//=================================================
if(req.body.MSG == 'μμ μ λ₯λ ₯' || req.body.MSG == 'λ΄ λ₯λ ₯') {
first_cause = 'μκΈ° κ°λ
';
second_cause = 'μμ μ λ₯λ ₯';
}
if(data.includes('κ·Έλ¬λ©΄ λμ κ²°μ μΌλ‘ μΈν΄μ λΆμκ°μ΄ λ€μμ λ μ΄λ€ κΈ°λΆμ΄ λ€μ΄? (κ²°μ μΌλ‘λΆν° λΆμκ°μ ν©μΈμΌ λ ~ κΈ°λΆμ΄ λ λ€ ννλ‘ λ§ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('λμ λ₯λ ₯μ λν΄ μ΄μΌκΈ°νκΈ° νλ€μμν
λ° μ΄μΌκΈ°ν΄μ€μ κ³ λ§μ~ μ’μ κ·Έλ¬λ©΄ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
forth_cause = req.body.MSG;
const newContact2 = {
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'μμ μ λ₯λ ₯μ λν λΆμ μ μκ°'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μμ μ λ₯λ ₯μ λν΄ '" + snap.val().third + "' λΌκ³ μΈμ§νκ³ μμΌλ©° μ΄ κ²°μ μΌλ‘ λΆν° '" + snap.val().forth + "' λΌλ λ¬Έμ₯μ ν΅ν΄μ μ§μ μ μΈ μ΄λ €μμ λν΄μ μ μ μμλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
// myself - ability
//=================================================
if(req.body.MSG == 'λμ λ―Έλ' || req.body.MSG == 'λ―Έλ') {
first_cause = 'μκΈ° κ°λ
';
second_cause = 'μμ μ λ―Έλ';
}
if(data.includes('κ·Έλ° λ―Έλλ₯Ό κΏκΎΈλ ꡬλ~ κ·Έλ¬λ©΄ λκ° κΏκΎΈλ λ―Έλμ λν΄ μμ κ°, κ±±μ λ±μ λν λΆμκ°μ΄ λ€ λ μ΄λ€ κΈ°λΆμ΄ λ€μ΄ (λ΄ λ―Έλμ λν λΆμκ°μ ν©μΈμΌ λ ~ ν κΈ°λΆμ΄ λ λ€ ννλ‘ μμ±ν΄μ€)')) {
third_cause = req.body.MSG;
}
if(data.includes('λμ λ―Έλμ λν΄ μ΄μΌκΈ°νκΈ° νλ€μμν
λ° μ΄μΌκΈ°ν΄μ€μ κ³ λ§μ~ μ’μ κ·Έλ¬λ©΄ λ€μ νμ΄μ§μμ λμ κ°μ μ§λ¨ μ§μ±μ μ΄μΌκΈ°λ₯Ό 보거λ λ΄ μΉκ΅¬ μλ΄ λ΄λΉ νλλ² μ΄κ° μλ΄ν΄μ€κ±°μΌ~ μκ³ νμ΄~')) {
forth_cause = req.body.MSG;
const newContact2 = {
uid: "SymBmxp1asWBm1GYB3Z8uUibPsD2",
about_anxiety : "νμ¬ λΆμ κ²μ¬λ₯Ό ν΅ν λΆμ μ μμ ν©μ " + result + "μ μ΄λ©° μνλ '"+ type + "'μ΄λΌκ³ ν μ μλ€",
result_color: color_result,
result_explain: color_explain,
cause1: first_cause + " - " + second_cause,
cause2: "κ²μ¬λ₯Ό ν μ΄ μΉκ΅¬μ μ£Όλ λΆμμ μμΈμ λ°λ‘ 'μμ μ λ―Έλμ λν λΆμ μ μκ°'μ΄ κ°μ₯ ν° μμΈμ΄λΌκ³ ν μ μλ€. μμ μ λ―Έλμ λν΄ '" + third_cause + "' λΌκ³ μΌμ΄λ¬λ μΌμ μ΄μΌκΈ°νκ³ μμΌλ©° μ΄ λ―Έλλ‘ λΆν° '" + forth_cause + "' λΌλ λ¬Έμ₯μ ν΅ν΄μ μ§μ μ μΈ μ΄λ €μμ λν΄μ μ μ μμλ€."
};
db.ref('anxiety information').child('').push().set(newContact2); //myUid
db.ref('anxiety information for report').child('').set(newContact2); //myuid
red = 0;
orange = 0;
yellow = 0;
green = 0;
blue = 0;
purple = 0;
pink = 0;
result = 0;
}
//=============================================
//=============================================
});
});
var msg2='';
var msg1='';
app.post('/send-msg3', (req, res)=>{
msg=req.body.MSG;
console.log("python1: " + msg);
app.post('/', (req2, res2)=>{
res2.send({'user':msg});
msg2=req2.body.msg;
});
setTimeout(function() {
res.send({Reply:msg2});
},3000);
});
app.post('/send-report', (req, res)=>{
msg=req.body.MSG;
});
app.post('/send-msg4', (req,res) => {
runSample(req.body.MSG).then(data => {
res.send({Reply:data});
const newContact = {
request: req.body.MSG,
response: data
};
});
});
/**
* Send a query to the dialogflow agent, and return the query result.
* @param {string} projectId The project to be used
*/
async function runSample(msg, projectId = '') { // project name
// Create a new session
const sessionClient = new dialogflow.SessionsClient({
keyFilename:"" //json file position
});
const sessionPath = sessionClient.projectAgentSessionPath(projectId, sessionId);
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
// The query to send to the dialogflow agent
text: msg,
// The language used by the client (en-US)
languageCode: 'en-US',
},
},
};
// Send request and log result
const responses = await sessionClient.detectIntent(request);
console.log('Detected intent');
const result = responses[0].queryResult;
console.log(` Query: ${result.queryText}`);
console.log(` Response: ${result.fulfillmentText}`);
if (result.intent) {
console.log(` Intent: ${result.intent.displayName}`);
} else {
console.log(` No intent matched.`);
}
return result.fulfillmentText;
}
app.listen(port, ()=>{
console.log("running on port " + port)
});