From 67bec0508e0464a24d562ec26b977987ee5b8b5f Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Mon, 21 Jun 2021 02:14:33 +0100 Subject: [PATCH] use re.compile on URL_REGEX --- app.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index dc26e4f..1e74520 100644 --- a/app.py +++ b/app.py @@ -10,8 +10,7 @@ from os import getenv PRICE_REGEX = re.compile( "(?:(?P[GBP|EUR|£|€])(?P[0-9]+(?:\.[0-9]{1,2})))") MODEL_REGEX = re.compile("[Rr][Tt][Xx] ?(?P30[6789]0( [Tt][Ii])?).?") - -URL_REGEX = "(?:(?:https?|ftp):\/\/|\b(?:[a-z\d]+\.))(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s`!()\[\]{};:'.,<>?«»“”‘’]))?" +URL_REGEX = re.compile("(?:(?:https?|ftp):\/\/|\b(?:[a-z\d]+\.))(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s`!()\[\]{};:'.,<>?«»“”‘’]))?") PARTALERT_ASIN = re.compile("asin=(?P[0-9a-zA-Z]{1,10})") PARTALERT_TLD = re.compile("tld=(?P\.(?:it|es|de|fr|co\.uk))") @@ -122,7 +121,7 @@ def on_message(resp): content = m['content'] if channelID in MONITORED_CHANNELS: - urls = re.findall(URL_REGEX, content) + urls = URL_REGEX.findall(content) if (urls): check_urls(urls)