-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboteship.txt
669 lines (561 loc) · 24.6 KB
/
boteship.txt
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
#########################################################
############### script name : EshipBot ##################
############### last update : 16/01/2023 ################
############### version : 10.12 #########################
######## description : Reinicia o serviço do e-ship #####
###### author : Josué Camargo ; Jhonatan Camargo ########
######## e-mail : [email protected] ####################
######## e-mail : [email protected] #########
#########################################################
import pyautogui
import time
import schedule
from textwrap import fill
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from datetime import datetime
import logging
import telebot
import threading
from PIL import Image
import random
#import datetime
logging.basicConfig(filename='botpython-logging.log', level=logging.INFO,
format='%(asctime)s:%(levelname)s:%(message)s')
### globais
ativo = pyautogui.locateOnScreen('ativo.png')
verconecta2 = pyautogui.locateOnScreen('verconecta2.png')
srvinfo = 'null'
srvinfh = 'null'
CHAVE_API = "chave aqui"
### conecta no servidor: 172.19.0.247 hostname: BRZ01WKSAPP02 (ok)
def conecta1():
time.sleep(1)
pyautogui.hotkey('ctrl', 'alt', 't')
time.sleep(5)
pyautogui.write('remmina')
time.sleep(1)
pyautogui.press('enter')
time.sleep(6)
srv3 = pyautogui.locateOnScreen('247.png')
pyautogui.doubleClick(srv3)
global srvinfo
srvinfo = '172.19.0.247'
global srvinfh
srvinfh = 'BRZ01WKSAPP02'
return
### confere se conectou, se não tenta mais três vezes (172.19.0.247 hostname: BRZ01WKSAPP02)
def verificacao_conecta1():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
k = 1
n = 3
b = 0
verconecta1 = pyautogui.locateOnScreen('verconecta1.png', confidence=0.9)
print(verconecta1)
logging.info(verconecta1)
while verconecta1 == None:
while k <= 10:
print(f'Conexão falhou, tentiva de número {k}')
logging.info(f'Conexão falhou, tentiva de número {k}')
k = k + 1
pyautogui.hotkey('alt', 'tab')
time.sleep(0.2)
pyautogui.hotkey('ctrl', 'c')
time.sleep(0.2)
pyautogui.write('exit')
time.sleep(0.2)
pyautogui.press('enter')
conecta1()
time.sleep(23)
verconecta1 = pyautogui.locateOnScreen('verconecta1.png', confidence=0.9)
if verconecta1 != None:
break
if k == n:
b = b + 1
print(f'Conexão ao servidor falhou, tentiva de número {k}, chamar enviar Email2()')
logging.info(f'Conexão ao servidor falhou, tentiva de número {k}, chamar enviar Email2()')
break
if verconecta1 == None:
print(f'Conexão do bot de reinicialização automatica ao servidor e-ship falhou, tentiva de número {k}')
logging.info(f'Conexão do bot de reinicialização automatica ao servidor e-ship falhou, tentiva de número {k}')
enviarEmail2()
break
else:
print(f'Conexão realizada, após {k} tentativas. {data_em_texto}')
logging.info(f'Conexão realizada, após {k} tentativas.')
break
if verconecta1 != None:
print(f'[172.19.0.247] - Conexão realizada!, {data_em_texto}')
logging.info(f'[172.19.0.247] - Conexão realizada!')
else:
print(f'[172.19.0.247] - Conexão NÃO realizada!, {data_em_texto}')
logging.info(f'[172.19.0.247] - Conexão NÃO realizada!')
### execução do script do eship
def script1():
pyautogui.press('esc')
time.sleep(2)
pyautogui.doubleClick(1916,1053)
time.sleep(2)
iniciar = pyautogui.locateOnScreen('iniciar.png', confidence=0.9)
pyautogui.doubleClick(iniciar)
### confere se script rodou, se não tenta mais três vezes 172.19.0.247 hostname: BRZ01WKSAPP02 e 172.19.0.237 hostname: BRZ01WKSAPP07
def verificacao_script1():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
q = 1
w = 3
e = 0
ativo = pyautogui.locateOnScreen('ativo.png', confidence=0.7)
print(ativo)
while ativo == None:
while q <= 10:
print(f'Script não rodou, tentativa {q}')
logging.info(f'Script não rodou, tentativa {q}')
q = q + 1
script1()
time.sleep(80)
ativo = pyautogui.locateOnScreen('ativo.png', confidence=0.7)
if ativo != None:
break
if q == w:
e = e + 1
print(f"Após {q} falhas no script {srvinfo}, estamos enviando o e-mail!")
logging.info(f'Após {q} falhas no script {srvinfo}, estamos enviando o e-mail!')
break
if ativo == None:
enviarEmail1()
pyautogui.hotkey('ctrl_r', 'f12')
break
else:
print(f'Script {srvinfo} rodou, após {q} tentativas.\n horário {data_em_texto}')
logging.info(f'Script {srvinfo} rodou, após {q} tentativas.')
break
if ativo != None:
print(f'Script Realizado. {data_em_texto}')
logging.info(f'Script Realizado.')
else:
print(f'Script NÃO Realizado! {data_em_texto}')
logging.info(f'Script NÃO Realizado!')
### função para encerrar o script
def fechar():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
pyautogui.hotkey('ctrlright', 'f4')
time.sleep(5)
pyautogui.hotkey('alt', 'tab')
time.sleep(0.5)
pyautogui.hotkey('alt', 'f4')
time.sleep(2)
pyautogui.press('enter')
print(f'Script Encerrado, {data_em_texto}')
global srvinfo
srvinfo = 'null'
global srvinfh
srvinfh = 'null'
return
### função para execução dos scripts me ordem
def rodar_script1():
conecta1()
time.sleep(30)
verificacao_conecta1()
time.sleep(5)
script1()
time.sleep(85)
verificacao_script1()
fechar()
### envia o e-mail de falha no script de reset do e-ship em caso de falhas
def enviarEmail1():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
#configurações SMTP
smtp = smtplib.SMTP_SSL('smtp.gmail.com', 465)
email = '[email protected]'
senha = 'ntdihlrreryszhlk'
email_destino = '[email protected]'
#textos e-mail erro script
mensagem_inicialAD01 = (f"Script rodou 3x e não conseguiu resetar o serviço do E-ship no servidor {srvinfo} hostname: {srvinfh}. Favor verificar com Urgência. \n" )
mensagem_final = (f"\nAtenciosamente - Equipe TI - Branco Motores\nHorario da falha: {data_em_texto}")
espacamento = "\n \n"
#envia o email erro script
smtp.login(email,senha)
msg = MIMEMultipart()
msg['From'] = email
msg['To'] = email_destino
msg['Subject'] = "Alerta, script não rodou "
msg.attach(MIMEText(mensagem_inicialAD01, 'plain'))
msg.attach(MIMEText(espacamento, 'plain'))
msg.attach(MIMEText(mensagem_final, 'plain'))
#envia o e-mail
smtp.sendmail(msg['From'], msg['To'], msg.as_string())
smtp.quit()
### envia o e-mail de falha de conexão com os servidores em caso de falha
def enviarEmail2():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
#configurações SMTP
smtp = smtplib.SMTP_SSL('smtp.gmail.com', 465)
email = '[email protected]'
senha = 'ntdihlrreryszhlk'
email_destino = '[email protected]'
#textos e-mail erro de conexão
mensagem_inicialAD01 = (f"Conexão com o servidor {srvinfo} hostname: {srvinfh} falhou três vezes, impossibilitando resetar o serviço do E-ship. \n")
mensagem_final = (f"\nAtenciosamente - Equipe TI - Branco Motores\nHorario da falha: {data_em_texto}")
espacamento = "\n \n"
#envia o email erro de conexão
smtp.login(email,senha)
msg = MIMEMultipart()
msg['From'] = email
msg['To'] = email_destino
msg['Subject'] = "Alerta, erro de conexão com o servidor BRZ01WKSAPP07"
msg.attach(MIMEText(mensagem_inicialAD01, 'plain'))
msg.attach(MIMEText(espacamento, 'plain'))
msg.attach(MIMEText(mensagem_final, 'plain'))
#envia o e-mail
smtp.sendmail(msg['From'], msg['To'], msg.as_string())
smtp.quit()
### desabilitado - e-mail de envio de erro ao conectar no servidor, f
"""def enviarEmail3():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
#configurações SMTP
smtp = smtplib.SMTP_SSL('smtp.gmail.com', 465)
email = '[email protected]'
senha = 'ntdihlrreryszhlk'
email_destino = '[email protected]'
#textos e-mail erro de conexão
mensagem_inicialAD01 = (f"Conexão com o servidor 172.19.0.237 hostname: BRZ01WKSAPP07 falhou três vezes, impossibilitando resetar o serviço do E-ship. \n")
mensagem_final = (f"\nAtenciosamente - Equipe TI - Branco Motores\nHorario da falha: {data_em_texto}")
espacamento = "\n \n"
#envia o email erro de conexão
smtp.login(email,senha)
msg = MIMEMultipart()
msg['From'] = email
msg['To'] = email_destino
msg['Subject'] = "Alerta, erro de conexão com o servidor BRZ01WKSAPP07"
msg.attach(MIMEText(mensagem_inicialAD01, 'plain'))
msg.attach(MIMEText(espacamento, 'plain'))
msg.attach(MIMEText(mensagem_final, 'plain'))
#envia o e-mail
smtp.sendmail(msg['From'], msg['To'], msg.as_string())
smtp.quit()"""
### desabilitado - e-mail de envio de erro ao conectar no servidor
"""def enviarEmail4():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
#configurações SMTP
smtp = smtplib.SMTP_SSL('smtp.gmail.com', 465)
email = '[email protected]'
senha = 'ntdihlrreryszhlk'
email_destino = '[email protected]'
#textos e-mail erro de conexão
mensagem_inicialAD01 = (f"Conexão com o servidor 172.19.0.238 hostname: BRZ01WKSAPP09 falhou três vezes, impossibilitando resetar o serviço do E-ship. \n")
mensagem_final = (f"\nAtenciosamente - Equipe TI - Branco Motores\nHorario da falha: {data_em_texto}")
espacamento = "\n \n"
#envia o email erro de conexão
smtp.login(email,senha)
msg = MIMEMultipart()
msg['From'] = email
msg['To'] = email_destino
msg['Subject'] = "Alerta, erro de conexão com o servidor BRZ01WKSAPP09"
msg.attach(MIMEText(mensagem_inicialAD01, 'plain'))
msg.attach(MIMEText(espacamento, 'plain'))
msg.attach(MIMEText(mensagem_final, 'plain'))
#envia o e-mail
smtp.sendmail(msg['From'], msg['To'], msg.as_string())
smtp.quit()"""
### conecta no servidor: 172.19.0.237 hostname: BRZ01WKSAPP07 (ok)
def conecta2():
time.sleep(1)
pyautogui.hotkey('ctrl', 'alt', 't')
time.sleep(5)
pyautogui.write('remmina')
time.sleep(1)
pyautogui.press('enter')
time.sleep(6)
srv1 = pyautogui.locateOnScreen('237.png')
pyautogui.doubleClick(srv1)
global srvinfo
srvinfo = '172.19.0.237'
global srvinfh
srvinfh = 'BRZ01WKSAPP07'
return
### confere se conectou, se não tenta mais três vezes (172.19.0.237 hostname: BRZ01WKSAPP07)
def verificacao_conecta2():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
k = 1
n = 3
b = 0
verconecta2 = pyautogui.locateOnScreen('verconecta2.png', confidence=0.9)
print(verconecta2)
logging.info(verconecta2)
while verconecta2 == None:
while k <= 10:
print(f'Conexão falhou, tentiva de número {k}')
logging.info(f'Conexão falhou, tentiva de número {k}')
k = k + 1
pyautogui.hotkey('alt', 'tab')
time.sleep(0.2)
pyautogui.hotkey('ctrl', 'c')
time.sleep(0.2)
pyautogui.write('exit')
time.sleep(0.2)
pyautogui.press('enter')
conecta2()
time.sleep(23)
verconecta2 = pyautogui.locateOnScreen('verconecta2.png', confidence=0.9)
if verconecta2 != None:
break
if k == n:
b = b + 1
print(f'Conexão ao servidor falhou, tentiva de número {k}, chamar enviar Email2()')
logging.info(f'Conexão ao servidor falhou, tentiva de número {k}, chamar enviar Email2()')
break
if verconecta2 == None:
print(f'Conexão do bot de reinicialização automatica ao servidor e-ship falhou, tentiva de número {k}')
logging.info(f'Conexão do bot de reinicialização automatica ao servidor e-ship falhou, tentiva de número {k}')
enviarEmail2()
break
else:
print(f'Conexão realizada, após {k} tentativas.')
logging.info(f'Conexão realizada, após {k} tentativas.')
break
if verconecta2 != None:
print(f'[172.19.0.237] - Conexão realizada!, {data_em_texto}')
logging.info(f'[172.19.0.237] - Conexão realizada!')
else:
print(f'[172.19.0.237] - Conexão NÃO realizada!{data_em_texto}')
logging.info(f'[172.19.0.237] - Conexão NÃO realizada!')
### função para execução dos scripts em ordem
def rodar_script2():
conecta2()
time.sleep(30)
verificacao_conecta2()
time.sleep(5)
script1()
time.sleep(80)
verificacao_script1()
fechar()
### conecta no servidor: 172.19.0.238 hostname: BRZ01WKSAPP09
def conecta3():
time.sleep(1)
pyautogui.hotkey('ctrl', 'alt', 't')
time.sleep(5)
pyautogui.write('remmina')
time.sleep(1)
pyautogui.press('enter')
time.sleep(6)
srv2 = pyautogui.locateOnScreen('238.png')
pyautogui.doubleClick(srv2)
global srvinfo
srvinfo = '172.19.0.238'
global srvinfh
srvinfh = 'BRZ01WKSAPP09'
return
### confere se conectou, se não tenta mais três vezes (172.19.0.238 hostname: BRZ01WKSAPP09)
def verificacao_conecta3():
data_e_hora_atuais = datetime.now()
data_em_texto = data_e_hora_atuais.strftime('%d/%m/%Y %H:%M')
k = 1
n = 3
b = 0
verconecta3 = pyautogui.locateOnScreen('verconecta3.png', confidence=0.9)
print(verconecta3)
logging.info(verconecta3)
while verconecta3 == None:
while k <= 10:
print(f'Conexão falhou, tentiva de número {k}')
logging.info(f'Conexão falhou, tentiva de número {k}')
k = k + 1
pyautogui.hotkey('alt', 'tab')
time.sleep(0.2)
pyautogui.hotkey('ctrl', 'c')
time.sleep(0.2)
pyautogui.write('exit')
time.sleep(0.2)
pyautogui.press('enter')
conecta2()
time.sleep(23)
verconecta3 = pyautogui.locateOnScreen('verconecta3.png', confidence=0.9)
if verconecta3 != None:
break
if k == n:
b = b + 1
print(f'Conexão ao servidor falhou, tentiva de número {k}, chamar enviar Email2()')
logging.info(f'Conexão ao servidor falhou, tentiva de número {k}, chamar enviar Email2()')
break
if verconecta3 == None:
print(f'Conexão do bot de reinicialização automatica ao servidor e-ship falhou, tentiva de número {k}')
logging.info(f'Conexão do bot de reinicialização automatica ao servidor e-ship falhou, tentiva de número {k}')
enviarEmail2()
break
else:
print(f'Conexão realizada, após {k} tentativas.')
logging.info(f'Conexão realizada, após {k} tentativas.')
break
if verconecta3 != None:
print(f'[172.19.0.238] - Conexão realizada!, {data_em_texto}')
logging.info(f'[172.19.0.238] - Conexão realizada!')
else:
print(f'[172.19.0.238] - Conexão NÃO realizada!{data_em_texto}')
logging.info(f'[172.19.0.238] - Conexão NÃO realizada!')
### função para execução dos scripts em ordem (238)
def rodar_script3():
conecta3()
time.sleep(30)
verificacao_conecta3()
time.sleep(5)
script1()
time.sleep(80)
verificacao_script1()
fechar()
schedule.every().day.at('06:30').do(rodar_script1)
schedule.every().day.at('12:30').do(rodar_script1)
schedule.every().day.at('15:00').do(rodar_script1)
schedule.every().day.at('20:30').do(rodar_script1)
schedule.every().day.at('06:45').do(rodar_script2)
schedule.every().day.at('12:45').do(rodar_script2)
schedule.every().day.at('15:15').do(rodar_script2)
schedule.every().day.at('20:45').do(rodar_script2)
schedule.every().day.at('06:55').do(rodar_script3)
schedule.every().day.at('12:55').do(rodar_script3)
schedule.every().day.at('15:25').do(rodar_script3)
schedule.every().day.at('20:55').do(rodar_script3)
def minha_tarefa():
while 1:
schedule.run_pending()
time.sleep(1)
thread = threading.Thread(target=minha_tarefa)
thread.start()
#globais bot telegram
senha1 = 'senha1'
senha2 = 'senha2'
senha3 = 'senha3'
imagem = 'senha4'
print237 = 'senha5'
print238 = 'senha6'
print247 = 'senha7'
tempo_espera = 300 # tempo em segundos para reiniciar os servidores
tempo_espera_print = 60 # tempo em segundos para capturar o status atual dos servidores
ultima_execucao = 0
bot = telebot.TeleBot(CHAVE_API)
def verificacao(mensagem):
global ultima_execucao
agora = time.time()
if mensagem.text == senha1 or mensagem.text == senha2 or mensagem.text == senha3 or mensagem.text == imagem or mensagem.text == print237 or mensagem.text == print238 or mensagem.text == print247:
hora_atual = datetime.now().hour
if (hora_atual >= 6 and hora_atual < 7) or (hora_atual >= 12 and hora_atual < 13) or (hora_atual >= 15 and hora_atual < 16) or (hora_atual >= 20 and hora_atual < 21):
return "Não é possível rodar o script nestes horários: 6h-7h, 12h-13h, 15h-16h, 20h-21h."
if mensagem.text == print237 or mensagem.text == print238 or mensagem.text == print247 or mensagem.text == imagem:
tempo_espera_atual = tempo_espera_print
else:
tempo_espera_atual = tempo_espera
if agora - ultima_execucao >= tempo_espera_atual:
ultima_execucao = agora
return True
else:
tempo_restante = int(tempo_espera_atual - (agora - ultima_execucao))
return f"Aguarde pelo menos {tempo_restante} segundos para rodar o script novamente."
@bot.message_handler(func=lambda mensagem: True)
def responder(mensagem):
global ultima_execucao
verifica = verificacao(mensagem)
if verifica == True:
ultima_execucao = time.time()
if mensagem.text == senha1:
bot.reply_to(mensagem, "Password aceita, script 172.19.0.247 iniciando. Aguarde pelo menos 5 minutos para rodar novamente.")
print(f'API telegram confirmada, rodando script 247 {datetime.now().strftime("%d/%m/%Y %H:%M")}')
logging.info(f'Acionamento script 172.19.0.247 por chatbot')
rodar_script1()
elif mensagem.text == senha2:
bot.reply_to(mensagem, "Password aceita, script 172.19.0.238 iniciando. Aguarde pelo menos 5 minutos para rodar novamente.")
print(f'API telegram confirmada, rodando script 238 {datetime.now().strftime("%d/%m/%Y %H:%M")}')
logging.info(f'Acionamento script 172.19.0.238 por chatbot')
rodar_script3()
elif mensagem.text == senha3:
bot.reply_to(mensagem, "Password aceita, script 172.19.0.237 iniciando. Aguarde pelo menos 5 minutos para rodar novamente.")
print(f'API telegram confirmada, rodando script 237 {datetime.now().strftime("%d/%m/%Y %H:%M")}')
logging.info(f'Acionamento script 172.19.0.237 por chatbot')
rodar_script2()
elif mensagem.text == imagem:
bot.reply_to(mensagem, "segue o ultimo print gerado pelo sistema")
print(f'print de erro solicitado {datetime.now().strftime("%d/%m/%Y %H:%M")}')
logging.info(f'print de erro solicitado por chatbot')
enviar_imagem(mensagem, '/home/lucas/Documentos/BotEship/remmina.png')
elif mensagem.text == print237:
bot.reply_to(mensagem, "Solicitado o print da tela atual do 172.19.0.237, aguarde 60 segundos")
print(f'print da tela atual do 172.19.0.237 solicitado {datetime.now().strftime("%d/%m/%Y %H:%M")}')
logging.info(f'print da tela atual do 172.19.0.237 solicitado por chatbot')
agr237(mensagem)
elif mensagem.text == print238:
bot.reply_to(mensagem, "Solicitado o print da tela atual do 172.19.0.238, aguarde 60 segundos.")
print(f'print da tela atual do 172.19.0.238 solicitado {datetime.now().strftime("%d/%m/%Y %H:%M")}')
logging.info(f'print da tela atual do 172.19.0.238 solicitado por chatbot')
agr238(mensagem)
elif mensagem.text == print247:
bot.reply_to(mensagem, "Solicitado o print da tela atual do 172.19.0.247, aguarde 60 segundos.")
print(f'print da tela atual do 172.19.0.247 solicitado {datetime.now().strftime("%d/%m/%Y %H:%M")}')
logging.info(f'print da tela atual do 172.19.0.247 solicitado por chatbot')
agr247(mensagem)
elif verifica:
bot.reply_to(mensagem, verifica)
else:
texto = "Bem-vindo ao BOT Branco - eship. Digite a senha para rodar os scripts."
bot.reply_to(mensagem, texto)
def enviar_imagem(mensagem, caminho_imagem):
imagem = open(caminho_imagem, 'rb')
bot.send_photo(mensagem.chat.id, imagem)
imagem.close()
def agr247(mensagem):
conecta1()
time.sleep(25)
pyautogui.hotkey('ctrlright', 'f12')
time.sleep(1)
enviar_imagem(mensagem, '/home/lucas/Documentos/BotEship/remmina.png')
time.sleep(2)
bot.reply_to(mensagem, "Prontinho, print coletado agora do servidor 172.19.0.247 agora!")
fechar()
def agr237(mensagem):
conecta2()
time.sleep(25)
pyautogui.hotkey('ctrlright', 'f12')
time.sleep(1)
enviar_imagem(mensagem, '/home/lucas/Documentos/BotEship/remmina.png')
time.sleep(2)
bot.reply_to(mensagem, "Prontinho, print coletado agora do servidor 172.19.0.237 agora!")
fechar()
def agr238(mensagem):
conecta3()
time.sleep(25)
pyautogui.hotkey('ctrlright', 'f12')
time.sleep(1)
enviar_imagem(mensagem, '/home/lucas/Documentos/BotEship/remmina.png')
time.sleep(2)
bot.reply_to(mensagem, "Prontinho, print coletado agora do servidor 172.19.0.238!")
fechar()
respostas = [
"Desculpe, não entendi. Pode tentar novamente?",
"Não tenho certeza se entendi o que você quis dizer. Pode tentar de outra forma?",
"Desculpe, não consegui entender o que você queria dizer.",
"Poderia reformular? Não entendi",
"Não tenho certeza do que você está tentando dizer. Pode tentar novamente?",
"Não consegui entender sua mensagem.",
"Desculpe, não entendi.",
]
resposta_aleatoria = random.choice(respostas)
bot.polling()
"""
tempo_atual = datetime.datetime.now()
# Verifique o tipo da mensagem.date
tempo_maximo_interacao = 1
ultima_interacao = (tempo_atual - datetime.datetime.fromtimestamp(mensagem.date)).total_seconds() / 60
if ultima_interacao > tempo_maximo_interacao:
# Se o tempo de interação for maior que o tempo máximo permitido, enviar a mensagem de boas-vindas
texto = "Bem-vindo ao BOT Branco - eship. Digite a senha para rodar os scripts."
bot.reply_to(mensagem, texto)
else:
# Se o tempo de interação for menor que o tempo máximo permitido, escolher uma resposta aleatória da lista
resposta_aleatoria = random.choice(respostas)
bot.reply_to(mensagem, resposta_aleatoria)"""