Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from fake_useragent import UserAgent
- import praw, re, os, time
- def userAgent():
- ua = UserAgent()
- return ua.random
- def checkRepeat(text):
- count = {}
- returnlist = []
- for char in text:
- if char in count:
- count[char] += 1
- else:
- count[char] = 1
- for key in count:
- if count[key] > 2:
- returnlist.append(key)
- if len(returnlist) > 0:
- return True
- else:
- return False
- def split(text):
- return text.upper().split()
- def numDash(var):
- num = 0
- for x in var:
- if x == "-":
- num += 1
- if num == 2 or num == 4:
- return True
- return False
- def checkList(key,droplist):
- if any(item in key for item in droplist):
- return True
- else:
- return False
- def findKey(text,droplist):
- matched = []
- allkeys = []
- matchedkeys = []
- verifiedkeys = []
- text = split(text)
- text = [x for x in text if "-" in x]
- for x in text:
- if numDash(x):
- matched.append(x)
- else:
- continue
- keys = [x.replace("-","") for x in matched]
- keys = [x for x in keys if len(x) == 15 or len(x) == 25]
- for x in keys:
- allkeys.append("-".join([x[i:i+5] for i in range(0,len(x),5)]))
- for key in allkeys:
- fullkey = key.replace("-","")
- if not checkRepeat(fullkey):
- verifiedkeys.append(key)
- for x in verifiedkeys:
- chunk = x.split("-")
- for part in chunk:
- if len(chunk) == 5 or len(chunk) == 3:
- if not "*" in x and not "@" in x:
- if not checkList(x,droplist):
- matchedkeys.append(x)
- return matchedkeys
- def tryKey(key,cache):
- if len(key) > 1:
- for x in key:
- if x not in cache:
- print(x)
- os.system("sbka.ahk "+str(x))
- cache.append(x)
- time.sleep(1)
- else:
- print(key[0])
- os.system("sbka.ahk "+str(key[0]))
- cache.append(x)
- time.sleep(1)
- def getPosts(sub,limit,droplist,cache):
- r = praw.Reddit(user_agent=userAgent())
- stream = praw.helpers.submission_stream(r,sub,limit=limit,verbosity=-1)
- for submission in stream:
- m = findKey(submission.selftext,droplist)
- if len(m) > 0:
- tryKey(m,cache)
- droplist = ["GABEN","G4B3N","SCUM"]
- cache = []
- getPosts("eegras",5,droplist,cache)
- print("done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement