diff --git a/app/matrix_bot/config.py b/app/matrix_bot/config.py index a08f8b2..09bb460 100644 --- a/app/matrix_bot/config.py +++ b/app/matrix_bot/config.py @@ -45,6 +45,7 @@ class BotLibConfig(BaseSettings): bot_lib_config = BotLibConfig() +print(bot_lib_config.dict()) structlog.configure( wrapper_class=structlog.make_filtering_bound_logger(bot_lib_config.log_level), ) diff --git a/app/matrix_bot/eventparser.py b/app/matrix_bot/eventparser.py index cc0fde5..574ba4e 100755 --- a/app/matrix_bot/eventparser.py +++ b/app/matrix_bot/eventparser.py @@ -57,11 +57,11 @@ def sender_username(self) -> str: def sender_domain(self) -> str | None: """ Sender IDs are formatted like this: "@-: - e.g. @john.doe-ministere_example.gouv.fr1:agent.ministere_example.tchap.gouv.fr + e.g. @john.doe-ministere_example.gouv.fr1:agent.ministere_example.tchap.gouv.frmerci """ match: re.Match[str] | None = re.search( - r"(?<=\-)(.*?)[0-9]*(?=\:)", self.event.sender - ) # match the domain name (between the first "-" and ":", with optional numbers to ignore at the end) + r"(?<=\-)[^\-\:]+[0-9]*(?=\:)", self.event.sender + ) # match the domain name (between the last "-" and ":", with optional numbers to ignore at the end of the domain) WARNING: this regex is not perfect and doesn't work for domain names with dashes in it like "developpement-durable.gouv.fr" if match: return match.group(0) logger.warning("Could not extract domain from sender ID", sender_id=self.sender_id) diff --git a/pyproject.toml b/pyproject.toml index 67f3c73..dda033f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "albert-tchapbot" -version = "0.1.6" +version = "0.1.7" description = "Albert Tchap Bot" authors = [ { name = "Pôle d'Expertise de la Régulation Numérique", email = "contact.peren@finances.gouv.fr" },