Difficulty applying decision structure

Hi guys, how do I MAKE an if, else loop in the spaces that I left in evidence with a comment?

from botcity.core import DesktopBot
import chardet
import codecs
import pyperclip
import time

caminho_arquivo = ‘C:\Users\Rafael\Desktop\MercadoLivre\ArquivosDeTexto\mensagens.txt’
caminho_arquivo2 = f’C:\Users\Rafael\Desktop\MercadoLivre\ArquivosDeTexto\mensagens.txt’

def clicar_enviar(self):
if not self.find( “BotãoEnviar_1”, matching=0.97, waiting_time=10000):
self.not_found(“BotãoEnviar_1”)
self.click()
clicar_botao_enviar = clicar_enviar
def clicar_no_campo_caixa_de_mensasagens(self):
if not self.find( “mensagem1”, matching=0.97, waiting_time=10000):
self.not_found(“mensagem1”)
self.click_relative(162, 11)
#REPETIR AQUI
class Bot(DesktopBot):
def action(self, execution=None):
if not self.find( “ClicaNoIconeDoNavegador”, matching=0.97, waiting_time=10000):
self.not_found(“ClicaNoIconeDoNavegador”)
self.click()
i = 1
while i > 0:
if not self.find( “HomeDoMercadoLivre”, matching=0.97, waiting_time=10000):
self.not_found(“HomeDoMercadoLivre”)
self.click()
time.sleep(4)
while not self.find( “SinoVermelho”, matching=0.97, waiting_time=10000):
self.not_found(“SinoVermelho”)
self.click()

IF YOU FIND THE IMAGE "You sold GTAV" DO THIS BLOCK, OTHERWISE, DO THE ESLSE:-----------------------------------------------------------------------
	
            if not self.find( "VoceVendeuGTAV", matching=0.97, waiting_time=10000):     #Estrura de decisão começa aqui
                self.not_found("VoceVendeuGTAV")
            self.click_relative(184, 75)
            while not self.find( "VerMensagem", matching=0.97, waiting_time=10000):
                self.not_found("VerMensagem")
            self.click()
            if not self.find( "CampoDeMensagemSelecionado", matching=0.97, waiting_time=10000):
                self.not_found("CampoDeMensagemSelecionado")
            self.click_relative(125, 9)
            with open(caminho_arquivo2, 'rb') as f:
                codificacao = chardet.detect(f.read())['encoding']
            with codecs.open(caminho_arquivo, 'r', encoding=codificacao) as f:
                texto = f.read()
            pyperclip.copy(texto)
            self.paste()
            time.sleep(2)

            if not self.find( "Enviar", matching=0.97, waiting_time=10000):
                self.not_found("Enviar")
            self.click()

            clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)

            A = "https://drive.google.com/file/d/1uJzdN5JDc28GBx1yZmxReIMxfhTQKB_8/view?usp=sharing"
            B = "https://drive.google.com/file/d/1ks82TEI6_sDBqPVYTS4NijhNE1STPFsQ/view?usp=sharing"
            C = "https://drive.google.com/file/d/13Wvox0Ty3Th5cO-VMkafkGDPqtUyoAQ0/view?usp=sharing"
            D = "https://drive.google.com/file/d/1CHTD8Ht_QierOXkCU2uQ6idTAJNu56HX/view?usp=sharing"
            E = "https://drive.google.com/file/d/12gHXhCm4hRZXwVd9zssc1EOwRDd7bOeN/view?usp=sharing"
            F = "https://drive.google.com/file/d/16Mz9qiKxVSQqwS6t9nukJcEQZC7pfCGx/view?usp=sharing"
            G = "https://drive.google.com/file/d/1hpact71QxmjmWjYDcKcFl0Es7jOWe09s/view?usp=sharing"
            H = "https://drive.google.com/file/d/1eFqkLdGYFfesmYd73S-AnAEtZCXHnjRD/view?usp=sharing"
            K = "https://drive.google.com/file/d/1NJKVTIHMd2KQXVNnAenZQy06N6tP3YBb/view?usp=sharing"
            J = "https://drive.google.com/file/d/1Aeuk7BYDVQGzVMK7kNubSGulL3ANmnQC/view?usp=sharing"
            L = "https://drive.google.com/file/d/156DWOBhylT2A2t9VruD9Kx-6AvqrlCwv/view?usp=sharing"
            M = "https://drive.google.com/file/d/1FSlSRL4P-v7leIxaG6a8gmr6COTjs6W5/view?usp=sharing"
            N = "https://drive.google.com/file/d/1OT3yljORzMq0seYwxLhdKHY2tFiz08Ux/view?usp=sharing"
            O = "https://drive.google.com/file/d/1lay62N9KYvuID1rEUjJlepf-S75pziGU/view?usp=sharing"
            P = "https://drive.google.com/file/d/1GPSR_v6YORf-sZyugLpxis2YHjCX7ove/view?usp=sharing"
            Q = "https://drive.google.com/file/d/1bZWLsBHWL5OStHnEWWKdiKSC6xKa6f_-/view?usp=sharing"
            R = "https://drive.google.com/file/d/1N6aC0Aq_qCcE-GRDursVfDWR-SMQOcsD/view?usp=sharing"
            S = "https://drive.google.com/file/d/15qyloKmDGP0b5SYwvATtRfwV6Nx3Sdg1/view?usp=sharing"
            T = "https://drive.google.com/file/d/1LmVc0wPut5-0p3mTQwyJFy4_D4OHK4K9/view?usp=sharing"
            U = "https://drive.google.com/file/d/18O3uKls2Ybt0lI8WsYIy2gzJx2y3GdrM/view?usp=sharing"

            self.paste(A), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(B), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(C), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(D), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(E), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(F), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(G), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(H), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(K), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(J), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(L), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(M), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(N), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(O), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(P), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(Q), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(R), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(S), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(T), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            self.paste(U), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
            
            # IF NOT, DO:---------------------------------------------------------------------------------------------

            if not self.find( "Excluir_E_Voltar_A_Checagem", matching=0.97, waiting_time=10000):
                self.not_found("Excluir_E_Voltar_A_Checagem")
            self.move_relative(17, 45)
            
    Retorna ao loop While acima
        
@staticmethod
def not_found(label):
    print(f"Element not found: {label}")

if name == ‘main’:
Bot.main()

Hi Rafael, you could do something like this:

if self.find( "You SoldGTAV", matching=0.97, waiting_time=10000): 
	
    if not self.find( "VoceVendeuGTAV", matching=0.97, waiting_time=10000):     #Estrura de decisão começa aqui
        self.not_found("VoceVendeuGTAV")
    self.click_relative(184, 75)
    while not self.find( "VerMensagem", matching=0.97, waiting_time=10000):
        self.not_found("VerMensagem")
    self.click()
    if not self.find( "CampoDeMensagemSelecionado", matching=0.97, waiting_time=10000):
        self.not_found("CampoDeMensagemSelecionado")
    self.click_relative(125, 9)
    with open(caminho_arquivo2, 'rb') as f:
        codificacao = chardet.detect(f.read())['encoding']
    with codecs.open(caminho_arquivo, 'r', encoding=codificacao) as f:
        texto = f.read()
    pyperclip.copy(texto)
    self.paste()
    time.sleep(2)

    if not self.find( "Enviar", matching=0.97, waiting_time=10000):
        self.not_found("Enviar")
    self.click()

    clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)

    A = "https://drive.google.com/file/d/1uJzdN5JDc28GBx1yZmxReIMxfhTQKB_8/view?usp=sharing"
    B = "https://drive.google.com/file/d/1ks82TEI6_sDBqPVYTS4NijhNE1STPFsQ/view?usp=sharing"
    C = "https://drive.google.com/file/d/13Wvox0Ty3Th5cO-VMkafkGDPqtUyoAQ0/view?usp=sharing"
    D = "https://drive.google.com/file/d/1CHTD8Ht_QierOXkCU2uQ6idTAJNu56HX/view?usp=sharing"
    E = "https://drive.google.com/file/d/12gHXhCm4hRZXwVd9zssc1EOwRDd7bOeN/view?usp=sharing"
    F = "https://drive.google.com/file/d/16Mz9qiKxVSQqwS6t9nukJcEQZC7pfCGx/view?usp=sharing"
    G = "https://drive.google.com/file/d/1hpact71QxmjmWjYDcKcFl0Es7jOWe09s/view?usp=sharing"
    H = "https://drive.google.com/file/d/1eFqkLdGYFfesmYd73S-AnAEtZCXHnjRD/view?usp=sharing"
    K = "https://drive.google.com/file/d/1NJKVTIHMd2KQXVNnAenZQy06N6tP3YBb/view?usp=sharing"
    J = "https://drive.google.com/file/d/1Aeuk7BYDVQGzVMK7kNubSGulL3ANmnQC/view?usp=sharing"
    L = "https://drive.google.com/file/d/156DWOBhylT2A2t9VruD9Kx-6AvqrlCwv/view?usp=sharing"
    M = "https://drive.google.com/file/d/1FSlSRL4P-v7leIxaG6a8gmr6COTjs6W5/view?usp=sharing"
    N = "https://drive.google.com/file/d/1OT3yljORzMq0seYwxLhdKHY2tFiz08Ux/view?usp=sharing"
    O = "https://drive.google.com/file/d/1lay62N9KYvuID1rEUjJlepf-S75pziGU/view?usp=sharing"
    P = "https://drive.google.com/file/d/1GPSR_v6YORf-sZyugLpxis2YHjCX7ove/view?usp=sharing"
    Q = "https://drive.google.com/file/d/1bZWLsBHWL5OStHnEWWKdiKSC6xKa6f_-/view?usp=sharing"
    R = "https://drive.google.com/file/d/1N6aC0Aq_qCcE-GRDursVfDWR-SMQOcsD/view?usp=sharing"
    S = "https://drive.google.com/file/d/15qyloKmDGP0b5SYwvATtRfwV6Nx3Sdg1/view?usp=sharing"
    T = "https://drive.google.com/file/d/1LmVc0wPut5-0p3mTQwyJFy4_D4OHK4K9/view?usp=sharing"
    U = "https://drive.google.com/file/d/18O3uKls2Ybt0lI8WsYIy2gzJx2y3GdrM/view?usp=sharing"

    self.paste(A), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(B), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(C), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(D), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(E), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(F), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(G), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(H), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(K), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(J), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(L), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(M), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(N), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(O), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(P), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(Q), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(R), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(S), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(T), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(U), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
        
else:
    if not self.find( "Excluir_E_Voltar_A_Checagem", matching=0.97, waiting_time=10000):
        self.not_found("Excluir_E_Voltar_A_Checagem")
    self.move_relative(17, 45)

Or

while self.find( "You SoldGTAV", matching=0.97, waiting_time=10000): 
    if not self.find( "VoceVendeuGTAV", matching=0.97, waiting_time=10000):     #Estrura de decisão começa aqui
        self.not_found("VoceVendeuGTAV")
    self.click_relative(184, 75)
    while not self.find( "VerMensagem", matching=0.97, waiting_time=10000):
        self.not_found("VerMensagem")
    self.click()
    if not self.find( "CampoDeMensagemSelecionado", matching=0.97, waiting_time=10000):
        self.not_found("CampoDeMensagemSelecionado")
    self.click_relative(125, 9)
    with open(caminho_arquivo2, 'rb') as f:
        codificacao = chardet.detect(f.read())['encoding']
    with codecs.open(caminho_arquivo, 'r', encoding=codificacao) as f:
        texto = f.read()
    pyperclip.copy(texto)
    self.paste()
    time.sleep(2)

    if not self.find( "Enviar", matching=0.97, waiting_time=10000):
        self.not_found("Enviar")
    self.click()

    clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)

    A = "https://drive.google.com/file/d/1uJzdN5JDc28GBx1yZmxReIMxfhTQKB_8/view?usp=sharing"
    B = "https://drive.google.com/file/d/1ks82TEI6_sDBqPVYTS4NijhNE1STPFsQ/view?usp=sharing"
    C = "https://drive.google.com/file/d/13Wvox0Ty3Th5cO-VMkafkGDPqtUyoAQ0/view?usp=sharing"
    D = "https://drive.google.com/file/d/1CHTD8Ht_QierOXkCU2uQ6idTAJNu56HX/view?usp=sharing"
    E = "https://drive.google.com/file/d/12gHXhCm4hRZXwVd9zssc1EOwRDd7bOeN/view?usp=sharing"
    F = "https://drive.google.com/file/d/16Mz9qiKxVSQqwS6t9nukJcEQZC7pfCGx/view?usp=sharing"
    G = "https://drive.google.com/file/d/1hpact71QxmjmWjYDcKcFl0Es7jOWe09s/view?usp=sharing"
    H = "https://drive.google.com/file/d/1eFqkLdGYFfesmYd73S-AnAEtZCXHnjRD/view?usp=sharing"
    K = "https://drive.google.com/file/d/1NJKVTIHMd2KQXVNnAenZQy06N6tP3YBb/view?usp=sharing"
    J = "https://drive.google.com/file/d/1Aeuk7BYDVQGzVMK7kNubSGulL3ANmnQC/view?usp=sharing"
    L = "https://drive.google.com/file/d/156DWOBhylT2A2t9VruD9Kx-6AvqrlCwv/view?usp=sharing"
    M = "https://drive.google.com/file/d/1FSlSRL4P-v7leIxaG6a8gmr6COTjs6W5/view?usp=sharing"
    N = "https://drive.google.com/file/d/1OT3yljORzMq0seYwxLhdKHY2tFiz08Ux/view?usp=sharing"
    O = "https://drive.google.com/file/d/1lay62N9KYvuID1rEUjJlepf-S75pziGU/view?usp=sharing"
    P = "https://drive.google.com/file/d/1GPSR_v6YORf-sZyugLpxis2YHjCX7ove/view?usp=sharing"
    Q = "https://drive.google.com/file/d/1bZWLsBHWL5OStHnEWWKdiKSC6xKa6f_-/view?usp=sharing"
    R = "https://drive.google.com/file/d/1N6aC0Aq_qCcE-GRDursVfDWR-SMQOcsD/view?usp=sharing"
    S = "https://drive.google.com/file/d/15qyloKmDGP0b5SYwvATtRfwV6Nx3Sdg1/view?usp=sharing"
    T = "https://drive.google.com/file/d/1LmVc0wPut5-0p3mTQwyJFy4_D4OHK4K9/view?usp=sharing"
    U = "https://drive.google.com/file/d/18O3uKls2Ybt0lI8WsYIy2gzJx2y3GdrM/view?usp=sharing"

    self.paste(A), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(B), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(C), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(D), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(E), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(F), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(G), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(H), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(K), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(J), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(L), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(M), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(N), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(O), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(P), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(Q), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(R), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(S), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(T), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    self.paste(U), clicar_botao_enviar(self), time.sleep(2), clicar_no_campo_caixa_de_mensasagens(self), time.sleep(2)
    
else:
    if self.find( "Excluir_E_Voltar_A_Checagem", matching=0.97, waiting_time=10000):
        self.move_relative(17, 45)
        pass

Remembering that in this second option, if the image “You SoldGTAV” does not leave the screen, this looping will be infinite, and it will need some work to finish it.

Thank you, it worked