Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import time
- import datetime
- import praw
- from termcolor import colored
- from pushsafer import init, Client
- import urllib3
- urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
- def log(string, ts=True):
- f = open("apex.log", "a")
- if ts:
- f.write('{:%d.%m.%Y %H:%M:%S}'.format(datetime.datetime.now()) + " " + string + "\n")
- else:
- f.write(string + "\n")
- f.flush()
- f.close()
- log("---NEW-SESSION---", False)
- log("Starting program")
- try:
- init("")
- except Exception as e:
- log("Error connecting to push service: " + str(e))
- raise SystemExit
- try:
- reddit = praw.Reddit(client_id="", client_secret="", user_agent="test", username="", password="")
- except Exception as e:
- log("Error connecting to reddit: " + str(e))
- raise SystemExit
- subreddit = reddit.subreddit("apexlegends")
- already_posted = []
- counter = 0
- log("Starting loop")
- while True:
- try:
- new = subreddit.new(limit=20)
- except Exception as e:
- log("Error receiving new data: " + str(e))
- toCheck = ['battlepass',
- 'battle pass',
- 'patch']
- for post in new:
- for string in toCheck:
- if post.title.lower().find(string) != -1:
- if post.id not in already_posted:
- already_posted.append(post.id)
- Client("").send_message(post.selftext,post.title, "15480", "1", "47", "1", "http://chaoticoz.de/log", "Check logs", "0", "", "", "","","","","")
- log("Notification sent. Title: " + post.title)
- counter = 0
- if counter ==11:
- counter = 0
- log("60 seconds passed, nothing new")
- counter +=1
- time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement