diff --git a/Attrap_bot.py b/Attrap_bot.py index ad7237b6cb24141aa27d9e52fd104ac0e26961b3..1bdd32ac6d997a84ecfc01f78b488a5d56fb6fc9 100644 --- a/Attrap_bot.py +++ b/Attrap_bot.py @@ -209,18 +209,18 @@ class Attrap_bot: def get_smtp_sender(self, config_id): if self.config.get('smtp'): - if self.config['smtp'].get(config_id) and self.config['smtp'][config_id]['hostname']: - smtp_sender = Attrap_bot.SMTP_sender(self.config['smtp'][config_id]['hostname']) - if self.config['smtp'][config_id].get('username'): - smtp_sender.set_username(self.config['smtp'][config_id]['username']) - if self.config['smtp'][config_id].get('password'): - smtp_sender.set_password(self.config['smtp'][config_id]['password']) - if self.config['smtp'][config_id].get('port'): - smtp_sender.set_port(self.config['smtp'][config_id]['port']) - if self.config['smtp'][config_id].get('ssl'): - smtp_sender.set_ssl(self.config['smtp'][config_id]['ssl']) - if self.config['smtp'][config_id].get('starttls'): - smtp_sender.set_starttls(self.config['smtp'][config_id]['starttls']) - return smtp_sender + if self.config['smtp'].get(config_id) and self.config['smtp'][config_id]['hostname']: + smtp_sender = Attrap_bot.SMTP_sender(self.config['smtp'][config_id]['hostname']) + if self.config['smtp'][config_id].get('username'): + smtp_sender.set_username(self.config['smtp'][config_id]['username']) + if self.config['smtp'][config_id].get('password'): + smtp_sender.set_password(self.config['smtp'][config_id]['password']) + if self.config['smtp'][config_id].get('port'): + smtp_sender.set_port(self.config['smtp'][config_id]['port']) + if self.config['smtp'][config_id].get('ssl'): + smtp_sender.set_ssl(self.config['smtp'][config_id]['ssl']) + if self.config['smtp'][config_id].get('starttls'): + smtp_sender.set_starttls(self.config['smtp'][config_id]['starttls']) + return smtp_sender logger.warning(f"La configuration Mastodon est invalide (id: {config_id})") return None diff --git a/cli.py b/cli.py index d562c044460df253012aded3ed27abc22ffd4ee2..9baca1d89f0d51f6db31cbe275e985879fe4c82f 100755 --- a/cli.py +++ b/cli.py @@ -25,6 +25,7 @@ def create_config(keys, value): else: return {keys[-1]: value} + def merge_dicts(a: dict, b: dict, path=[]): for key in b: if key in a: @@ -36,6 +37,7 @@ def merge_dicts(a: dict, b: dict, path=[]): a[key] = b[key] return a + parser = argparse.ArgumentParser( prog='cli.py', description='Recherche les derniers RAA correspondant à une certaine requête et envoie les résultats par email et sur Mastodon'