Open
Description
Currently, pywhat only uses regular expressions to identify stuff. However, we may often want to update the description based on a match or to filter out false positives.
Some examples:
- Pinging URLs to check if it is responding or if a certain resource exists, etc.
- Parsing timestamps ([Proposal] parse timestampsΒ #234) (
1637093119.558717
toNovember 16, 2021 8:05:19 PM
) - Changing rarity based on a match
- And many more
How it should be implemented?
I think the best idea would be to write a class for every regex pattern (so that it can save the state between several matches). That class should have a method like process()
that gets a match object and can alter it and return it or return None to filter it out.
Example:
class URLProcessor:
def process(match):
if "http://trashurl.it" in match["url"]: # Or maybe we should create an actual Match class and do match.url
return None