-
Notifications
You must be signed in to change notification settings - Fork 0
/
reddit_bot.py
38 lines (33 loc) · 1.53 KB
/
reddit_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import praw
import codecs
import re
import os
import random
import steam_wishlist
from datetime import datetime
def find_game_sale():
""" Game sale finder. Uses steam wishlist to search through r/gamedeals and find any matches
for game sales.
"""
user_agent = ("Dark Souls 2 sale finder")
r = praw.Reddit(user_agent = user_agent)
subreddit = r.get_subreddit("gamedeals")
output = codecs.open('game_sales.txt', 'w', 'utf-8')
games = steam_wishlist.get_steam_wishlist('charlesleesr')
for submission in subreddit.get_hot(limit=20):
for game in games:
if re.findall('''Dark\s?Souls\s?(2|two)?''', submission.title, re.I) or re.findall(game, submission.title, re.I):
if re.findall('''Scholar\s?of\s?the\s?first\s?sin''', submission.title, re.I):
output.write (" This is the DLC, THIS IS WHAT YOU WANT")
output.write("Title: %s \n" % submission.title)
output.write("Url: %s \n" % submission.url)
output.write("-------------------------------------------------\n")
if os.stat("game_sales.txt").st_size == 0:
output.write("No steam wishlist sales found in the hottest 20 submission on r/gamedeals on %s \n" % datetime.today())
ds3_threshold = random.randrange(1,10)
if ds3_threshold >= 5:
output.write("Forget ds2, you should just get ds3 instead \n")
else:
output.write("Keep trying!\n")
output.write("This script will run again at 10 am tomorrow")
find_game_sale()