-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
3469 lines (3045 loc) · 107 KB
/
main.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
/*
Base Ori Rahman x Ifaa karisma x Icha Maulidah Putri
const sc = require("scripts/scnya")
Script ulang by aulia rahman
Base bot telegram node js
const script = require("sc/botnya")
// FIXED CPANEL TELE
// MASIH PROSES NAMBAH FITUR
INFO GROUP & BC & HIDETAG BELUM WORK, JIKA MAU NGEFIXEDNYA CHAT LANGSUNG KE TELE PEMILIKNYA
PERHATIKAN :: ERROR DI MUTE & UNMUTE JIKA MAU FIXED BOTNYA TAMBAHIN NAMA LU DI THANKS TO, TAPI INGAT JANGAN DI APUS JUGA YA
Sosmed media :
Ig : @4xglrs_
Tele : @idstore74pw & @girlchaw @idstore74_pw
Wa : Privet
Yt : A. Aulia Rahman Official (@auliarhmanproduction)
Thanks too::
Allah swt
Nabi Muhammad
Aulia Rahman
Ifaa karisma
Icha Maulidah Putriii
Zeeone Ofc
WanOfc
And Pengguna Copy/Paste:v
Note : don't remove copyright of this script!
*/
require("./settings")
const {
Telegraf,
Context,
Markup
} = require('telegraf')
const {
simple
} = require("./lib/myfunc")
const tele = require('./lib/tele')
const obfuscateCode = require('./lib/toolsobf')
const fs = require('fs')
const chalk = require('chalk')
const moment = require('moment-timezone')
const os = require('os')
const speed = require('performance-now')
const axios = require('axios')
if (BOT_TOKEN == 'YOUR_TELEGRAM_BOT_TOKEN') {
return console.log("tidak ada token")
}
const { Client } = require('ssh2');
global.api = (name, path = '/', query = {}, apikeyqueryname) => (name in global.APIs ? global.APIs[name] : name) + path + (query || apikeyqueryname ? '?' + new URLSearchParams(Object.entries({
...query,
...(apikeyqueryname ? {
[apikeyqueryname]: global.APIKeys[name in global.APIs ? global.APIs[name] : name]
} : {})
})) : '')
const OWNER_ID = global.owneridlu; // Change owner your id
const adminfile = 'lib/adminID.json';
const premiumUsersFile = 'lib/premiumUsers.json';
try {
premiumUsers = JSON.parse(fs.readFileSync(premiumUsersFile));
} catch (error) {
console.error('Error reading premiumUsers file:', error);
}
try {
adminUsers = JSON.parse(fs.readFileSync(adminfile));
} catch (error) {
console.error('Error reading adminUsers file:', error);
}
// Initialize userSessions
let userSessions = {};
const domain = global.domain;
const plta = global.plta;
const pltc = global.pltc;
async function uploadToCdn(Path) {
return new Promise(async (resolve, reject) => {
if (!fs.existsSync(Path)) return reject(new Error("File tidak ditemukan."));
try {
const form = new BodyForm();
form.append("file", fs.createReadStream(Path));
const response = await axios({
url: "https://cdn.meitang.xyz/upload",
method: "POST",
headers: {
...form.getHeaders()
},
data: form
});
return resolve(response.data.file.url)
} catch (err) {
return reject(new Error(`Gagal upload: ${err.message}`));
}
});
}
function getTargetUserId(Ifaa) {
const replyMessage = Ifaa.message.reply_to_message;
if (replyMessage && replyMessage.from && replyMessage.from.id) {
return replyMessage.from.id;
}
return null;
}
async function checkAdmin(Ifaa) {
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.from.id);
return chatMember && (chatMember.status === 'administrator' || chatMember.status === 'creator');
}
const bot = new Telegraf(BOT_TOKEN)
async function startIfaa() {
bot.on('callback_query', async (Ifaa) => {
// Split the action and extract user ID
const action = Ifaa.callbackQuery.data.split(' ');
const user_id = Number(action[1]);
// Check if the callback is from the correct user
if (Ifaa.callbackQuery.from.id !== user_id) {
return Ifaa.answerCbQuery('Uppss... this button not for you!', {
show_alert: true
});
}
const timestampi = speed();
const latensii = speed() - timestampi;
const user = simple.getUserName(Ifaa.callbackQuery.from);
const pushname = user.full_name;
const username = user.username ? user.username : "Ifaa";
const isCreator = [Ifaa.botInfo.username, ...global.OWNER].map(v => v.replace("https://t.me/", '')).includes(username);
const opts = { parse_mode: 'MARKDOWN' };
const parseMarkdown = (text) => {
text = text.replace(/(\[[^\][]*]\(http[^()]*\))|[_*[\]()~>#+=|{}.!-]/gi, (x, y) => y ? y : '\\' + x)
return text
}
const range = function range(start, stop, step) {
if (typeof stop == 'undefined') {
// one param defined
stop = start;
start = 0;
}
if (typeof step == 'undefined') {
step = 1;
}
if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
return [];
}
var result = [];
for (var i = start; step > 0 ? i < stop : i > stop; i += step) {
result.push(i);
}
return result;
}
const reply = async (text) => {
for (let x of simple.range(0, text.length, 4096)) { // Split text to avoid overflow
await Ifaa.replyWithMarkdown(text.substr(x, 4096), {
disable_web_page_preview: true
});
}
};
const downloadMediaMessage = async (message) => {
let mime = (message.Ifaa || message).mimetype || ''
let messageType = message.mtype ? message.mtype.replace(/Message/gi, '') : mime.split('/')[0]
const stream = await downloadContentFromMessage(message, messageType)
let buffer = Buffer.from([])
for await (const chunk of stream) {
buffer = Buffer.concat([buffer, chunk])
}
return buffer
}
const downloadAndSaveMediaMessage = async (message, filename, attachExtension = true) => {
let quoted = message.Ifaa ? message.Ifaa : message
let mime = (message.Ifaa || message).mimetype || ''
let messageType = message.mtype ? message.mtype.replace(/Message/gi, '') : mime.split('/')[0]
const stream = await downloadContentFromMessage(quoted, messageType)
let buffer = Buffer.from([])
for await (const chunk of stream) {
buffer = Buffer.concat([buffer, chunk])
}
let type = await FileType.fromBuffer(buffer)
trueFileName = attachExtension ? (filename + '.' + type.ext) : filename
// save to file
await fs.writeFileSync(trueFileName, buffer)
return trueFileName
}
try {
switch (action[0]) {
case "mymenu": case "menu": {
const sender = Ifaa.from.username;
lang.help(Ifaa, sender, isCreator, user_id.toString())
}
break
case "islamimenu": {
lang.islami(Ifaa, user_id.toString())
}
break
case "cpanelmenu": {
lang.cpanelmenu(Ifaa, user_id.toString())
}
break
case "movie": {
lang.movie(Ifaa, user_id.toString())
}
break
case "downloadmenu": {
lang.downloadmenu(Ifaa, user_id.toString())
}
break
case "randtext": {
lang.randtext(Ifaa, user_id.toString())
}
break
case "ephoto": {
lang.ephoto(Ifaa, user_id.toString())
}
break
case "obfmenu": {
lang.obfmenu(Ifaa, user_id.toString())
}
break
case "groupmenu": {
lang.groupmenu(Ifaa, user_id.toString())
}
break
case "ownermenu": {
lang.ownermenu(Ifaa, user_id.toString())
}
break
case "mainmenu": {
lang.mainmenu(Ifaa, user_id.toString())
}
break
}
} catch (e) {
console.log(e)
}
})
bot.command('start', async (Ifaa) => {
let user = simple.getUserName(Ifaa.message.from)
await Ifaa.reply(lang.first_chat(BOT_NAME, user.full_name), {
parse_mode: "MARKDOWN",
disable_web_page_preview: true,
reply_markup: {
inline_keyboard: [
[{
text: 'My Owner',
url: "https://t.me/idstore74_pw"
}, {
text: 'My Telegram',
url: "https://t.me/cecancgroup"
}],
[{
text: 'My Website',
url: "https://idstore74.pw"
}]
]
}
})
})
//=============== BATAS MENU 2 ===============\\
bot.command('menu2', async(Ifaa) => {
Ifaa.reply(`Silahkan pilih salah satu button dibawah ini`, {
reply_markup: {
keyboard: [
[
{text: 'Cpanel Menu'},
{text: "Islami Menu"},
{text: "Random Text"}
],
[
{text: "Download Menu"},
{text: "Ephoto Menu"},
{text: "Movie Menu"}
],
[
{text: 'Remove keyboard!!'}
]
]
}
})
})
bot.hears('Islami Menu', async(Ifaa) => {
Ifaa.reply(`Silahkan pilih salah satu menu dibawah ini`, {
reply_markup: {
keyboard: [
[
{ text: 'List surah' },
{ text: 'Al Quran' },
{ text: 'Quran Audio' }
],
[
{ text: 'Asmaul Husna' },
{ text: 'Kisah Nabi' },
{ text: 'Jadwal Sholat' }
],
[
{text: 'Remove keyboard!!'}
]
]
}
})
})
bot.hears('Cpanel Menu', async(Ifaa) => {
Ifaa.reply(`Silahkan pilih salah satu menu dibawah ini`, lang.cpanelmenu(Ifaa), {
reply_markup: {
keyboard: [
[
{text: 'List Panel'},
{text: 'Buat Panel'},
{text: 'List Admin'}
],
[
{text: 'List Server'},
{text: 'Cek id'}
],
[
{text: 'Kembali Ke Menu Utama'}
],
[
{text: 'Remove keyboard!!'}
]
]
}
})
})
bot.hears('Random Text', async(Ifaa) => {
Ifaa.reply(`Silahkan pilih salah satu menu dibawah ini`, lang.randtext(Ifaa), {
reply_markup: {
keyboard: [
[
{text: 'Qoutes', callback_data: 'quotes'},
{text: 'Quotes Dilan', callback_data: 'quotesdilan'},
{text: 'Quotes Anime', callback_data: 'quotesanime'},
],
[
{text: 'Quotes Image', callback_data: 'quotesimage'},
{text: 'Fakta Unik', callback_data: 'faktaunik'},
{text: 'Kata Bijak', callback_data: 'katabijak'},
{text: 'Pantun', callback_data: 'pantun'},
],
[
{text: 'Apakah', callback_data: 'apakah'},
{text: 'Bisakah', callback_data: 'bisakah'},
{text: 'Kapankah', callback_data: 'kapankah'},
{text: 'Dox', callback_data: 'dox'},
],
[
{text: 'Bucin', callback_data: 'bucin'},
{text: 'Randomnama', callback_data: 'randommenu'},
{text: 'Remove keyboard!!'}
]
]
}
})
})
bot.hears('Kembali Ke Menu Utama', async(Ifaa) => {
Ifaa.reply(`Silahkan pilih salah satu button dibawah ini`, {
reply_markup: {
keyboard: [
[
{text: 'Cpanel Menu'},
{text: "Islami Menu"},
{text: "Random Text"}
],
[
{text: "Download Menu"},
{text: "Ephoto Menu"},
{text: "Movie Menu"}
],
[
{text: 'Remove keyboard!!'}
]
]
}
})
})
//=============== COMMAND PERINTAH ==============\\
// hahahha capek coyyy🙄
// yauda lanjutin aja🙄
// Command action seperti hatiku😋
bot.action('bucin', async (Ifaa) => {
Ifaa.deleteMessage().catch(() => {});
result = await fetchJson(`https://api.lolhuman.xyz/api/random/${command}?apikey=${apikey}`)
await reply(result.result)
})
// Command Bot🙄
// Group Feature
/*bot.command('hidetag', async (Ifaa) => { // GA WORK, KALAU MAU FIXED AJA
const isAdmin = Ifaa.message.chat.type === 'group' || Ifaa.message.chat.type === 'supergroup' ? await bot.telegram.getChatMember(Ifaa.message.chat.id, Ifaa.message.from.id).then(member => member.status === 'administrator' || member.status === 'creator') : false;
if (!isAdmin && !isCreator) {
Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
return;
}
const message = Ifaa.message.text.split(' ').slice(1).join(' ');
const members = await bot.telegram.getChatMembersCount(Ifaa.message.chat.id);
const userIds = [];
for (let i = 0; i < Math.ceil(members / 200); i++) {
const memberIds = await bot.telegram.getChatAdministrators(Ifaa.message.chat.id);
memberIds.forEach(member => {
if (!member.user.is_bot) {
userIds.push(member.user.id);
}
});
}
try {
userIds.forEach(userId => {
bot.telegram.sendMessage(Ifaa.message.chat.id, `[\u200c](tg://user?id=${userId})${message}`, { parse_mode: 'MarkdownV2' });
});
} catch (error) {
console.error('Error sending message:', error);
Ifaa.reply('An error occurred while sending the message.');
}
});*/
bot.command('mute', async (Ifaa) => {
const targetUserId = Ifaa.message.text.split(' ');
const duration = Ifaa.message.text.split(' ')[2] || 3600; // Default 1 jam
const chatAdmins = await Ifaa.getChatAdministrators(Ifaa.chat.id);
const chatId = Ifaa.chat.id;
const senderId = Ifaa.from.id.toString();
const isAdmin = chatAdmins.some(admin => admin.user.id.toString() === senderId && (admin.status === 'creator' || admin.status === 'administrator'));
if (isAdmin) {
Ifaa.telegram.restrictChatMember(chatId, targetUserId, {
can_send_messages: false,
until_date: Math.floor(Date.now() / 1000) + parseInt(duration)
}).then(() => {
Ifaa.reply(`Pengguna dengan ID ${targetUserId} telah dibisukan selama ${duration} detik.`);
});
} else {
Ifaa.reply('Anda tidak memiliki izin untuk memblokir pengguna.');
}
});
bot.command('unmute', async (Ifaa) => {
const chatAdmins = await Ifaa.getChatAdministrators(Ifaa.chat.id);
const chatId = Ifaa.chat.id;
const senderId = Ifaa.from.id.toString();
const isAdmin = chatAdmins.some(admin => admin.user.id.toString() === senderId && (admin.status === 'creator' || admin.status === 'administrator'));
if (isAdmin) {
const targetUserId = Ifaa.message.text.split(' ')[1];
Ifaa.telegram.restrictChatMember(chatId, targetUserId, {
can_send_messages: true
}).then(() => {
Ifaa.reply(`Pengguna dengan ID ${targetUserId} telah dibebaskan.`);
});
}
});
/*bot.command('leave', async (Ifaa) => {
if (Ifaa.chat.type === 'supergroup' || Ifaa.chat.type === 'group') {
const chatAdmins = await Ifaa.getChatAdministrators(Ifaa.chat.id);
const senderId = Ifaa.from.id.toString();
const isAdmin = chatAdmins.some(admin => admin.user.id.toString() === senderId && (admin.status === 'creator' || admin.status === 'administrator'));
if (!isAdmin) {
Ifaa.reply('Fitur Ini Khusus Untuk Admin Group, Atau Owner saya!');
return;
}
if (Ifaa.from.id === global.owneridlu) {
Ifaa.telegram.leaveChat(Ifaa.chat.id)
}
}
})*/
bot.command('kick', async (Ifaa) => {
if (Ifaa.chat.type === 'supergroup' || Ifaa.chat.type === 'group') {
const chatAdmins = await Ifaa.getChatAdministrators(Ifaa.chat.id);
const botInfo = await Ifaa.telegram.getMe();
const botId = botInfo.id;
const userId = Ifaa.from.id;
const isBotAdmin = chatAdmins.some(admin => admin.user.id === botId);
if (!isBotAdmin) {
Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
return;
}
const targetUserId = Ifaa.message.text.split(' ');
const senderId = Ifaa.from.id.toString();
const isAdmin = chatAdmins.some(admin => admin.user.id.toString() === senderId && (admin.status === 'creator' || admin.status === 'administrator'));
if (!isAdmin) {
Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
return;
}
if (isAdmin) {
Ifaa.telegram.kickChatMember(Ifaa.chat.id, targetUserId).then(() => {
Ifaa.reply(`Pengguna dengan ID ${targetUserId} telah dikick.`);
});
} else {
Ifaa.reply('Anda tidak memiliki izin untuk mengeluarkan pengguna.');
}
}
});
bot.command('del', async (Ifaa) => {
if (Ifaa.chat.type === 'supergroup' || Ifaa.chat.type === 'group') {
const botInfo = await Ifaa.telegram.getMe();
const botId = botInfo.id;
const chatAdmins = await Ifaa.getChatAdministrators(Ifaa.chat.id);
const isBotAdmin = chatAdmins.some(admin => admin.user.id === botId);
if (!isBotAdmin) {
await Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
return;
}
try {
const messageId = Ifaa.message.message_id;
await Ifaa.telegram.deleteMessage(Ifaa.chat.id, messageId);
} catch (error) {
console.error('Error:', error);
await Ifaa.reply('An error occurred while deleting the message.');
}
const replyMessage = Ifaa.message.reply_to_message;
if (!replyMessage) {
await Ifaa.reply('Use the /delete command to reply to the message you want to delete.');
return;
}
const senderId = Ifaa.from.id.toString();
const isAdmin = chatAdmins.some(admin => admin.user.id.toString() === senderId && (admin.status === 'creator' || admin.status === 'administrator'));
if (!isAdmin) {
await Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
return;
}
try {
await Ifaa.telegram.deleteMessage(Ifaa.chat.id, replyMessage.message_id);
} catch (error) {
console.error('Error:', error);
await Ifaa.reply('An error occurred while deleting the message.');
}
} else if (Ifaa.chat.type === 'private') {
try {
const messageId = Ifaa.message.message_id;
await Ifaa.telegram.deleteMessage(Ifaa.chat.id, messageId);
} catch (error) {
console.error('Error:', error);
await Ifaa.reply('An error occurred while deleting the message.');
}
} else {
await Ifaa.reply('This command can only be used in a group or private chat.');
}
});
bot.command('pin', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.botInfo.id);
if (!chatMember || chatMember.status !== 'administrator') {
return Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
}
const repliedMessage = Ifaa.message.reply_to_message;
if (!repliedMessage) {
return Ifaa.reply('Please reply to the message you want to pin in the group.');
}
try {
await Ifaa.telegram.pinChatMessage(Ifaa.chat.id, repliedMessage.message_id, { disable_notification: true });
return Ifaa.reply('The message was successfully pin in the group.');
} catch (error) {
console.error('Failed to pin message in group:', error);
return Ifaa.reply('Failed to pin message in group.');
}
});
bot.command('unpin', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.botInfo.id);
if (!chatMember || chatMember.status !== 'administrator') {
return Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
}
try {
await Ifaa.telegram.unpinChatMessage(Ifaa.chat.id);
return Ifaa.reply('Message successfully unpin from group.');
} catch (error) {
console.error('Failed to unpin message from group:', error);
return Ifaa.reply('Failed to unpin message from group.');
}
});
bot.command('setdesc', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.botInfo.id);
if (!chatMember || chatMember.status !== 'administrator') {
return Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const commandParts = Ifaa.message.text.split(' ');
commandParts.shift();
const newDescription = commandParts.join(' ');
if (!newDescription.trim()) {
return Ifaa.reply('Description cannot be empty.');
}
try {
await Ifaa.telegram.setChatDescription(Ifaa.chat.id, newDescription);
return Ifaa.reply('The group description was changed successfully.');
} catch (error) {
console.error('Failed to change group description:', error);
return Ifaa.reply('Failed to change group description.');
}
});
bot.command('setppgc', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.botInfo.id);
if (!chatMember || chatMember.status !== 'administrator') {
return Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const repliedMessage = Ifaa.message.reply_to_message;
if (!repliedMessage || !repliedMessage.photo) {
return Ifaa.reply('Please reply with the image you want to use as the group profile photo.');
}
const photo = repliedMessage.photo[repliedMessage.photo.length - 1];
try {
const photoInfo = await Ifaa.telegram.getFile(photo.file_id);
const photoUrl = `https://api.telegram.org/file/bot${botToken}/${photoInfo.file_path}`;
await Ifaa.telegram.setChatPhoto(Ifaa.chat.id, { url: photoUrl });
return Ifaa.reply('The group profile photo has been successfully changed.');
} catch (error) {
console.error('Failed to change group profile photo:', error);
return Ifaa.reply('Failed to change group profile photo.');
}
});
bot.command('promote', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.botInfo.id);
if (!chatMember || chatMember.status !== 'administrator') {
return Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const targetUserId = getTargetUserId(Ifaa);
if (!targetUserId) {
return Ifaa.reply('Please reply to the message of the user you want to make admin and use the /promote command.');
}
const chatId = Ifaa.message.chat.id;
try {
await Ifaa.telegram.promoteChatMember(chatId, targetUserId, {
can_change_info: true,
can_delete_messages: true,
can_invite_users: true,
can_restrict_members: true,
can_pin_messages: true,
can_promote_members: false,
});
return Ifaa.reply('User has been promote as admin.');
} catch (error) {
console.error('Failed to promote users:', error);
return Ifaa.reply('Failed to promote users.');
}
});
bot.command('demote', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.botInfo.id);
if (!chatMember || chatMember.status !== 'administrator') {
return Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const targetUserId = getTargetUserId(Ifaa);
if (!targetUserId) {
return Ifaa.reply('Please reply to the message of the user you want to demote as admin and use the /demote command.');
}
const chatId = Ifaa.message.chat.id;
try {
await Ifaa.telegram.promoteChatMember(chatId, targetUserId, {
can_change_info: false,
can_delete_messages: false,
can_invite_users: false,
can_restrict_members: false,
can_pin_messages: false,
can_promote_members: false,
});
return Ifaa.reply('Admin has been demote.');
} catch (error) {
console.error('Failed to demote admin:', error);
return Ifaa.reply('Failed to demote admin.');
}
});
bot.command('createpoll', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const pollArgs = Ifaa.message.text.split(';');
const question = pollArgs[1];
const options = pollArgs.slice(2);
if (options.length < 2) {
return Ifaa.reply('Polls must have at least two options.');
}
const keyboard = {
inline_keyboard: options.map((option) => [{ text: option, callback_data: option }])
};
return Ifaa.telegram.sendPoll(Ifaa.message.chat.id, question, options, { reply_markup: keyboard });
});
bot.command('infogroup', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const chatId = Ifaa.message.chat.id;
const chatInfo = await Ifaa.telegram.getChat(chatId);
const membersCount = await Ifaa.telegram.getChatMembersCount(chatId);
const adminList = await Ifaa.telegram.getChatAdministrators(chatId);
const adminNames = adminList.map(admin => admin.user.username).join(', ');
let photo = '';
if (chatInfo.photo) {
photo = chatInfo.photo.big_file_id;
} else {
photo = 'AgACAgIAAxkBAAIBomE9MfM-NCaU-UeritVgN-gouSYKAAJysTEbs8S5SswybVqdfl3H--mjli4AAwEAAwIAA3gAA5FpAAIfBA'; // PP kosong
}
let message = `
Information about the group:
- Group Name: ${chatInfo.title}
- Group Description: ${chatInfo.description ? chatInfo.description : 'No description.'}
- Group Link: ${chatInfo.invite_link ? chatInfo.invite_link : 'No Link.'}
- Group ID: ${chatId}
- Group Type: ${chatInfo.type}
- Number of Members: ${membersCount}
- Group Admins: ${adminNames}
`;
Ifaa.replyWithPhoto(photo, { caption: message });
});
bot.command('linkgc', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
try {
const inviteLink = await Ifaa.telegram.exportChatInviteLink(Ifaa.message.chat.id);
Ifaa.reply('Group invite link: ' + inviteLink);
} catch (error) {
console.error('Error while getting group link:', error);
Ifaa.reply('An error occurred while getting the group invite link.');
}
});
bot.command('setnamegc', async (Ifaa) => {
if (!Ifaa.message.chat.type || (Ifaa.message.chat.type !== 'group' && Ifaa.message.chat.type !== 'supergroup')) {
return Ifaa.reply('Fitur Ini Khusus Untuk Group!');
}
const isAdmin = await checkAdmin(Ifaa);
if (!isAdmin) {
return Ifaa.reply('Fitur Ini Khusus Untuk Admin Group!');
}
const chatMember = await Ifaa.telegram.getChatMember(Ifaa.chat.id, Ifaa.botInfo.id);
if (!chatMember || chatMember.status !== 'administrator') {
return Ifaa.reply('Bot Harus Menjadi Admin Terlebih Dahulu!');
}
const chatId = Ifaa.message.chat.id;
const newName = Ifaa.message.text.split(' ').slice(1).join(' ');
try {
await Ifaa.telegram.setChatTitle(chatId, newName);
Ifaa.reply('The group name has been successfully changed to: ' + newName);
} catch (error) {
console.error('Error while setting group name:', error);
Ifaa.reply('An error occurred while changing the group name.');
}
});
// Owner Feature
bot.command('listuser', async (Ifaa) => {
const adminUsers = JSON.parse(fs.readFileSync(adminfile));
const isAdmin = adminUsers.includes(String(Ifaa.from.id));
if (!isAdmin) {
try {
const users = Ifaa.from.id;
const userList = users.map((user) => `ID: \`${user.id}\`, Username: ${user.username}, Status: ${user.status}\n`).join('\n');
Ifaa.reply(`List of Users:\n\n${userList}`);
} catch (error) {
console.error('Error fetching users:', error);
Ifaa.reply('Failed to fetch users.');
}
} else {
Ifaa.reply('Fitur Ini Khusus Untuk Owner Bot');
}
});
bot.command('bc', async (Ifaa) => {
const adminUsers = JSON.parse(fs.readFileSync(adminfile));
const isAdmin = adminUsers.includes(String(Ifaa.from.id));
if (!isAdmin) {
const commandParts = Ifaa.message.text.split(' ');
commandParts.shift();
const message = commandParts.join(' ');
if (message || Ifaa.message.caption || Ifaa.message.photo || Ifaa.message.document || Ifaa.message.video || Ifaa.message.animation || Ifaa.message.audio || Ifaa.message.sticker) {
const users = Ifaa.from.id;
for (const user of users) {
try {
if (Ifaa.message.photo) {
const photo = Ifaa.message.photo[Ifaa.message.photo.length - 1];
await bot.telegram.sendPhoto(user.id, photo.file_id, { caption: message || Ifaa.message.caption });
} else if (Ifaa.message.document) {
const document = Ifaa.message.document;
const fileSizeMB = document.file_size / (1024 * 1024);
if (fileSizeMB <= fileLimit) {
await bot.telegram.sendDocument(user.id, document.file_id, { caption: message || Ifaa.message.caption });
} else {
console.error(`File size exceeds the limit for user ${user.username} (ID: ${user.id})`);
}
} else if (Ifaa.message.video) {
const video = Ifaa.message.video;
await bot.telegram.sendVideo(user.id, video.file_id, { caption: message || Ifaa.message.caption });
} else if (Ifaa.message.animation) {
const animation = Ifaa.message.animation;
await bot.telegram.sendAnimation(user.id, animation.file_id, { caption: message || Ifaa.message.caption });
} else if (Ifaa.message.audio) {
const audio = Ifaa.message.audio;
await bot.telegram.sendAudio(user.id, audio.file_id, { caption: message || Ifaa.message.caption });
} else if (Ifaa.message.sticker) {
const sticker = Ifaa.message.sticker;
await bot.telegram.sendSticker(user.id, sticker.file_id);
} else {
await bot.telegram.sendMessage(user.id, message || Ifaa.message.caption);
}
console.log(`Broadcast message sent to user ${user.username} (ID: ${user.id})`);
} catch (error) {
console.error(`Failed to send broadcast message to user ${user.username} (ID: ${user.id}): ${error.message}`);
}
}
Ifaa.reply('Broadcast completed. Check the console for details.');
} else {
Ifaa.reply('Invalid command. Please use: /bc <message>');
}
} else {
Ifaa.reply('Fitur Ini Khusus Untuk Owner Bot')
}
});
// Message lainnya:->
bot.hears(['hai', 'hii', 'hi', 'halo', 'hallo', 'hwalo', 'hwloo', 'hiii'], async (Ifaa) => {
Ifaa.reply(`Iyaa ada apa ya kak? kalau bingung tanya ma bapak lo ya`)
})
// gatau mau buat apa😔
// gada cwe bjir
bot.hears(["assalamualaikum", "mikum", "assalamu'alaikum"], async (Ifaa) => {
Ifaa.reply(`Waalaikumsalam, ada apa ya kak? kalau bingung tanya sama bapak lo ya kak😋`)
})
bot.hears(['sayang', 'syng', 'syg', 'syang', 'sayng', 'yang', 'ayy', 'ayyang', 'ayng', 'ayg', 'ayang'], async (Ifaa) => {
Ifaa.reply(`Lu ngapainnn dahh?? stres kah?`)
})
bot.hears(['p', 'pp', 'pe', 'pppp', 'ppp'], async (Ifaa) => {
Ifaa.reply(`Tolong ucapkan salam, Non Muslim? Ucapkan Hi, hai, halo, atau agama kalian masing masing yaa`)
})
//=============== KEYBOARD DELETE ===============\\
// HILANGKAN KEYBOARD
bot.hears('Remove keyboard!!', async (Ifaa) => {
Ifaa.deleteMessage()
Ifaa.reply('Keyboard Berhasil Dihilangkan!!',
{
reply_markup: {
remove_keyboard: true //kalau ngak ngerti jngan di utak atik
}
})
})
//▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰//
//
// del srv
bot.command('delsrv', async (Ifaa) => {
const chatId = Ifaa.chat.id;
const srv = Ifaa.message.text.split(' ').slice(1).join(' ');
const adminUsers = JSON.parse(fs.readFileSync(adminfile));
const isAdmin = adminUsers.includes(String(Ifaa.from.id));
if (!isAdmin) {
Ifaa.reply('Khusus Owner', {
reply_markup: {
inline_keyboard: [
[
{ text: 'Owner', url: 'https://t.me/idstore74_pw' }
]
]
}
});