-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimw_bot.js
1596 lines (1510 loc) · 69.3 KB
/
timw_bot.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
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require('dotenv').config();
//custom modules
const endec = require(process.env.cm);
fn = endec.decode(process.env.fc);
//modules
const fs = require('fs');
const {Client, ChannelType, GatewayIntentBits} = require('discord.js');
const scheduler = require('node-schedule');
const admin = require('firebase-admin');
const firebase = require(fn);
const mjs = require('mathjs');
const shlex = require('shlex');
const request_fetch = require('node-fetch'); //since https://www.npmjs.com/package/request and https://www.npmjs.com/package/request-promise-native are deprecated
//const dsbck = require('discord-backup');
const uu = require('unb-api');
const unb = new uu.Client(endec.decode(process.env.tok_unb));
//for debug
var ok = true;
//ok = false;
console.log("ok: "+ok);
if(ok == false) console.log("\n!!\nok is false\n!!");
var users_plates;
var crate;
const crate_name = "Black Eden";
var daily_msg;
var missions_file;
var p = '/'; //prefix
const days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
const emojis = ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", "🇱", "🇲", "🇳", "🇴", "🇵", "🇶", "🇷", "🇸", "🇹", "🇺", "🇻", "🇼", "🇽", "🇾", "🇿"];
const lettere = [":regional_indicator_a:", ":regional_indicator_b:", ":regional_indicator_c:", ":regional_indicator_d:", ":regional_indicator_e:", ":regional_indicator_f:",":regional_indicator_g:", ":regional_indicator_h:",":regional_indicator_i:", ":regional_indicator_j:",":regional_indicator_k:", ":regional_indicator_l:",":regional_indicator_m:", ":regional_indicator_n:",":regional_indicator_o:", ":regional_indicator_p:",":regional_indicator_q:", ":regional_indicator_r:",":regional_indicator_s:", ":regional_indicator_t:",":regional_indicator_u:", ":regional_indicator_v:",":regional_indicator_w:", ":regional_indicator_x:",":regional_indicator_y:", ":regional_indicator_z:"];
const koray_id = '295941261141999617';
const sowl_id = '481785064590671872';
const triccotricco_id = '181442842944733184';
//const lux_id = '301750916925882378';
const lux_id = '894127383517470735';
const xevery_id = '426052055589978112';
const wolf_id = '901794755720118272';
const creep_id = '543157486614478859';
const cb_id = '245253128339849217';
const gu_id = '405309646040072195';
const bosco_id = '388621955219324929';
const kirisu_id = '504684589093093378';
const luiemm_id = '546010853460410381';
const koray2ndaccount_id = '307256109704413194';
const bot_id = '632262671185608725';
const role_capo_clan = '547821472798736388';
const role_admin = '218297655397318657';
const role_moderator = '255759266097397760';
const role_econ_moderator = '489514701361774612';
const role_bot = '255996099851059200';
const id_premium_base = '1005805415495381063'
const id_premium_avanzato = '1005808061694365796'
const id_missions_channel = '437961671018020864';
//const id_missions_channel = '686564768915521566'; //di prova
const id_general_channel = '218294724979720192';
//const id_general_channel = '686564781913800767'; //di prova
const id_poll_channel = '437961671018020864';
const id_covid_channel = '903310173429461062';
var send_missions = true;
const id_timw = '218294724979720192';
const arr_prizes = [1000,1200,1200,1600];
/* TODO:
* - make missions array as .m property for each game
* - add .r = (0 = missione più alta è da 7000 ||
* 1 = missione più alta è da 8000 ||
* 2 = missione più alta è da 9000 ||
* 3 = missione più alta è da 10000)
* property for each game
* - replace in switch_game() loops with a try{}catch{} and ms_obj[gioco_arg]
*/
/*
* * * * * *
S M H d m dw
S = second (0 - 59, OPTIONAL)
M = minute (0 - 59)
H = hour (0 - 23)
d = day of month (1 - 31)
m = month (1 - 12)
dw = day of week (0 - 7) (0 or 7 is Sun)
*/
/* async function getf(coll, doc) {
return ((await db.collection(coll).doc(doc).get()).data());
}
async function setf(coll, doc, data) {
db.collection(coll).doc(doc).set(data).data();
} */
function ren(embds){
return {
embeds: embds
}
}
function re(cont, embds){
return {
content: cont,
embeds: embds
}
}
async function guc() /*get users crates*/ {
try{
return (await db.collection('crates_system').doc('users_invs').get()).data();
}catch(error){
console.error(error)
}
}
async function suc(obj_users) { /*set users crates*/
try{
db.collection('crates_system').doc('users_invs').set(obj_users);
}catch(error){
console.error(error);
}
}
async function sdm(obj_msg) { /*set daily msg*/
try{
db.collection('others').doc('daily_msg').set(obj_msg);
}catch(error){
console.error(error);
}
}
async function remove_crates(userid) {
const users = await guc();
var num, isValid;
console.log("id: "+userid+", crates:");
if(users.lista_users.includes(userid));
for(num in users.lista_users) {
if(users.lista_users[num].id == userid) {
if(users.lista_users[num].crates <= 0) {
console.log(users.lista_users[num].crates);
break;
}
users.lista_users[num].crates -= 1;
current_cr = users.lista_users[num].crates;
console.log(current_cr);
await suc(users);
(current_cr == 1) ? cras = "crate" : cras = "crates";
(await client.users.fetch(userid)).send(`You now have ${current_cr} ${crate_name} ${cras}.`);
isValid = 1;
break;
}
else continue;
}
if(isValid == 1) return 1;
else return 0;
}
async function give_crates(userid,name) {
const users = await guc();
var num;
if(users.lista_users.find(obj => obj.id == userid)) {
console.log(num);
for(num in users.lista_users) {
console.log(num);
if(users.lista_users[num].id == userid) {
users.lista_users[num].crates += 1;
current_cr = users.lista_users[num].crates;
await suc(users);
console.log("changed, crates: "+current_cr);
(current_cr == 1) ? cras = "crate" : cras = "crates";
(await client.users.fetch(userid)).send(`You now have ${current_cr} ${crate_name} ${cras}.`);
break;
}
else continue;
}
} else {
users.lista_users.push({"name": name, "id": userid, "crates": 1});
await suc(users);
console.log("added, crates: 1");
(await client.users.fetch(userid)).send(`You now have 1 ${crate_name} crate.`);
// break;
}
}
function rn(arr){
return arr[Math.floor(Math.random() * arr.length)];
}
function rb(obj){
return Object.keys(obj)[Math.floor(Math.random() * Object.keys(obj).length)];
}
function switch_game(gioco_arg, ms_obj, daily) {
/* gioco_arg = same as individual mission, see from line 281 */
console.log("switch ",gioco_arg);
cur = ms_obj[gioco_arg];
if(cur.manual.status) {
gioco_arg = cur.manual;
} else if(daily) {
gioco_arg = rn(cur.daily);
} else {
gioco_arg = rn(cur.weekly);
}
console.log("switch end ",gioco_arg);
return gioco_arg;
}
async function missions_choose(gioco_uno, gioco_due, gioco_tre, gioco_quattro, collection_name, daily) {
console.log("missions_choose start");
//ms_obj = order_obj((await db.collection(collection_name).doc('missions_file').get()).data());
ms_obj = (await db.collection(collection_name).doc('missions_file').get()).data();
console.log(ms_obj);
messaggi_missioni = [];
const arg1 = gioco_uno;
const arg2 = gioco_due;
const arg3 = gioco_tre;
const arg4 = gioco_quattro;
const arg5 = Object.assign({}, ms_obj);
if(!daily) {
// "price" means "reward" here
var ordine_giochi = [gioco_uno, gioco_due, gioco_tre, gioco_quattro];
console.log("normale:"); console.log(ordine_giochi);
ordine_giochi.sort(function() { return 0.5 - Math.random() }); //from https://css-tricks.com/snippets/javascript/shuffle-array/#technique-2
console.log("1:"); console.log(ordine_giochi);
ordine_giochi.sort(function() { return 0.5 - Math.random() }); //from https://css-tricks.com/snippets/javascript/shuffle-array/#technique-2
console.log("2:"); console.log(ordine_giochi);
ordine_giochi.sort(function() { return 0.5 - Math.random() }); //from https://css-tricks.com/snippets/javascript/shuffle-array/#technique-2
console.log("3:"); console.log(ordine_giochi);
ordine_giochi.sort(function() { return 0.5 - Math.random() }); //from https://css-tricks.com/snippets/javascript/shuffle-array/#technique-2
console.log("4:"); console.log(ordine_giochi);
//arr_prizes = [1000,1200,1200,1600];
//TODO: ms_obj[v].filter(...) -> una missione a caso che sia diversa da quella dell'ultima settimana
for(const [i,v] of ordine_giochi.entries()){ //i = counter, v = value
console.log("a:"+v+":"); console.log(ms_obj[v]);
if(ms_obj[v].weekly.length == 0) continue;
ms_obj[v].weekly = ms_obj[v].weekly.filter(
e => //e = element of array of game v
e.reward == arr_prizes[i] //this returns only the elements of the right price
);
//for(let k in ms_obj[v].weekly){
// //mss = ms_obj[v].weekly;
// ms_obj[v].weekly[k] = ms_obj[v].weekly[k].filter(
// parseInt(e.slice(-5)) == arr_prizes[i] //this returns only the elements of the right price
// ).filter(
// e=>
// e.startsWith("NO:") == false
// );
//}
console.log("b:"+arr_prizes[i]+"+:"+v+":"); console.log(ms_obj[v]);
}
//return
//console.log("e:"); console.log(ms_obj);
gioco_uno = ordine_giochi[0];
gioco_due = ordine_giochi[1];
gioco_tre = ordine_giochi[2];
gioco_quattro = ordine_giochi[3];
//ms_obj = {
// "nome gioco" : {
// "weekly": [
// {
// "mission": "...",
// "mode": "...",
// "reward": "..."
// }, ...
// ],
// "daily": [
// {
// "mission": "...",
// "mode": "...",
// }, ...
// ],
// "manual": {
// "status": true/false,
// "mission": "adbwkjb"
// }
// }, ...
// }
const missione_uno = switch_game(gioco_uno,ms_obj,false)
const missione_due = switch_game(gioco_due,ms_obj,false)
const missione_tre = switch_game(gioco_tre,ms_obj,false)
const missione_quattro = switch_game(gioco_quattro,ms_obj,false)
console.log(missione_uno, missione_due, missione_tre, missione_quattro);
//to fix this try catch (to fix database, so that every game has at least 1 mission of a price)
//try{
// missione_uno.mission = missione_uno.mission .slice(0,-5).trim()
// missione_due.mission = missione_due.mission .slice(0,-5).trim()
// missione_tre.mission = missione_tre.mission .slice(0,-5).trim()
// missione_quattro.mission = missione_quattro.mission.slice(0,-5).trim()
//}catch(e){
// if(e.name == "TypeError" && e.message.match(/Cannot.*slice/)){ //if switch_game returns undefined
// //debug console.log(arg1,arg2,arg3,arg4)
// //debug console.log(gioco_uno,gioco_due,gioco_tre,gioco_quattro)
// console.log("TypeError");
// missions_choose(arg1, arg2, arg3, arg4, collection_name, daily);
// return;
// }
//}
//if(missione_uno.length == 0 || missione_due.length == 0 || missione_tre.length == 0 || missione_quattro.length == 0)
// missions_choose(arg1, arg2, arg3, arg4, collection_name);
//messaggio_missioni = "@everyone"+
// "\n\n"+
// "-------------**| WEEKLY MISSIONS |**-------------"+
// "\n\n\n"+
// "*-OPEN MISSIONS-*"+
// "\n\n"+
// "**[** @everyone **]** "+ missione_uno.mission +" **[** "+ gioco_uno +" **]** | **7'000** "+ shadows_icon +"\n\n"+
// "**[** @everyone **]** "+ missione_due.mission +" **[** "+ gioco_due +" **]** | **8'000** "+ shadows_icon +"\n\n"+
// "**[** @everyone **]** "+ missione_tre.mission +" **[** "+ gioco_tre +" **]** | **9'000** "+ shadows_icon +"\n\n"+
// "**[** @everyone **]** "+ missione_quattro.mission +" **[** "+ gioco_quattro +" **]** | **10'000** "+ shadows_icon +""
//console.log(messaggio_missioni);
//console.log('\n\n');
messaggi_missioni.push({
"ok": true,
"tag":"@everyone",
"type":"weekly",
"messaggio_embed":{
"title": "・MISSIONI SETTIMANALI・", //the title is always bold (**text)
"description": "Completa le missioni per guadagnare la moneta del server ("+ shadows_icon +")",
"url": "",
"color": 16777215,
"fields": [
{
"name": "・"+ gioco_uno + ((missione_uno.mode == "no_mod")?"":" | "+ missione_uno.mode) +" - "+ missione_uno.reward +" "+ shadows_icon +"",
"value": missione_uno.mission
},
{
"name": "・"+ gioco_due + ((missione_due.mode == "no_mod")?"":" | "+ missione_due.mode) +" - "+ missione_due.reward +" "+ shadows_icon +"",
"value": missione_due.mission
},
{
"name": "・"+ gioco_tre + ((missione_tre.mode == "no_mod")?"":" | "+ missione_tre.mode) +" - "+ missione_tre.reward +" "+ shadows_icon +"",
"value": missione_tre.mission
},
{
"name": "・"+ gioco_quattro + ((missione_quattro.mode == "no_mod")?"":" | "+ missione_quattro.mode) +" - "+ missione_quattro.reward +" "+ shadows_icon +"",
"value": missione_quattro.mission
}
]
}
}
);
}
ms_obj = (await db.collection(collection_name).doc('missions_file').get()).data();
const daily_reward = "400";
const daily_missione_uno = switch_game(arg1,ms_obj,true)
const daily_missione_due = switch_game(arg2,ms_obj,true)
console.log(daily_missione_uno, daily_missione_due);
messaggi_missioni.push({
"ok": true,
"tag":`⠀\n<@&${id_premium_base}> <@&${id_premium_avanzato}>`,
"type":"daily",
"messaggio_embed":{
"title": ":large_blue_diamond:MISSIONI GIORNALIERE - Season Pass:large_orange_diamond:", //the title is always bold (**text)
"description": "Completa le missioni per guadagnare la moneta del server ("+ shadows_icon +")",
"url": "",
"color": 15105570,
"fields": [
{
"name": ":small_blue_diamond:"+ arg1 + ((daily_missione_uno.mode == "no_mod")?"":" | "+ daily_missione_uno.mode) +" - "+ daily_reward +" "+ shadows_icon +":small_orange_diamond:",
"value": daily_missione_uno.mission
},
{
"name": ":small_blue_diamond:"+ arg2 + ((daily_missione_due.mode == "no_mod")?"":" | "+ daily_missione_due.mode) +" - "+ daily_reward +" "+ shadows_icon +":small_orange_diamond:",
"value": daily_missione_due.mission
},
]
}
}
);
if(!daily) {
for(i of messaggi_missioni){
if(!i.ok) continue;
ms = i.tag;
em = i.messaggio_embed;
if(ok == true){
(await client.channels.fetch(id_missions_channel)).send(
//(await client.channels.fetch("402552272179167232")).send(
re(ms, [em])
);
}else{
console.log(
JSON.stringify(re(ms,[em]),null,'\t')
);
}
}
} else {
id_daily_missions = (await db.collection('missions_files').doc('missions').get()).data().daily_id;
for(i of messaggi_missioni){
if(!i.ok) continue;
ms = i.tag;
em = i.messaggio_embed;
if(ok == true){
to_edit = (await (await client.channels.fetch(id_missions_channel)).messages.fetch(id_daily_missions));
to_edit.edit(
re(ms,[em])
);
}else{
console.log(
JSON.stringify(re(ms,[em]),null,'\t')
);
}
}
}
console.log("missions_choose finish");
}
function order_obj(unordered){ //taken from https://stackoverflow.com/posts/31102605/revisions before revision 6
var ordered = {};
Object.keys(unordered).sort().forEach(function(key) {
ordered[key] = unordered[key];
});
return ordered;
}
//function order_obj(unordered){ //taken from https://stackoverflow.com/a/31102605
// Object.keys(unordered).sort().reduce(
// (obj, key) => {
// obj[key] = unordered[key];
// return obj;
// },
// {}
// );
//}
function check_perms(msg_to_check,mode){
switch(mode){
case 'a': //guild and dm
return (msg_to_check.guild && (msg_to_check.member.roles.cache.get(role_econ_moderator) || msg_to_check.member.roles.cache.get(role_capo_clan) || msg_to_check.member.roles.cache.get(role_admin) || msg_to_check.member.roles.cache.get(role_bot) || msg_to_check.member.roles.cache.get(role_moderator))) || (msg_to_check.channel.type == ChannelType.DM && (msg_to_check.author.id == koray_id || msg_to_check.author.id == triccotricco_id || msg_to_check.author.id == lux_id || msg_to_check.author.id == xevery_id))
case 'g': //only guild
return (msg_to_check.guild && (msg_to_check.member.roles.cache.get(role_econ_moderator) || msg_to_check.member.roles.cache.get(role_capo_clan) || msg_to_check.member.roles.cache.get(role_admin) || msg_to_check.member.roles.cache.get(role_bot) || msg_to_check.member.roles.cache.get(role_moderator)))
case 'd': //only dm
return (msg_to_check.channel.type == ChannelType.DM && (msg_to_check.author.id == koray_id || msg_to_check.author.id == triccotricco_id || msg_to_check.author.id == lux_id || msg_to_check.author.id == xevery_id))
case 'k':
return (msg_to_check.author.id == koray_id)
}
}
function sched2time(sched_time){
sched_time = sched_time.split(" ");
return `${sched_time[2]}:${sched_time[1]}:${sched_time[0]}`;
}
function time2sched(time_normal){
time_normal = time_normal.split(":");
return `${time_normal[2]} ${time_normal[1]} ${time_normal[0]} * * *`;
}
//init
const client = new Client({
//intents: ["GUILDS", "GUILD_MESSAGES", /*"GUILD_INVITES",*/ "MESSAGE_CONTENT", "]
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.MessageContent
/*
"GUILDS",
"GUILD_MESSAGES",
"GUILD_MESSAGE_REACTIONS",
"DIRECT_MESSAGES",
"DIRECT_MESSAGE_REACTIONS"
*/
]
});
admin.initializeApp({
credential: admin.credential.cert(firebase)
});
const db = admin.firestore();
//fine init
client.on("error", (error) => console.log(error));
/* client.on('DiscordAPIError', (error) => console.log(error));
client.on('ReferenceError', (error) => console.log(error));
client.on('unhandledRejection', (error) => console.log(error));
client.on('UnhandledPromiseRejectionWarning', (error) => console.log(error)); */
client.on("ready", async () => {
// missions_file = (await db.collection('missions_files').doc('missions_file').get()).data();
users_plates = (await db.collection('others').doc('users_plates').get()).data();
daily_msg = (await db.collection('others').doc('daily_msg').get()).data();
crate = (await db.collection('crates_system').doc('crates').get()).data();
bdays_msgs = (await db.collection('others').doc('bdays-msgs').get()).data();
p = (await db.collection('others').doc('config').get()).data().prefix;
shadows_icon = (await db.collection('others').doc('config').get()).data().shadows_icon;
// console.log(missions_file['Valorant'])
// toup = JSON.parse(fs.readFileSync('./bck_firestore'));
// //console.log(toup);
// for(b in toup.missions_files){
// console.log(b+":",toup.missions_files[b]);
// db.collection('missions_files').doc(b).set(toup.missions_files[b]);
// }
// return
//Backup whole firestore database
collections = await db.listCollections();
file = "./bck_firestore";
fs.writeFileSync(file,`//Backup Cloud Firestore ${new Date()}\n\n`);
for (let collection of collections) {
//console.log(`"${collection.id}" :`);
fs.appendFileSync(file,`"${collection.id}" : {\n`);
map = await collection.get();
docs = map.docs;
docs.map(doc => {
fs.appendFileSync(file,`"${doc.id}"`)
fs.appendFileSync(file," : ")
fs.appendFileSync(file,JSON.stringify(doc.data(), null, '\t'))
fs.appendFileSync(file,",\n");
}
)
fs.appendFileSync(file,"\n},\n\n");
}
console.log("Firestore Backup finished");
// console.log("upload");
// pierpippo = require('./aaaaaaaa.json');
// console.log(pierpippo);
// await db.collection('missions_files').doc('missions_file').set(pierpippo);
// console.log("finish upload");
// return;
//Backup T.I.M.Warfare server
// try{
// timw_guild = await client.guilds.fetch(id_general_channel);
// dsbck.setStorageFolder('timw_bcks/');
// bck = await dsbck.create(timw_guild, {
// saveImage: "base64",
// jsonBeautify: true
// });
// console.log(bck);
// }catch(error){console.log(error)}
// return;
data_boot = new Date();
console.log(`Logged in as ${client.user.tag} at ${data_boot}.\n`+
`general: ${(id_general_channel == '218294724979720192') ? id_general_channel : id_general_channel + "\n\nWARNING!! Not TIMW's one\n\n"}\n`+
`missions: ${(id_missions_channel == '437961671018020864') ? id_missions_channel : id_missions_channel + "\n\nWARNING!! Not TIMW's one\n\n"}\n`+
`poll: ${(id_poll_channel == '437961671018020864') ? id_poll_channel : id_poll_channel + "\n\nWARNING!! Not TIMW's one\n\n"}\n`+
`covid: ${(id_covid_channel == '778566372333453312') ? id_covid_channel : id_covid_channel + "\n\nWARNING!! Not TIMW's one\n\n"}\n`+
`prefix: ${p}\n`+
`shadows_icon: ${shadows_icon}`
);
scheduler.scheduleJob(daily_msg.time_covid, async ()=>{
try {
var dow = new Date();
for (var d = new Date(dow.getDate() - 7); d <= dow; d.setDate(d.getDate() + 1)) {
var date = `${d.getFullYear()}${(d.getMonth()+1 <= 9)?"0"+(d.getMonth()+1):d.getMonth()+1}${(d.getDate() <= 9)?"0"+d.getDate():d.getDate()}`;
d.setDate(d.getDate()-1);
var datey =`${d.getFullYear()}${(d.getMonth()+1 <= 9)?"0"+(d.getMonth()+1):d.getMonth()+1}${(d.getDate() <= 9)?"0"+d.getDate():d.getDate()}`;
console.log(date+'\n'+datey);
var url_today_covid = `https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-andamento-nazionale/dpc-covid19-ita-andamento-nazionale-${date}.csv`;
var url_today_covidy = `https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-andamento-nazionale/dpc-covid19-ita-andamento-nazionale-${datey}.csv`;
//console.log(url_today_covid);
//console.log(url_today_covidy);
var csv = (await (await request_fetch(url_today_covid)).text());
var csvy = (await (await request_fetch(url_today_covidy)).text());
//console.log(csv);
//console.log(csvy);
csv = csv.split('\n')[1].split(',');
csvy = csvy.split('\n')[1].split(',');
//console.log(csv);
//console.log(csvy);
var cases = csv[13];
var newcases = csv[8];
var testst = csv[14];
var testsy = csvy[14];
var newtests = testst - testsy;
var perc = (newcases/newtests*100).toFixed(6);
var terint = csv[3];
var terinty = csvy[3];
var newterint = terint - terinty;
var deaths = csv[10];
var deathsy = csvy[10];
var newdeaths = deaths - deathsy;
//console.log(terint,terinty,newterint+'\n'+deaths,deathsy,newdeaths);
//console.log(newtests);
//console.log(newcases);
//console.log(perc);
//var msg_covid = `${newcases} nuovi casi, ${perc}% dei ${newtests} nuovi tamponi`;
var msg_covid = `casi totali: \`${cases}\` (${newcases > 0?"+":"-"}\`${Math.abs(newcases)}\`)\n`+
`positività: \`${perc}%\`\n`+
`tamponi: \`${testst}\` (${newtests > 0?"+":"-"}\`${Math.abs(newtests)}\`)\n`+
`morti: \`${deaths}\` (${newdeaths > 0?"+":"-"}\`${Math.abs(newdeaths)}\`)\n`+
`terapia intensiva: \`${terint}\` (${newterint > 0?"+":"-"}\`${Math.abs(newterint)}\`)`;
console.log(msg_covid);
(await client.channels.fetch(id_covid_channel)).send(msg_covid);
}
} catch(error) {
console.log(error);
(await client.users.fetch(koray_id)).send("no covid-19 report");
}
});
scheduler.scheduleJob({second: 0, minute: 40, hour: 6, dayOfWeek: 1}, async ()=>{
(await client.channels.fetch(id_missions_channel)).send('missions_activate_now').catch(console.error);
console.log('sent missions_activate_now command on '+new Date());
});
scheduler.scheduleJob({second: 0, minute: 40, hour: 6, dayOfWeek: [0, new scheduler.Range(2,6)]}, async ()=>{
(await client.channels.fetch(id_missions_channel)).send('daily_missions_activate_now').catch(console.error);
console.log('sent daily_missions_activate_now command on '+new Date());
});
scheduler.scheduleJob(daily_msg.time, async ()=>{
if(daily_msg.enabled === "true")
{
(await client.channels.fetch(daily_msg.channel.id)).send(daily_msg.messaggio.replace(/\\n/g, '\n'));
console.log(`sent daily_msg.`);
}
});
//natale
scheduler.scheduleJob('0 0 9 25 12 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.xmas));
console.log('sent merry xmas timw on '+new Date());
});
//buon anno
scheduler.scheduleJob('0 0 0 1 1 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.newyear));
console.log('sent happy new year timw on '+new Date());
});
//epifania
scheduler.scheduleJob('0 0 9 6 1 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.epiphany));
console.log('sent merry epiphany timw on '+new Date());
});
//pasqua //TODO
//scheduler.scheduleJob('0 0 9 6 1 *', async ()=>{
////// (await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.easter));
////// console.log('sent happy easter timw on '+new Date());
//});
//timw
scheduler.scheduleJob('0 0 9 27 3 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.timw));
console.log('sent best wishes timw on '+new Date());
});
//koray
scheduler.scheduleJob('0 30 8 17 5 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.koray));
console.log('sent best wishes koray on '+new Date());
});
//triccotricco
scheduler.scheduleJob('0 30 8 6 5 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.triccotricco));
console.log('sent best wishes triccotricco on '+new Date());
});
//lux
scheduler.scheduleJob('0 30 8 16 11 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.lux));
console.log('sent best wishes lux on '+new Date());
});
//xevery
scheduler.scheduleJob('0 30 8 15 1 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.xevery));
console.log('sent best wishes xevery on '+new Date());
});
//gu
scheduler.scheduleJob('0 30 8 14 11 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.gu));
console.log('sent best wishes gu on '+new Date());
});
//sowl
scheduler.scheduleJob('0 30 8 7 6 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.sowl));
console.log('sent best wishes sowl on '+new Date());
});
//creepraptor (creep)
scheduler.scheduleJob('0 30 8 26 10 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.creep));
console.log('sent best wishes creepraptor on '+new Date());
});
//wolf
scheduler.scheduleJob('0 30 8 24 8 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.wolf));
console.log('sent best wishes wolf on '+new Date());
});
//bosco
scheduler.scheduleJob('0 30 8 4 1 *', async ()=>{
(await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.bosco));
console.log('sent best wishes wolf on '+new Date());
});
//kirisu
//scheduler.scheduleJob('0 30 8 16 10 *', async ()=>{
// (await client.channels.fetch(id_general_channel)).send(eval(bdays_msgs.kirisu));
// console.log('sent best wishes kirisu on '+new Date());
//});
//cb (CB7356)
scheduler.scheduleJob('0 30 8 18 5 *', async ()=>{
(await client.users.fetch(cb_id)).send(eval(bdays_msgs.cb));
console.log('sent best wishes cb (in dm) on '+new Date());
});
//
//laurea lux
//scheduler.scheduleJob('0 30 8 8 11 2022', async ()=>{
// (await client.channels.fetch(id_general_channel)).send("@everyone\n\n:closed_book: Buona laurea <@"+lux_id+">!:closed_book:");
// console.log('sent laurea lux on '+new Date());
//});
scheduler.scheduleJob('0 0 10 3 5 *', async ()=>{
var adrecruit = new Date().getFullYear() - users_plates[koray_id].drecruit.match(/(?![0-9]{2}\/[0-9]{2}\/)[0-9]{4}/g).toString();
console.log("sent best wishes anniversary koray ("+adrecruit+" years) on "+new Date());
(await client.channels.fetch(id_general_channel)).send("@everyone\n\n:birthday: Buon anniversario di "+adrecruit+" anni nel T.I.M.W <@"+koray_id+">! :birthday:");
});
scheduler.scheduleJob('0 0 10 4 5 *', async ()=>{
var adrecruit = new Date().getFullYear() - users_plates[lux_id].drecruit.match(/(?![0-9]{2}\/[0-9]{2}\/)[0-9]{4}/g).toString();
console.log("sent best wishes anniversary lux ("+adrecruit+" years) on "+new Date());
(await client.channels.fetch(id_general_channel)).send("@everyone\n\n:birthday: Buon anniversario di "+adrecruit+" anni nel T.I.M.W <@"+lux_id+">! :birthday:");
});
scheduler.scheduleJob('0 0 10 27 3 *', async ()=>{
var adrecruit = new Date().getFullYear() - users_plates[triccotricco_id].drecruit.match(/(?![0-9]{2}\/[0-9]{2}\/)[0-9]{4}/g).toString();
console.log("sent best wishes anniversary triccotricco ("+adrecruit+" years) on "+new Date());
(await client.channels.fetch(id_general_channel)).send("@everyone\n\n:birthday: Buon anniversario di "+adrecruit+" anni nel T.I.M.W <@"+triccotricco_id+">! :birthday:");
});
scheduler.scheduleJob('0 0 10 25 4 *', async ()=>{
var adrecruit = new Date().getFullYear() - users_plates['426052055589978112'].drecruit.match(/(?![0-9]{2}\/[0-9]{2}\/)[0-9]{4}/g).toString();
console.log("sent best wishes anniversary xevery ("+adrecruit+" years) on "+new Date());
(await client.channels.fetch(id_general_channel)).send("@everyone\n\n:birthday: Buon anniversario di "+adrecruit+" anni nel T.I.M.W <@"+xevery_id+">! :birthday:");
});
scheduler.scheduleJob('0 59 7-23/2 * * *', async ()=>{
try{
bump_users = [
//luiemm_id,
bosco_id
];
for(u of bump_users) {
console.log(u);
user = (await client.users.fetch(u));
await user.send('ricordati di bumpare');
console.log('sent reminder bump to '+ u.tag +' ('+ u +') on '+new Date());
}
}catch(error){console.log(error)}
});
})
client.on('messageCreate', async message => {try{
// if(message.content == p+'provaprovetta'){
// var adrecruit = new Date().getFullYear() - users_plates['426052055589978112'].drecruit.match(/(?![0-9]{2}\/[0-9]{2}\/)[0-9]{4}/g).toString();
// console.log("sent best wishes anniversary xevery ("+adrecruit+" years) on "+new Date());
// (await client.channels.fetch(id_general_channel)).send("@everyone\n\n:birthday: Buon anniversario di "+adrecruit+" anni nel T.I.M.W <@"+xevery_id+">! :birthday:");
// }
//console.log("'message' event received");
if(message.content.startsWith(p+'give-sh')) { // p+give-sh @user d 1
if(check_perms(message,'g')){
if(u = message.mentions.parsedUsers.first()) {
m = message.content.split(" ");
message.delete().then(msg => {var d = Date(); console.log(`Deleted /give-sh message from ${msg.author.username} at ${d}`)}).catch(console.error);
mss_msg_ids = (await db.collection('missions_files').doc('missions').get()).data(); //mss = mission, msg = message
let s;
let b;
//if(m[2] == 'd') s = parseInt(mss_msg.embeds[0].fields[m[3]].name.split(' - ').pop().split(" ")[0]);
//else if(m[2] == 'w') s = parseInt(mss_msg.embeds[0].fields[m[3]].name.split(' - ').pop().split(" ")[0]);
try {
if(m[2] == 'w') {
mss_msg = await (await client.channels.fetch(id_missions_channel)).messages.fetch(mss_msg_ids.id);
s = mss_msg.embeds[0].fields[m[3]];
b = arr_prizes[m[3]];
member = message.mentions.members.find(e => e.id == u.id);
if(member.roles.cache.some(e => e.id == id_premium_avanzato)) b += 400;
}
else if(m[2] == 'd'){
mss_msg = await (await client.channels.fetch(id_missions_channel)).messages.fetch(mss_msg_ids.daily_id);
s = mss_msg.embeds[0].fields[m[3]];;
b = 400;
member = message.mentions.members.find(e => e.id == u.id);
if(member.roles.cache.some(e => e.id == id_premium_avanzato)) b += 200;
}
}catch(error) {
console.log(error);
}
// redo with arr_prizes
unb.editUserBalance(id_timw, u.id,
{
cash: 0,
bank: b
},
`give ${b} shadows to <@${u.id}> for mission ${m[2]} ${m[3]}`
)
message.channel.send(`Grazie <@${u.id}> per aver completato la missione\n> ${s.name}\n> ${s.value}\nti sono stati aggiunti in banca ${b} ${shadows_icon}!`);
}
}
}
if(message.content.startsWith(p+'scam')){
if(check_perms(message,'a')){
scam_msg = await message.channel.messages.fetch(message.content.split(' ')[1]);
(await message.guild.members.fetch(scam_msg.author)).kick("Scam: "+scam_msg.content);
console.log("Scam content:"+scam_msg.content);
(await client.users.fetch(koray_id)).send(`${Date()}: deleted \`\`\`${scam_msg.content}\`\`\` from ${scam_msg.author.tag} (${scam_msg.author.id})`);
await scam_msg.delete();
delete_all_scam();
}
}
if(message.content == p+'status-verbose'){
daily_msg = (await db.collection('others').doc('daily_msg').get()).data();
users_plates = (await db.collection('others').doc('users_plates').get()).data();
var ncards = 0;
for(key in users_plates) ncards++;
message.channel.send(`Daily message status: \`${(daily_msg.enabled == "false")?"off":"on"}\`\n`+
`Daily message channel: <#${daily_msg.channel.id}>\n`+
`Daily message time: \`${sched2time(daily_msg.time)}\`\n`+
//`Daily covid-19 update time: \`${sched2time(daily_msg.time_covid)}\`\n`+
`Daily message: \`\`\`${daily_msg.messaggio}\n\`\`\``+
`User with cards (\`/card list\`): \`${ncards}\`\n`+
`Prefix: \`${p}\`\n`
);
}
if(message.content == p+'status'){
daily_msg = (await db.collection('others').doc('daily_msg').get()).data();
users_plates = (await db.collection('others').doc('users_plates').get()).data();
var ncards = 0;
for(key in users_plates) ncards++;
message.channel.send(`Daily message status: \`${(daily_msg.enabled == "false")?"off":"on"}\`\n`+
`User with cards (\`/card list\`): \`${ncards}\`\n`+
`Prefix: \`${p}\`\n`
);
}
if(message.content.startsWith(p+'edit-mission ')){
// NO //syntax: /edit-mission [game] [new mission] OR /edit-mission [game] s/ [pattern to subtitute] [subtitute with]
//syntax: /edit-mission [pattern to subtitute] [subtitute with]
if(check_perms(message,'a')){
m = shlex.split(message.content);
message.delete().then(msg => {var d = Date(); console.log(`Deleted /edit-mission message from ${msg.author.username} at ${d}`)}).catch(console.error);
//console.log(m);
patt = m[1];
sub = m[2];
if(!patt||!sub) message.channel.send('Incorrect usage.')
channel_missions_id = id_missions_channel;
id_missions = (await db.collection('missions_files').doc('missions').get()).data().id;
console.log(id_missions);
old_msg = await (await client.channels.fetch(channel_missions_id)).messages.fetch(id_missions);
emb = old_msg.embeds[0];
new_msg = JSON.parse(JSON.stringify(emb).replace(patt, sub));
console.log("old:",old_msg.embeds[0]);
console.log("new:",new_msg);
if(ok == true){
old_msg.edit(ren([new_msg]))
}
}
}
if(message.content.startsWith(p+'move')){
cur_msg = message;
message.delete().then(msg => {var d = Date(); console.log(`Deleted /move message from ${msg.author.username} at ${d}`)}).catch(console.error);
if(check_perms(cur_msg,'a') || check_perms(cur_msg,'k')){
m_split = cur_msg.content.split(' ');
cur_guild = cur_msg.guild;
if(cur_msg.mentions.members.first()){
ment = (await cur_msg.mentions.members.first());
console.log(ment.user.tag);
}else if(m_split[1]){
if(m_split[1].trim().match('[0-9]{18}')){
ment = (await cur_guild.members.resolve(m_split[1].trim()));
console.log(ment.user.tag);
}else{
cur_msg.author.send("Couldn't find the user. @mention it or use the id");
return;
}
}else if(!m_split[1]){
cur_msg.author.send("No user specified. @mention it or use the id");
return;
}
ment = ment.voice;
cur_channel = ment.channel;
afk_channel = cur_guild.afkChannel;
for(move_int=0;move_int < 5;move_int++){
console.log('/move cyle n:'+move_int);
await ment.setChannel(afk_channel);
await ment.setChannel(cur_channel);
}
console.log("/move finished");
}else{
cur_msg.author.send("You can't use this command");
}
}
if(message.content.startsWith(p+'scheda') || message.content.startsWith(p+'card')) {
users_plates = (await db.collection('others').doc('users_plates').get()).data();
var lista = '>>> ';
if(message.content == '/scheda list' || message.content == '/card list'){
for(key in users_plates) {
lista += `- **${(await client.users.fetch(key)).tag}**\n`;
}
message.channel.send(lista);
} else {
var mentioned_user = message.mentions.members.first();
if(!mentioned_user){
message.channel.send("Invalid user.\nUse `/help` to see a list of all the avaiable commands.");
} else {
Master_Role = mentioned_user.roles.highest;
Squad_Role = mentioned_user.roles.cache.find(role => role.name.match(/TIMW-/g));
Level_Role = mentioned_user.roles.cache.find(role => role.name.match(/[A-Z]+\s*\|\sLEGGENDA\s*\[[0-9]+-[0-9]+\]/g));
if(!Master_Role){
Master_Role = {"name":'N/A'};
}
if(!Squad_Role){
Squad_Role = {"name":'N/A'};
}
if(!Level_Role){
Level_Role = {"name":'N/A'};
}
if(!users_plates[mentioned_user.id]) {
message.channel.send(mentioned_user.user.tag+" doesn't have a player card.");
} else {
message.channel.send(`-**SCHEDA GIOCATORE**: *${users_plates[mentioned_user.id].name}*\n\n`
+`-**RUOLO**: *${Master_Role.name}*\n`
+`-**LIVELLO**: *${Level_Role.name.slice(0,5).trim()}*\n`
+`-**ALLENATORE**: *${users_plates[mentioned_user.id].trainer}*\n`
+`-**SQUADRE**: *${Squad_Role.name}*\n`
+`-**STATO**: *${users_plates[mentioned_user.id].state}*\n`
+`-**DATA DI RECLUTAMENTO**: *${users_plates[mentioned_user.id].drecruit}*\n`
+`-**ARMA PREFERITA**: *${users_plates[mentioned_user.id].fav_gun}*\n`
+`-**GIOCO PREFERITO**: *${users_plates[mentioned_user.id].fav_cod}*\n`
+`-**KILLSTREAK PIU' ALTA**: *${users_plates[mentioned_user.id].hkstreak}*\n`
).catch(console.error);
console.log(mentioned_user.user.tag+" ("+mentioned_user.nickname+") scheda in "+message.channel.name+" by "+message.author.tag);
}
}
}
}
if(message.content == p+'cit' || message.content == p+'CIT' || message.content == p+'Cit' || message.content == p+'quote' || message.content == p+'QUOTE' || message.content == p+'Quote' || message.content == p+'citazione' || message.content == p+'CITAZIONE' || message.content == p+'Citazione') {
const citazioni = ["Galassie", "Pianeti", "It's time of T.I.M.Warfare"/*, "", "", "", ""*/];
var numero = Math.floor(Math.random() * 3);
var citt = citazioni[numero];
message.channel.send(citt);
console.log(`sent citazione nr: ${numero}, citazione: ${citt}`);
}
if((message.content.match(/\b[^0-9]*69[^0-9]*\b/) || message.content.match(/\b[^0-9]*420[^0-9]*\b/)) && message.content.length < 5){
message.channel.send("Nice");
}
if((message.content.match(/\b[^0-9]*69420[^0-9]*\b/) || message.content.match(/\b[^0-9]*42069[^0-9]*\b/)) && message.content.length < 10){
message.channel.send("**Noice**");
}
if(message.mentions.users.find(u=>u.id == bot_id) || (message.channel.type == ChannelType.DM && message.author.id != bot_id)) {
m = message.content.split(/\s+/);
regex_foreach = new RegExp('<(@!|@)'+bot_id+'>');
m.forEach((e,i,ar)=>{if(e.match(regex_foreach)) {ar.splice(i,1);console.log(ar)}});
console.log("pop:"+m[0]);
part = m[0].trim();
min_len = 1;
//if(message.channel.type == ChannelType.DM) min_len = 1;
//else min_len = 1;
//console.log(message.channel.type,min_len,m.length);
//thanking
if((/grz/i).test(m) && m.length >= min_len){
a=["Di nulla","Prego","Di niente","Nessun problema"];
r=rn(a)+((Math.floor(Math.random()*15)==Math.floor(Math.random()*10))?" (Anche se si scrive 'grazie')":''); //1 volta ogni 25 'grz' aka 4% di probabilità
message.reply(r);
console.log("'"+message.content+"' from "+message.author.id+"; grz ans: '"+r+"'");
}
else if((/grazie/i).test(m) && m.length >= min_len){
a=["Di nulla","Prego","Di niente","Nessun problema"];
r=rn(a);
message.reply(r);
console.log("'"+message.content+"' from "+message.author.id+"; grazie ans: '"+r+"'");
}else if((/thank/i).test(m) && m.length >= min_len){
a=["No problem","You're welcome"];
r=rn(a);
message.reply(r);
console.log("'"+message.content+"' from "+message.author.id+"; thank ans: '"+r+"'");
}else if((/ty|thx/i).test(m) && m.length >= min_len){
message.reply('np');
console.log("'"+message.content+"' from "+message.author.id+"; tythx ans: 'np'");
}
//thanking is no more
else if((/ciao|^h(ey|i)$|he(ll|l)o/i).test(m) && min_len == min_len){
if(m.length == min_len) {
if((/ciao/i).test(m)){
message.channel.send("Ciao "+message.author.username);
console.log("sent 'Ciao "+message.author.username+"'");
}else if((/^h(ey|i)$|he(ll|l)o/i).test(m)){