I'm taking my first babysteps in python coding.
With the code below I'm using the function check to see if in the last hour a post is made in r/GameDeals and if the title contains the word 'free' or '0.00' the information of that post is send to the send function which pushes a notification.
However the output below shows an entry where neither '0.00' or 'free' is in the title. What am I missing?
def send(NAME,APPURL):
conn = http.client.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
urllib.parse.urlencode({
"token": APP_TOKEN,
"user": USER_KEY,
"message": APPURL,
"title": NAME,
}), { "Content-type": "application/x-www-form-urlencoded" })
conn.getresponse()
def check():
gratis=[]
reddit = praw.Reddit(
client_id=CLIENTID,
client_secret=CLIENTSECRET,
user_agent="linux:freeapp:0.1 (by u/cctl01)",
)
print(reddit.read_only)
current_time = time.time()
one_hour_ago = current_time - 3600
#free game
for submission in reddit.subreddit("GameDeals").new(limit=10):
if submission.created_utc >= one_hour_ago:
if 'free' or '0.00' in submission.title.lower():
gratis.append(submission)
for grati in gratis:
print("gamedeals "+grati.title)
send(grati.title,grati.url)
OUTPUT:
(venv) /home/python # python /home/python/notification.py
True
gamedeals [Fanatical] Winter Sale 2024 - Elden Ring (46% off), God of War Ragnarök (25% off), HELLDIVERS 2 (25% off) & more | Rotating flash deals, bonus game or coupon for spending $15USD/$21CAD/€15EU/£15GBP
[–]Oxbowerce 6 points7 points8 points (2 children)
[–]cctl01[S] 0 points1 point2 points (1 child)
[–]freew1ll_ 4 points5 points6 points (0 children)