now really works parse invisible lab infection

This commit is contained in:
Your Name 2024-12-19 23:19:31 +03:00
parent e00b3ff2bf
commit 22422e5d0b

View file

@ -21,67 +21,67 @@ def find_infect_theme(text):
# current order in theme: # current order in theme:
# ('infected', 'bio_expr', 'infected days', 'pathogen remaining') # ('infected', 'bio_expr', 'infected days', 'pathogen remaining')
# UA theme # UA theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> йобнув.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> йобнув.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) біо-ресурса", r"([0-9\.\,k]+) біо-ресурса",
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# RU theme # RU theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> подверг.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> подверг.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme, default_bioexpr_theme,
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# EN theme # EN theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) pcs\.", r"([0-9\.\,k]+) pcs\.",
r' for ([0-9\ ]+) d.*', r' for ([0-9\ ]+) d.*',
r'Remaining: ([0-9\ ]+)'), r'Remaining: ([0-9\ ]+)'),
# AZ theme # AZ theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> сикди.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> сикди.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"верир: ([0-9\.\,k]+)", r"верир: ([0-9\.\,k]+)",
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# "ПК гик" theme # "ПК гик" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> насрал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> насрал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"потеряет: ([0-9\.\,k]+)", r"потеряет: ([0-9\.\,k]+)",
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# "Новогодняя" theme # "Новогодняя" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> подверг заморозке.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> подверг заморозке.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme, default_bioexpr_theme,
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# "Сексуальная индустрия" theme # "Сексуальная индустрия" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a>.+выебал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a>.+выебал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"кончила ([0-9\.\,k]+)", r"кончила ([0-9\.\,k]+)",
r' ещё ([0-9\ ]+) д.*', r' ещё ([0-9\ ]+) д.*',
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# "Аферисты в сетях" theme # "Аферисты в сетях" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> атаковал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> атаковал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"приносит: ([0-9\.\,k]+)", r"приносит: ([0-9\.\,k]+)",
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# "Квадробер" theme # "Квадробер" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a>.+бешенству.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a>.+бешенству.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"корма: ([0-9\.\,k]+)", r"корма: ([0-9\.\,k]+)",
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# UA theme [via trust] # UA theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> за допомогою довіреності зазнала зараження.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> за допомогою довіреності зазнала зараження.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) біо-ресурса", r"([0-9\.\,k]+) біо-ресурса",
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# RU theme [via trust] # RU theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> при помощи доверенности подвергла заражению.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> при помощи доверенности подвергла заражению.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme, default_bioexpr_theme,
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
# EN theme [via trust] # EN theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> by authorization infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> by authorization infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) pcs\.", r"([0-9\.\,k]+) pcs\.",
r' for ([0-9\ ]+) d.*', r' for ([0-9\ ]+) d.*',
r'Remaining: ([0-9\ ]+)'), r'Remaining: ([0-9\ ]+)'),
# idk what is theme [via trust] # idk what is theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)?">.*</a> при помощи анонимуса атаковала.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">', (r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> при помощи анонимуса атаковала.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r'приносит: ([0-9\.\,k]+)', r'приносит: ([0-9\.\,k]+)',
default_infected_days_theme, default_infected_days_theme,
default_pathogen_remaining_theme), default_pathogen_remaining_theme),
@ -90,9 +90,14 @@ def find_infect_theme(text):
trying_theme_index = bio_attack_themes.index(theme) trying_theme_index = bio_attack_themes.index(theme)
logger.debug(f'trying theme {trying_theme_index}...') logger.debug(f'trying theme {trying_theme_index}...')
r, bioexp, days, remaining = re.findall(theme[0], text), re.findall(theme[1], text), re.findall(theme[2], text), re.findall(theme[3], text) r, bioexp, days, remaining = re.findall(theme[0], text), re.findall(theme[1], text), re.findall(theme[2], text), re.findall(theme[3], text)
if r and bioexp and days and remaining: if len(r) > 2 and bioexp and days and remaining:
logger.debug(f'found theme {trying_theme_index}') logger.debug(f'found theme {trying_theme_index}')
return r, bio_attack_themes[trying_theme_index] return r, bio_attack_themes[trying_theme_index]
r = re.findall(theme[0].split('</a>', 1)[1], text)
if len(r) == 1 and bioexp and days and remaining:
logger.debug(f'found theme {trying_theme_index}, but invisible first lab it will be replaced to avocado id')
r = [(f'tg://openmessage?user_id={avocado_id}', r[0])]
return r, bio_attack_themes[trying_theme_index]
return r, None return r, None