diff --git a/main.py b/main.py index 6ee7f0a..6cc1eac 100644 --- a/main.py +++ b/main.py @@ -393,7 +393,6 @@ def main(driver: Chrome, logger = logging.getLogger('main')): try: flow.react(Wait) attempts += 1 - name = cell(index, column.recipient).value email = cell(index, column.email).value try: code = str(cell(index, column.code).value) @@ -440,7 +439,6 @@ def main(driver: Chrome, logger = logging.getLogger('main')): flow.allow(Skip) flow.react(Wait) progress['email'] = str(email) - progress['recipient'] = str(name) logger.info('[%d/%d] Sending to %s', index-1, limit-1, email) clean = True error = None @@ -470,11 +468,14 @@ def main(driver: Chrome, logger = logging.getLogger('main')): action = ActionChains(driver) hello = hello or locale.default - if name is not None and (name := str(name).strip()) and not contains_non_latin_alphabet(name): - parts = HumanName(name) - parts.capitalize(force=True) - short = len(parts.first) < 3 or (len(parts.first) < 5 and parts.first.endswith('.')) - hello = ' '.join(filter(None, [hello, parts.title, parts.first, (parts.middle or parts.last) if short else None])) + if column.recipient in headers: + if name := str(cell(index, column.recipient).value).strip(): + if not contains_non_latin_alphabet(name): + progress['recipient'] = str(name) + parts = HumanName(name) + parts.capitalize(force=True) + short = len(parts.first) < 3 or (len(parts.first) < 5 and parts.first.endswith('.')) + hello = ' '.join(filter(None, [hello, parts.title, parts.first, (parts.middle or parts.last) if short else None])) hello += ',' action.send_keys(hello).perform()