Guest User

Untitled

a guest
Mar 14th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. from fake_useragent import UserAgent
  2. import praw, re, os, time
  3.  
  4. def userAgent():
  5. ua = UserAgent()
  6. return ua.random
  7.  
  8. def checkRepeat(text):
  9. count = {}
  10. returnlist = []
  11. for char in text:
  12. if char in count:
  13. count[char] += 1
  14. else:
  15. count[char] = 1
  16. for key in count:
  17. if count[key] > 2:
  18. returnlist.append(key)
  19. if len(returnlist) > 0:
  20. return True
  21. else:
  22. return False
  23.  
  24. def split(text):
  25. return text.upper().split()
  26.  
  27. def numDash(var):
  28. num = 0
  29. for x in var:
  30. if x == "-":
  31. num += 1
  32. if num == 2 or num == 4:
  33. return True
  34. return False
  35.  
  36. def checkList(key,droplist):
  37. if any(item in key for item in droplist):
  38. return True
  39. else:
  40. return False
  41.  
  42. def findKey(text,droplist):
  43. matched = []
  44. allkeys = []
  45. matchedkeys = []
  46. verifiedkeys = []
  47. text = split(text)
  48. text = [x for x in text if "-" in x]
  49. for x in text:
  50. if numDash(x):
  51. matched.append(x)
  52. else:
  53. continue
  54. keys = [x.replace("-","") for x in matched]
  55. keys = [x for x in keys if len(x) == 15 or len(x) == 25]
  56. for x in keys:
  57. allkeys.append("-".join([x[i:i+5] for i in range(0,len(x),5)]))
  58. for key in allkeys:
  59. fullkey = key.replace("-","")
  60. if not checkRepeat(fullkey):
  61. verifiedkeys.append(key)
  62. for x in verifiedkeys:
  63. chunk = x.split("-")
  64. for part in chunk:
  65. if len(chunk) == 5 or len(chunk) == 3:
  66. if not "*" in x and not "@" in x:
  67. if not checkList(x,droplist):
  68. matchedkeys.append(x)
  69. return matchedkeys
  70.  
  71. def tryKey(key,cache):
  72. if len(key) > 1:
  73. for x in key:
  74. if x not in cache:
  75. print(x)
  76. os.system("sbka.ahk "+str(x))
  77. cache.append(x)
  78. time.sleep(1)
  79. else:
  80. print(key[0])
  81. os.system("sbka.ahk "+str(key[0]))
  82. cache.append(x)
  83. time.sleep(1)
  84.  
  85. def getPosts(sub,limit,droplist,cache):
  86. r = praw.Reddit(client_id='',client_secret='',user_agent='',username='',password='') #fill this up according to your api access keys
  87. for submission in r.subreddit('all').stream.comments():
  88. try:
  89. #print(str(submission.author)+"\n"+str(submission.body))
  90. m = findKey(submission.body,droplist)
  91. if len(m) > 0:
  92. tryKey(m,cache)
  93. except:
  94. pass
  95.  
  96. droplist = ["GREAT","RIGHT","GGXDD"]
  97. cache = []
  98.  
  99. getPosts("eegras",5,droplist,cache)
  100. print("done")
Add Comment
Please, Sign In to add comment