removed unused vars and functions
This commit is contained in:
parent
2417c53970
commit
86e29fa6da
41
app.py
41
app.py
@ -7,15 +7,9 @@ import requests
|
||||
from dotenv import load_dotenv
|
||||
from os import getenv
|
||||
|
||||
PRICE_REGEX = re.compile(
|
||||
"(?:(?P<currency>[GBP|EUR|£|€])(?P<price>[0-9]+(?:\.[0-9]{1,2})))")
|
||||
MODEL_REGEX = re.compile("[Rr][Tt][Xx] ?(?P<model>30[6789]0( [Tt][Ii])?).?")
|
||||
URL_REGEX = re.compile(
|
||||
"(?:(?:https?|ftp):\/\/|\b(?:[a-z\d]+\.))(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s`!()\[\]{};:'.,<>?«»“”‘’]))?")
|
||||
|
||||
PARTALERT_ASIN = re.compile("asin=(?P<asin>[0-9a-zA-Z]{1,10})")
|
||||
PARTALERT_TLD = re.compile("tld=(?P<tld>\.(?:it|es|de|fr|co\.uk))")
|
||||
|
||||
# consoles
|
||||
PS5_CHANNELS = [713321461124694056, 721009876893040682,
|
||||
781965674838753331, 802674800786145311,
|
||||
@ -73,7 +67,7 @@ def get_stockinformer_url(url: str) -> str:
|
||||
return f"https://stockinformer.co.uk/{url}"
|
||||
elif "amazon" in url:
|
||||
return f"{url.split('?')[0]}"
|
||||
|
||||
|
||||
return url
|
||||
|
||||
return None
|
||||
@ -110,39 +104,6 @@ def check_urls(urls: List[str]):
|
||||
webbrowser.open(url)
|
||||
|
||||
|
||||
def check_price(message: str) -> bool:
|
||||
prices = {
|
||||
"3060 ti": {"gbp": 500, "eur": 600},
|
||||
"3070": {"gbp": 680, "eur": 850},
|
||||
"3080": {"gbp": 880, "eur": 1000},
|
||||
"3090": {"gbp": 1450, "eur": 1650}
|
||||
}
|
||||
|
||||
try:
|
||||
price = float(PRICE_REGEX.search(message).group("price"))
|
||||
currency = PRICE_REGEX.search(message).group("currency")
|
||||
model = MODEL_REGEX.search(message).group("model").lower()
|
||||
|
||||
if currency == "£":
|
||||
currency = "gbp"
|
||||
elif currency == "€":
|
||||
currency = "eur"
|
||||
else:
|
||||
currency = currency.lower()
|
||||
|
||||
if model == "3060":
|
||||
return False
|
||||
|
||||
print(f"Model: {model}, Price: {currency}{price:0.2f}")
|
||||
if price <= prices[model][currency]:
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@bot.gateway.command
|
||||
def on_message(resp):
|
||||
urls = []
|
||||
|
Loading…
Reference in New Issue
Block a user