-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmiko.sh
More file actions
executable file
·4623 lines (4150 loc) · 153 KB
/
Copy pathmiko.sh
File metadata and controls
executable file
·4623 lines (4150 loc) · 153 KB
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
#! /bin/bash
#-----------------------------------------------------------------------------------------------------------
# DATA: 10 de abril de 2020 (1-⁰ dia de operação)
# SCRIPT: miko.sh
# VERSÃO: 0.5.8
# DESENVOLVIDO POR: Fabrício Caetano [F43®1¢10 m0h∆m3d]
# PÁGINA: https://eduardamonteiro.zyrosite.com/
# CHANNEL: https://t.me/mikoduda
# BOT: https://t.me/engenhariade_bot
# MANUAL: https://telegra.ph/Eduarda-Monteiro--manual-09-20
# GITHUB: https://github.com/fabriciocaetano
# CONTATO: fabricio45726245@protonmail.ch
#
# DESCRIÇÃO: miko (Duda) é uma Bot de telegram desenvolvida para agir como um humano moderador/colaborador/participante,
# desenvolvida para facilitar a moderação de grupos na plataforma TELEGRAM. visto que pessoas respeitam mais
# mais admins humanos do que admins bots.
#
# Constituída por uma coleção de habilidades e funções que permitem aos ADMINS e MEMBROS:
# * Gerenciar grupos, canais e membros.
# * e : https://telegra.ph/Eduarda-Monteiro--manual-09-20
#
# DEPENDÊNCIAS: curl, jq, ffmpeg, sox, html2text, pdf2txt/pdftotxt, catdoc.
#
# NOTAS: Desenvolvida na linguagem Shell Script, utilizando o interpretador de
# comandos BASH e explorando ao máximo os recursos built-in do mesmo,
# reduzindo o nível de dependências de pacotes externos.
#-----------------------------------------------------------------------------------------------------------
# CONFIGURAÇÕES E TOKENS DA EDUARDA MONTEIRO (DUDA/BOT):
#--------------------------------------------------------------------------------------------------------------
#chave/token da duda/bot
bot_token='<SUA_CHAVE_PRINCIPAL>' #duda principal
#bot_token='<sua_chave_teste>' # duda teste
#---------------------------
# token de pagamentos stripe:
token_pay='<TOKEN_VÁLIDA>' #real
#token_pay='<token teste>' #teste
#---------------------------
#token da deepai.org para detecção de porn e imagens extremistas
token_porn='<TOKEN_DEEPAI>' # ficará defasado após futuras atualizações
#---------------------------
# ID do dono, VOCÊ
ID_DONO="<SEU_USER_ID>"
#--------------------------------------------------------------------------------------------------------------
# VERIFICAÇÃO DE PASTAS IMPORTANTES:
#--------------------------------------------------------------------------------------------------------------
[[ -a guia ]] || mkdir guia
[[ -a sons ]] || mkdir sons
[[ -a audio ]] || mkdir audio
[[ -a dados ]] || mkdir dados
[[ -a podcast ]] || mkdir podcast
[[ -a resumir ]] || mkdir resumir
[[ -a production ]] || mkdir production
#--------------------------------------------------------------------------------------------------------------
# usando set +f e -f para habilitar e
# sehabilitar a expansão de nomes de
# arquivos do shell ao longo do código.
# evitar expansão em meio a mensagens
# e processamentos.
# IMPORTANDO PLUGINS/FUNÇÕES:
#--------------------------------------------------------------------------------------------------------------
#importando plugins/funções
for plug in plugins/*;do
# mysql.sh desativado e descontinuado
[[ "${plug%.*}" = "mysql" ]] || {
plug=${plug%.*}
declare -A "${plug##*/}"
}
done
for plug in plugins/*;do
source ${plug}
done
#--------------------------------------------------------------------------------------------------------------
# VERIFICAR DEPENDÊNCIAS NECESSÁRIAS:
#--------------------------------------------------------------------------------------------------------------
[[ "$(command -v curl)" ]] || {
echo -e "falta dependência, nome: curl\nse estiver usando ubuntu, instale com o comando:\nsudo apt install curl"
exit 1
}
[[ "$(command -v jq)" ]] || {
echo -e "falta dependência, nome: jq\nse estiver usando ubuntu, instale com o comando:\nsudo snap install jq"
exit 1
}
#--------------------------------------------------------------------------------------------------------------
#baixar API para comunicação do telegram, caso o mesmo não esteja disponível no diretório do bot em questão
#--------------------------------------------------------------------------------------------------------------
[[ -a ShellBot.sh ]] || {
curl 'https://raw.githubusercontent.com/shellscriptx/shellbot/master/ShellBot.sh' -o ShellBot.sh
chmod +x ShellBot.sh
}
[[ -a LICENSE.txt ]] || {
curl 'https://raw.githubusercontent.com/shellscriptx/shellbot/master/LICENSE.txt' -o LICENSE.txt
}
#--------------------------------------------------------------------------------------------------------------
# IMPORTANDO DEPENDÊNCIAS
#--------------------------------------------------------------------------------------------------------------
source ShellBot.sh
ShellBot.init --token "${bot_token}" --return map
#--------------------------------------------------------------------------------------------------------------
# encapsulando funções das funções do shellbot
# para facilitar e focar na codificação das interações
# da duda, e reduzir as formas diversificadas e atípicas de interações.
#--------------------------------------------------------------------------------------------------------------
escrever(){
# cálculo com base em testes e estudos pessoais
# para emular o tempo real de digitação média
# de um ser humano médio a elevado em termos tecnológicos.
# número de caracteres da mensagem X tempo médio de pressiona-
# mento de teclas de um usuário comum / por tempo de espera
# entre requisições de 'digitando ...'
repetir=$(bc <<< "${#mensagem}*0.12/3")
for((i=0;i<=${repetir%.*};i++)); do
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action typing
sleep 3s
done
}
enviar() {
mensagem="${mensagem//\+/\%2B}"
id_chat=${my_chat_member_from_id[$id]}
id_chat=${message_chat_id[$id]:-$id_chat}
ShellBot.sendMessage --chat_id ${callback_query_message_chat_id:-$id_chat} --text "${mensagem}" $1
}
responder() {
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} --text "$mensagem" --reply_to_message_id ${message_message_id[$id]} "$1"
}
foto() {
ShellBot.sendPhoto --chat_id ${message_chat_id[$id]} --photo @${arquivofoto}
}
enviarfoto() {
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action upload_photo
}
enviar_menu(){
ShellBot.sendMessage --chat_id ${message_chat_id[$id]} --text "${mensagem}" \
--reply_markup "$keyboard1"
}
documento() {
ShellBot.sendDocument --chat_id ${message_chat_id[$id]} --document ${1} ${2}
}
local_documento() {
ShellBot.sendDocument --chat_id ${message_chat_id[$id]} --document @${1} ${2}
}
enviando_documento() {
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action upload_document
}
local_video() {
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action upload_video
ShellBot.sendVideo --chat_id ${message_chat_id[$id]} --video @${1} ${2}
}
video() {
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action upload_video
ShellBot.sendVideo --chat_id ${message_chat_id[$id]} --video ${1} ${2}
}
local_sticker(){
ShellBot.sendSticker --chat_id ${message_chat_id[$id]} --sticker @${1} ${2}
}
sticker(){
ShellBot.sendSticker --chat_id ${message_chat_id[$id]} --sticker ${1} ${2}
}
banir(){
argument=${message_from_id[$id]}
ShellBot.kickChatMember --chat_id ${message_chat_id[$id]} --user_id ${1:-$argument}
}
banir_ref(){
id_user=${message_reply_to_message_from_id[$id]}
ShellBot.kickChatMember --chat_id ${message_chat_id[$id]} --user_id ${message_reply_to_message_new_chat_participant_id[$id]:-$id_user}
}
desbanir(){
id_user=${message_from_id[$id]}
id_user=${message_reply_to_message_from_id[$id]:-$id_user}
ShellBot.unbanChatMember --chat_id ${message_chat_id[$id]} --user_id ${message_reply_to_message_new_chat_participant_id[$id]:-$id_user}
}
adeus(){
ShellBot.leaveChat --chat_id ${message_chat_id[$id]}
}
animacao(){
ShellBot.sendAnimation --chat_id ${message_chat_id[$id]} --animation ${1} ${2}
}
fixar(){
ShellBot.pinChatMessage --chat_id ${message_chat_id[$id]} --message_id ${message_message_id[$id]} || {
mensagem="eu não tenho poder administrativo aqui, ou não tenho todas as permissões de administradora para FIXAR MENSAGENS aqui, se desejar que eu continue, me dê poderes administrativos necessários para eu , irei tentar novamente em 2 minutos."
escrever
enviar
sleep 2m
ShellBot.pinChatMessage --chat_id ${message_chat_id[$id]} --message_id ${message_message_id[$id]}
}
}
desafixar(){
ShellBot.unpinChatMessage --chat_id ${message_chat_id[$id]} --message_id ${message_message_id[$id]}
}
fixar_ref(){
ShellBot.pinChatMessage --chat_id ${message_chat_id[$id]} --message_id ${message_reply_to_message_message_id[$id]} || {
mensagem="eu não tenho poder administrativo aqui, ou não tenho todas as permissões de administradora para FIXAR MENSAGENS aqui, se desejar que eu continue, me dê poderes administrativos necessários para eu operar, , irei tentar novamente em 2 minutos."
escrever
enviar
sleep 2m
ShellBot.pinChatMessage --chat_id ${message_chat_id[$id]} --message_id ${message_reply_to_message_message_id[$id]}
}
}
fixarbot(){
ShellBot.pinChatMessage --chat_id ${message_chat_id[$id]} --message_id ${return[message_id]} || {
mensagem="eu não tenho poder administrativo aqui, ou não tenho todas as permissões de administradora para FIXAR MENSAGENS aqui, se desejar que eu continue, me dê poderes administrativos necessários para eu operar, caso contrário, irei tentar novamente em 2 minutos."
escrever
enviar
sleep 2m
ShellBot.pinChatMessage --chat_id ${message_chat_id[$id]} --message_id ${return[message_id]}
}
}
editar(){
ShellBot.editMessageText --chat_id ${message_chat_id[$id]} --message_id ${return[message_id]} --text "$1" $2
}
guardaredicao(){
edicao=${return[message_id]}
}
editaredicao(){
ShellBot.editMessageText --chat_id ${message_chat_id[$id]} --message_id "$edicao" --text "$1"
}
deletarbot(){
user_id=${callback_query_message_message_id[$id]}
outro_chat_id=${callback_query_message_chat_id[$id]}
[[ ${1} ]] && {
ShellBot.deleteMessage --chat_id ${message_chat_id[$id]:-$outro_chat_id} --message_id ${1}
} || {
ShellBot.deleteMessage --chat_id ${message_chat_id[$id]:-$outro_chat_id} --message_id ${return[message_id]:-$user_id}
}
}
deletar(){
delet=${message_message_id[$id]}
ShellBot.deleteMessage --chat_id ${message_chat_id[$id]} --message_id ${message_left_chat_participant_id[$id]:-$delet}
}
deletar_ref(){
ShellBot.deleteMessage --chat_id ${message_chat_id[$id]} --message_id ${message_reply_to_message_message_id[$id]}
}
audio(){
valor=$((${2}/3))
repetir=0
while :
do
[[ "$repetir" -ge "$valor" ]] && break;
repetir=$((repetir+1))
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action record_audio
sleep 3s
done
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action upload_audio
ShellBot.sendAudio --chat_id ${message_chat_id[$id]} --audio @${1} ${3}
}
scope(){
valor=$((${2}/3))
repetir=0
while [[ $repetir -lt $valor ]]; do
repetir=$((repetir+1))
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action record_video_note
sleep 3s
done
ShellBot.sendChatAction --chat_id ${message_chat_id[$id]} --action upload_video_note
ShellBot.sendVideoNote --chat_id ${message_chat_id[$id]} --video_note @${1} ${3}
}
#determinação de gênero textual para sujeito
#ex: envio a palavra "ventilador", ele retorna: o|com|no ventilador.
# e os plurais também: os|uns|nos ventiladores
#-------------------------------------------------------------
genero(){
parser=$[${#2}-2]
compare=${2:$parser:2}
[[ ${1} = 1 ]] && {
[[ "${compare}" =~ (a|ã|â|á) ]] && saida="a" || {
parser2=$[${#2}-3]
compare2=${2:$parser2:3}
[[ "${compare2}" =~ (a|ã|â|á) ]] && {
saida="a"
} || saida="o"
}
}
[[ ${1} = 2 ]] && {
[[ "${compare}" =~ (a|ã|â|á) ]] && saida="na" || {
parser2=$[${#2}-3]
compare2=${2:$parser2:3}
[[ "${compare2}" =~ (a|ã|â|á) ]] && {
saida="na"
} || saida="no"
}
}
[[ ${1} = 3 ]] && {
[[ "${compare}" =~ (a|ã|â|á) ]] && saida="uma" || {
parser2=$[${#2}-3]
compare2=${2:$parser2:3}
[[ "${compare2}" =~ (a|ã|â|á) ]] && {
saida="uma"
} || saida="um"
}
}
# adição de plurais
parser3=$[${#2}-1]
compare3=${2:$parser3:1}
[[ "${compare3}" = "s" ]] && {
[[ "${1}" = 3 && "${saida}" = "um" ]] && {
saida="uns"
} || saida="${saida}s"
} || saida="${saida}"
}
#-------------------------------------------------------------
# FUNÇÃO DE DETECÇÃO DE FLOOD
checkcontinuity() {
[[ ${message_reply_to_message_from_id[$id]} ]] || {
ShellBot.getChatMember --chat_id ${message_chat_id[$id]} --user_id ${message_from_id[$id]}
Ids=$(< check/${message_chat_id[$id]}.lil)
[[ "${return[status]}" = "administrator" || "${return[status]}" = "creator" ]] || {
[[ "$Ids" = *"${message_from_id[$id]}"* ]] && {
echo ".${message_from_id[$id]}:" >> check/${message_chat_id[$id]}.lil
quantidade=0
while read linha;do
[[ $linha ]] && quantidade=$((quantidade+1))
done < check/${message_chat_id[$id]}.lil
[[ $quantidade = 3 && ${#message_text[$id]} -ge 1 && ${#message_text[$id]} -le 5 ]] && {
[[ "${message_from_username[$id]}" ]] && {
mensagem="@${message_from_username[$id]}, faça favor de juntar suas mensagens, mensagens com poucos caracteres acima de 3 seguidas, ja é um flood, saiba que ENTER não é vírgula, respeito por favor."
enviar
}
[[ "${message_from_username[$id]}" ]] || {
mensagem="${message_from_first_name[$id]}, faça favor de juntar suas mensagens, mensagens com poucos caracteres acima de 3 seguidas, ja é um flood, saiba que ENTER não é vírgula, respeito por favor."
responder
}
sleep 1m
deletarbot
}
[[ $quantidade = 5 ]] && {
[[ "${message_from_username[$id]}" ]] && {
mensagem="@${message_from_username[$id]}, cuidado com o flood, você será banido se continuar."
enviar
} || {
mensagem="${message_from_first_name[$id]}, cuidado com o flood, você será banido se continuar."
responder
}
sleep 1m
deletarbot
}
[[ $quantidade -ge 7 ]] && {
mensagem="você floodou, até."
responder
banir
> check/${message_chat_id[$id]}.lil
sleep 1m
deletarbot
}
}
}
[[ "$Ids" = *".${message_from_id[$id]}:"* ]] || echo ".${message_from_id[$id]}:" > check/${message_chat_id[$id]}.lil
}
}
edit="--parse_mode markdown"
#verificar se banco de dados existe, se não tiver, ele será criado
Create_database
[[ -a up.txt ]] || > up.txt
[[ -a guia ]] || mkdir guia
[[ -a abudabi ]] || mkfifo abudabi
update(){
exec 3>&-
exec "${0}"
}
[[ "$(< up.txt)" = "atualize" ]] && {
echo "avisando para desligamento ..."
echo "desliga" > up.txt
echo $(< abudabi)
}
[[ -a nexus ]] || mkfifo nexus
while :
do
[[ "$(< up.txt)" = "desliga" ]] && {
echo "desligando ..."
> up.txt
echo "morrendo" > abudabi
exit
}
ShellBot.getUpdates --limit 100 --offset $(ShellBot.OffsetNext) --timeout 5
###################################################
# #
# algumas variáveis precisam ficar daqui para #
# baixo, pois são individuais para cada #
# solicitação. #
# #
###################################################
# verificar horário em thread
(
[[ "$(date +%H:%M)" =~ (06|12|18|24)\:00 && -a nexus ]] && {
#evitar que seja acionado novamente
rm nexus
./multicast.sh
lista="$(< consulta.lil)"
data=$(date +%D)
while IFS=':' read F1 F2 F3 F4 F5 F6; do
(
IFS=';' read D1 D2 D3 D4 <<< "${F6}"
while IFS=';' read C1 C2 C3;do
[[ "${D1}" = "${C1}" ]] && {
D1="${D1};${C2}"
T1=${C3%%\/*}
}
[[ "${D2}" = "${C1}" ]] && {
D2="${D2};${C2}"
T2=${C3%%\/*}
}
[[ "${D3}" = "${C1}" ]] && {
D3="${D3};${C2}"
T3=${C3%%\/*}
}
[[ "${D4}" = "${C1}" ]] && {
D4="${D4};${C2}"
T4=${C3%%\/*}
}
done <<< "${lista}"
anexo=''
ShellBot.InlineKeyboardButton --button 'anexo' --line "1" --text "${D1%;*}" --callback_data "notinterpret" --url "${D1#*;}"
ShellBot.InlineKeyboardButton --button 'anexo' --line "2" --text "${D2%;*}" --callback_data "notinterpret" --url "${D2#*;}"
ShellBot.InlineKeyboardButton --button 'anexo' --line "3" --text "${D3%;*}" --callback_data "notinterpret" --url "${D3#*;}"
ShellBot.InlineKeyboardButton --button 'anexo' --line "4" --text "${D4%;*}" --callback_data "notinterpret" --url "${D4#*;}"
keyboard1="$(ShellBot.InlineKeyboardMarkup -b 'anexo')"
D1=${D1%;*} ; D2=${D2%;*} ; D3=${D3%;*} ; D4=${D4%;*}
T1=${T1%%-*} ; T1=${T1%%|*} ; T1=${T1//\;/ } ; T1=${T1//\_/ }
T2=${T2%%-*} ; T2=${T2%%|*} ; T2=${T2//\;/ } ; T2=${T2//\_/ }
T3=${T3%%-*} ; T3=${T3%%|*} ; T3=${T3//\;/ } ; T3=${T3//\_/ }
T4=${T4%%-*} ; T4=${T4%%|*} ; T4=${T4//\;/ } ; T4=${T4//\_/ }
layout="*${F5//_/ }*\n\n"
layout+="notícias da *.:newslettercast:.*\n"
layout+="*❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱*\n\n"
layout+="*${D1^}:*\n"
layout+=" ። ${T1}\n\n"
layout+="*${D2^}:*\n"
layout+=" ። ${T2}\n\n"
layout+="\n*${D3^}:*\n"
layout+=" ። ${T3}\n\n"
layout+="*${D4^}:*\n"
layout+=" ። ${T4}\n\n"
layout+="*❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱❱*\n"
layout+="—————(${data})—————\n"
layout+="BY: @engenhariade\_bot\n"
layout+="se quiser fazer uma doação, pix: eduardamonteiro@telegmail.com 👀"
ShellBot.sendAudio --chat_id "${F2}" --audio "@podcast/newslettercast_${F1}.mp3" --title "newslettercast de ${F5//_/ }" --caption "${layout}" --reply_markup "$keyboard1" --parse_mode markdown
#avisar que não foi enviado, com um marcador de pré aviso
#[[ "$?" = 1 ]] &&
)&
done < fontes.ref
#permitir ser reativado após a conclusão
mkfifo nexus
}
)&
#--- informação para saber a quem deve responder ---#
resp="--reply_to_message_id ${message_message_id[$id]}"
for id in $(ShellBot.ListUpdates)
do
(
minusc=${message_text[$id],,}
[[ ${message_caption[$id]} ]] && minusc=${message_caption[$id],,}
[[ -a lista_negra.lil ]] || > lista_negra.lil
while read linha;do
[[ ${linha} ]] && {
[[ "${minusc}" = *"${linha}"* || ${message_from_username[$id]} = "${linha}" || ${message_from_id[$id]} = "${linha}" ]] && {
deletar &
deletar_ref &
banir
}
}
done < lista_negra.lil &
mencionar=0 #controle de menções
[[ "${message_from_id[$id]}" = "${ID_DONO}" ]] && {
[[ "${message_text[$id]}" = *"/vida"* ]] && {
deletar
mensagem="ativa"
enviar
sleep 1s
deletarbot
}
[[ "${message_text[$id]}" = *"/comando"* ]] && {
deletar
IFS=' ' read f1 f2 <<< "${message_text[$id]}"
mensagem="saida:\n$($f2)"
enviar
}
[[ "${message_text[$id]}" = "/registro"* ]] && {
IFS=' ' read f1 f2 <<< "${message_text[$id]}"
[[ ${f2} ]] && {
deletar
echo "${f2,,}" >> lista_negra.lil
mensagem="ítem adicionado na lista."
enviar
}
[[ ${f2} ]] || {
[[ "${message_reply_to_message_from_id[$id]}" ]] && {
deletar
echo "${message_reply_to_message_from_id[$id]}" >> lista_negra.lil
mensagem='ítem adicionado na lista.'
enviar
} || {
mensagem='o idiota, adicione o registro na frente do comando ô retardado.'
enviar
}
}
sleep 5s
deletarbot
}
[[ "${message_text[$id]}" = "/noregistro"* ]] && {
IFS=' ' read f1 f2 <<< "${message_text[$id]}"
[[ ${f2} ]] && {
deletar
sed -i "${f2}" lista_negra.lil
mensagem="ítem removido da lista."
enviar
} || {
[[ ${message_reply_to_message_message_id[$id]} ]] && {
deletar
echo "${message_reply_to_message_message_id[$id]}" >> lista_negra.lil
} || {
mensagem='o idiota, adicione o registro na frente do comando ô retardado.'
enviar
}
}
}
[[ "${message_text[$id]}" = *'/atualizar'* ]] && {
mensagem="atualizando"
enviar
echo "atualize" > up.txt
update
}
[[ "${message_text[$id]}" = *"/desligar"* ]] && {
deletar
mensagem="desligando ..."
enviar
init 0
systemctl poweroff -i
}
[[ "${message_text[$id]}" = *"/reiniciar"* ]] && {
deletar
mensagem="reiniciando ..."
enviar
sudo init 6
sudo reboot now
}
[[ "${message_text[$id]}" = *"/memoria"* ]] && {
deletar
mensagem=$(free)
enviar
}
[[ "${message_text[$id]}" = *"/sair"* ]] && {
deletar
adeus
}
[[ "${message_text[$id]}" = *"/aviso"* ]] && {
#IFS=' ' read F1 F2 <<< ${message_text[$id]}
tratamento=${message_text[$id]#\/aviso*}
tratamento=${tratamento//\\\"/\"}
mensagem="enviando alerta em massa ..."
enviar
cd dados
set +f
for i in *;do
(
tratando=$(sed 's/^a/-/' <<< "${i}")
chat_banco=$(tr 'a-z' '0-9' <<< "${tratando%.*}")
ShellBot.sendMessage --chat_id "${chat_banco}" --text "${tratamento}" --parse_mode markdown && sucesso=true
[[ ${sucesso} = true ]] && {
[[ "${message_text[$id],,}" =~ \#(important|pin|fix) ]] && ShellBot.pinChatMessage --chat_id "${chat_banco}" --message_id ${return[message_id]}
}
# [[ ${sucesso} ]] || {
# ShellBot.leaveChat --chat_id "${chat_banco}" &
# rm -rf ${i}
# }
)&
done
cd ..
mensagem="alerta enviado a todos com sucesso!"
enviar
}
[[ "${message_text[$id]}" = *"/usuarios"* ]] && {
deletar
quantidade=$(ls dados | wc -l)
mensagem="tem $quantidade usuários atualmente."
enviar
sleep 4s
deletarbot
}
}
#--- se usuário enviar mensagem ao entrar, será removido da lista de banimento ---#
#--- e sendo usado como gancho para o antiflood inteligente
[[ -a novomembro.txt ]] && > novomembro.txt
(
#verificar padrões da mensagem para golpistas
fgrep -q "${message_from_id[$id]}" novomembro.txt && {
[[ ${minusc,,} =~ (🤑|💸|r?\$|💰|⚠️|✅) && ${minusc} =~ [0-9]{1,} ]] && {
banir &
deletar &
mensagem="golpista/scan banido"
enviar
sleep 6s
deletarbot
}
}
#verificar se ele esta no banco, e verificar se ele enviou algum spam
sed -i "/${message_from_id[$id]}/d" novomembro.txt
#verificar se a pessoa está floodando ou não
Consulta_table iflood
[[ "${valor}" = "1" ]] && {
checkcontinuity &
}
)&
#--- função teste para banir membros globalmente antes de entrar. ---#
# [[ -a bombardear.lil ]] && echo "" > bombardear.lil
# while read linha;do
# [[ "${message_from_username[$id]}" = "$linha" ]] && {
# banir
# mensagem="este usuário está configurado para banimento global, ele foi denunciado por algo em algum lugar por alguém. nada mais a saber, para desbanir ou pedir redenção, entre no chat do nosso guardião julgador, conte seu relato e provas, e ele baterá o martelo e decidir quem é inocente ou culpado. \n https://t.me/joinchat/KMg9nxptCrcWOygzBeO_Ag"
# responder
# }
# done < bombardear.lil
#--- BOAS-VINDAS ---#
[[ ${message_new_chat_member_id[$id]} ]] && {
Consulta_table boasvindas
boas_vindas=${valor}
[[ ${message_new_chat_participant_is_bot[$id]} = "true" && "#${message_new_chat_participant_id[$id]}#" != "#865837947#" ]] && {
boas_vindas=0
mensagem="oh, um bot, bora testar OwO"
enviar
mensagem="/start@${message_new_chat_member_username[$id]}"
responder
}
[[ "#${message_new_chat_participant_id[$id]}#" = "#${return[id]}#" ]] && {
boas_vindas=0
mensagem="oiii, obrigada por me adicionarem ao seu grupo ou ... canal."
enviar
mensagem="preciso que me configurem para meu funcionamento.\ncomeçando por: admin. é necessário para eu gerenciar o grupo. em seguida, me enviem o comando /configurar para verem minhas opções, e para ver o status de ativação delas, envie /status. boa sorte."
enviar
}
[[ "$boas_vindas" = "1" ]] && {
echo "${message_new_chat_participant_id[$id]}" >> novomembro.txt
#gerar apelido:
[[ ${message_new_chat_member_username[$id]} ]] && {
apel="@${message_new_chat_member_username[$id]}"
} || {
apel="${message_new_chat_member_first_name[$id]:0:2}"
[[ ${apel,,} =~ ^.(a|e|i|o|u) ]] || apel="${message_new_chat_member_first_name[$id]:0:3}"
apel="${apel}${apel,,}"
}
mensagem="oi ${apel}, tudo bem ?"
escrever
enviar
mensagem=''
nome=$[$RANDOM%11]
case $nome in
0)
mensagem+='tem alguma habilidade relacionada ao tema do grupo que gostaria de compartilhar ? :3'
;;
1)
mensagem+='poderia nos contar um pouco sobre você e seus objetivos aqui ? (se tiver algum e quiser compartilhar conosco ;D)'
;;
2)
mensagem+='você sabe algo sobre o tema deste grupo ou está estudando alguma relacionada ? :v'
;;
3)
mensagem+='sinta-se a vontade :), possui alguma habilidade relacionda ao tema deste grupo ?'
;;
4)
mensagem+="você está estudando alguma coisa sobre o tema deste grupo ?"
;;
5)
mensagem+='quais habilidades você poderia compartilhar conosco ? :v'
;;
6)
mensagem+='esta estudando alguma coisa interessante ? :3'
;;
7)
mensagem+="quais são seus interesses pelo tema deste grupo, ${message_new_chat_member_first_name[$id]} ?, poderia compartilhar conosco :3 ?"
;;
8)
mensagem+='você tem alguma afinidade com o tema deste grupo ou ainda está descobrindo alguma coisa que você se identifique melhor ?'
;;
9)
mensagem+='seu nome é interessante, o que você sabe sobre o tema deste grupo ?, ou está em busca de algo novo e ainda não sabe muita coisa ? :v'
;;
10)
mensagem+='conte-nos um pouco sobre você. está estudando alguma coisa relacionada ao tema deste grupo ? '
;;
11)
mensagem+='o que você esta aprendendo atualmente relacionado ao tema deste grupo ?'
;;
esac
escrever
responder
sleep 30s
fgrep -q "${message_new_chat_participant_id[$id]}" novomembro.txt && {
#salvar envio anterior para deletar
user_id=${callback_query_message_message_id[$id]}
param=${return[message_id]:-$user_id}
[[ ${message_new_chat_members_username[$id]} ]] && {
mensagem="@${message_new_chat_member_username[$id]}, preciso que você interaja conosco, temos que saber se você não é um spammer ou um bot. você tem 10 minutos para enviar alguma mensagem, não queremos te perder :3"
escrever
enviar
}
[[ ${message_new_chat_members_username[$id]} ]] || {
mensagem="fale algo ${message_new_chat_member_first_name[$id]}, eu preciso saber se você não é um spammer ou um bot, pois terei que remover você infelizmene caso não responda em 10 minutos."
escrever
responder
}
for((rodada=0;rodada<=120;rodada++));do
sleep 5s
while read -r linha;do
[[ "${linha}" = "${message_new_chat_participant_id[$id]}" ]] && {
persistencia=1
}
done < novomembro.txt
[[ ${persistencia} -eq 1 ]] || {
deletarbot
persistencia=1
break
}
done
}
fgrep -q "${message_new_chat_participant_id[$id]}" novomembro.txt && {
deletarbot &
deletarbot "${param}" &
ShellBot.kickChatMember --chat_id ${message_chat_id[$id]} --user_id ${message_new_chat_participant_id[$id]}
[[ ${message_new_chat_members_username[$id]} ]] && {
mensagem="removi @${message_new_chat_members_username[$id]}, não respondeu na entrada, '-'"
}
[[ ${message_new_chat_members_username[$id]} ]] || {
mensagem="removi ${message_new_chat_member_first_name[$id]}, por não ter falado nada, infelizmente"
}
enviar
sleep 1m
deletarbot
}
fgrep -q "${message_new_chat_participant_id[$id]}" novomembro.txt && {
sed -i "/${message_new_chat_member_first_name[$id]}/d" novomembro.txt
} || {
[[ ${message_new_chat_members_username[$id]} ]] && {
mensagem="@${message_new_chat_members_username[$id]}"
}
[[ ${message_new_chat_members_username[$id]} ]] || {
mensagem="${message_new_chat_member_first_name[$id]}"
}
mensagem+=", fique a vontade para fazer perguntas e tirar dúvidas :3,"
Consulta_table channel
[[ "$valor" = "0" ]] || mensagem+="dê uma olhada em nosso acervo\canal do grupo: \n $valor"
Consulta_table regra
[[ "$valor" = "0" ]] || mensagem+="\n e nas regras:\n regras:\n $valor"
mensagem+=" espero que te ajudemos no que procura :)"
responder
}
}
} &
#--------------- DETECTOR DE SPAMMERS POR IMAGEM, VÍDEO, GIF e STICKERS ---------------#
[[ ${message_sticker_thumb_file_id[$id]} ]] && file_id=${message_sticker_thumb_file_id[$id]} && spammer=1
[[ ${message_document_thumb_file_id[$id]} ]] && file_id=${message_document_thumb_file_id[$id]} && spammer=1
[[ ${message_video_thumb_file_id[$id]} ]] && file_id=${message_video_thumb_file_id[$id]} && spammer=1
[[ ${message_photo_file_id[$id]} ]] && file_id=${message_photo_file_id[$id]} && spammer=1
[[ $spammer -eq 1 ]] && {
spammer=0
Consulta_table spammers
detectar_spammers_fotos=$valor
[[ "$detectar_spammers_fotos" = "1" ]] && {
file_id=($file_id)
file_id=${file_id##*\|}
ShellBot.getFile --file_id $file_id
ShellBot.downloadFile --file_path ${return[file_path]} --dir $PWD
file_id=''
arquivo=${return[file_path]##*/}
banir=0
[[ $banir -eq 1 ]] && {
banir=0
banir
deletar
mensagem="bani um spammer :3"
enviar
sleep 10s
deletarbot
} || {
extrair_resultado=$(curl -s -F "image=@${arquivo}" -H "api-key: ${token_porn}" https://api.deepai.org/api/nsfw-detector)
nome=$(jq '.output.detections[].name' <<< "$extrair_resultado")
[[ "$nome" = *'credits'* ]] || {
certeza=$(jq '.output.nsfw_score' <<< "$extrair_resultado")
classificador=''
[[ "${nome,,}" = *"breast"* ]] && classificador+="mamilo "
[[ "${nome,,}" = *"genitalia"* ]] && classificador+="genital "
[[ "${nome,,}" = *"buttocks"* ]] && classificador+="nadega "
[[ "${nome,,}" = *"covered"* ]] && classificador+="coberta, mas decote visível. "
[[ "${nome,,}" = *"exposed"* ]] && classificador+="exposta."
[[ "$classificador" && "${certeza:2:2}" > "49" || "${certeza:2:2}" > "60" ]] && {
deletar
mensagem="@admin, *conteúdo pornográfico encontrado*\n\n*detectado (gênero removido):*\n${classificador:-não identificado}\n"
classificador=''
[[ ${message_from_username[$id]} ]] && mensagem+="\n usuário: @${message_from_username[$id]}"
[[ ${message_from_username[$id]} ]] || mensagem+="\n usuário: ${message_new_chat_member_first_name[$id]}"
enviar "$edit"
sleep 5m
deletarbot
}
}
}
rm -rf $arquivo
file_id=''
classificador=''
}
rm -rf $arquivo
}
#--------------- transcrição de audio ---------------#
[[ ${message_voice_file_id[$id]} ]] && {
file_id=(${message_voice_file_id[$id]//|/ })
file_id=${file_id[0]}
download_audio=0
ShellBot.getFile --file_id $file_id
ShellBot.downloadFile --file_path ${return[file_path]} --dir $PWD/audio
file_id=''
arquivo=${return[file_path]##*/}
name_audio=${return[file_path]##*/}
name_audio=${name_audio%%.*}
#convertendo o audio
ffmpeg -i audio/$arquivo -r 48k audio/${name_audio}.flac
rm -rf audio/${arquivo} &
#separando fragmentos
sox -V3 audio/${name_audio}.flac audio/${name_audio}_.flac silence -l 1 0.3 0.1% 1 0.3 0.1% : newfile : restart #1 0.2 0.3% 1 0.2 0.3% : newfile : restart
rm -rf audio/${name_audio}.flac &
texto=''
set +f
#buscar o último e deletar || ao mesmo tempo que edita para melhor transcrição
for envio in audio/${name_audio}_*flac;do
sox audio/silencio.wav ${envio} audio/silencio.wav "${envio%.*}.wav"
ffmpeg -y -i "${envio%.*}.wav" "${envio%.*}.flac"
rm -f "${envio%.*}.wav"
# ultimo=${envio}
done
#rm -f ${ultimo}
for envio in audio/${name_audio}_*flac;do
transcricao=$(curl -s -X POST --data-binary @${envio} --user-agent 'Mozilla/5.0' --header 'Content-Type: audio/x-flac; rate=48000;' "https://www.google.com/speech-api/v2/recognize?output=json&lang=pt-BR&key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw&client=Mozilla/5.0" | jq '.result[].alternative[].transcript')
rm -f "${envio}" &
while read linha;do
texto=${linha//\"/}
done <<< "${transcricao,,}"
texto_final+=${texto:+$texto\,\ }
done
set -f
texto_final=${texto_final%\,*}
texto_final="${texto_final:+$texto_final.}"
#aplicando filtro de comandos:
texto_final=${texto_final//vírgula/\,}
texto_final=${texto_final// ponto final/\.}
texto_final=${texto_final// ponto interrogação/\?}
texto_final=${texto_final// ponto de interrogação/\?}
texto_final=${texto_final// dois pontos/\:}
texto_final=${texto_final// nova linha/\\n }
texto_final=${texto_final// novo paragrafo/\\n\\n }
texto_final=${texto_final// paragrafo/\\n\\n }
texto_final=${texto_final// abre aspas/\"}
texto_final=${texto_final// fecha aspas/\"}
texto_final=${texto_final// reticencias/\.\.\.}
texto_final=${texto_final//\,\,/\,}
texto_final=${texto_final//\.\./\.}
Consulta_table audios
transcrever_audio=$valor
ShellBot.getChatMember --chat_id ${message_chat_id[$id]} --user_id ${message_from_id[$id]}
[[ "$transcrever_audio" = "1" || "${return[status]}" = "member" ]] && {
[[ ${texto_final} ]] && {
mensagem="escrita:\n${texto_final}"
responder
} || {
while read -r linha; do
frase+=( "${linha}" )
done <<< $(printf "%s\n" não\ {consegui,pude}\ {ouvir,entender,escutar}\ {nada\ d,}o\ audio.)
mensagem="${frase[$[$RANDOM%${#frase[@]}]]}"
escrever
responder
}
}
unset mensagem transcricao
minusc=${texto_final,,}
}
[[ -a enviando.txt ]] || > enviando.txt
[[ $(fgrep "${message_from_id[$id]}" enviando.txt) ]] && {
[[ ${message_photo_file_id[$id]} || ${message_document_file_id[$id]} ]] && {
echo ${message_photo_file_id[$id]}${message_document_file_id[$id]} >> arquivos.${message_from_id[$id]}
}
}