Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. import praw
  2. import time
  3. import datetime
  4. import urllib3
  5. import requests
  6. import json
  7. from urllib.parse import urlparse
  8.  
  9. Bigboi = []
  10. postDict = {}
  11. reddit = praw.Reddit(
  12. client_id='qTnjdOyhvYjzWw',
  13. client_secret='t7pZnB4QboZ9r1x09-QEUO5NHdI',
  14. password='AAa748141748141aA',
  15. user_agent='mama',
  16. username='MyRSSbot')
  17. print("\nAuthenticated as {}".format(reddit.user.me()))
  18.  
  19. def main():
  20. print('\nPMing..')
  21. x = '\n'
  22. for message in reddit.inbox.sent(limit=10):
  23. x += message.body
  24. for log in reddit.subreddit('mod').mod.log(limit=100):
  25. if log.mod != 'Aevann' and log.mod != 'AutoModerator' and log.action != 'approvecomment' and log.action != 'removecomment' and log.action != 'distinguish' and log.target_permalink not in x:
  26. reddit.redditor('Aevann').message('beep beep lettuce', str(log.mod) + ' ' + str(log.action) + ' ' + str(log.target_permalink))
  27. print('\nPMd' + ' "' + str(log.mod) + ' ' + str(log.action) + ' ' + str(log.target_fullname) + '"')
  28. print('PMing finished!')
  29. print('\nPosting articles..')
  30. for post in reddit.subreddit('POTUSWatch').hot(limit=12):
  31. if post.saved or post.domain == 'twitter.com' or post.domain == 'reddit.com':
  32. continue
  33. try:
  34. excerpts = json.loads(requests.post(f"http://api.smmry.com/?SM_API_KEY=AA52C3B194&SM_WITH_BREAK&SM_LENGTH=69&SM_URL={post.url}").text)['sm_api_content'].split("[BREAK]")[:-1]
  35. if post.domain == 'whitehouse.gov':
  36. commentboi = f"###Statement:"
  37. if post.domain != 'whitehouse.gov':
  38. commentboi = f"###Article:"
  39. for excerpt in excerpts:
  40. commentboi += f"\n\n>{excerpt.strip()}\n"
  41. post.reply(commentboi)
  42. post.save()
  43. print('\n' + post.url)
  44. time.sleep(20)
  45. except Exception as e:
  46. print('Articles finished!')
  47. break
  48. print('\nLoading post list..')
  49. try:
  50. with open('Bigboi.txt', encoding='utf-8',mode='r') as text_file:
  51. for line in text_file:
  52. Bigboi.append(str(line.rstrip('\n')))
  53. except Exception as e:
  54. print('Failed to load post list: ', str(e))
  55. time.sleep(1800)
  56. main()
  57. for submission in reddit.subreddit('me_irl').hot(limit=10):
  58. match = False
  59. for x in range (0, len(Bigboi)):
  60. if submission.url == Bigboi[x]:
  61. match = True
  62. break
  63. if match == False:
  64. postDict[submission.url] = [('I_irl'), ('OP: u/' + str(submission.author))]
  65. for submission in reddit.subreddit('meirl').hot(limit=10):
  66. match = False
  67. for x in range (0, len(Bigboi)):
  68. if submission.url == Bigboi[x]:
  69. match = True
  70. break
  71. if match == False:
  72. postDict[submission.url] = [('I_irl'), ('OP: u/' + str(submission.author))]
  73. for submission in reddit.subreddit('dankchristianmemes+memeeconomy+biomememes+smoobypost+teenagers+2meirl4meirl+dankmemes+historymemes+trippinthroughtime+teleshits+surrealmemes+starterpacks+bertstrips+bikinibottomtwitter+dank_meme+memes+prequelmemes+fakehistoryporn').hot(limit=25):
  74. match = False
  75. for x in range (0, len(Bigboi)):
  76. if submission.url == Bigboi[x]:
  77. match = True
  78. break
  79. if match == False:
  80. postDict[submission.url] = [('I_irl'), ('OP: u/' + str(submission.author))]
  81. if len(postDict) == 0:
  82. print('No new posts')
  83. else:
  84. try:
  85. for k, v in postDict.items():
  86. post = reddit.subreddit('i_irl').submit(str(v[0]), url=k)
  87. post.reply(str(v[1]))
  88. Bigboi.append(k)
  89. print('\nPosted' + str(post.shortlink))
  90. print('Saving post to list..')
  91. post = str(k)
  92. try:
  93. with open('Bigboi.txt', encoding='utf-8', mode='a') as text_file:
  94. text_file.write(k + '\n')
  95. except Exception as e:
  96. print('Failed to save post..', str(e))
  97. print('String..', post)
  98. time.sleep(1800)
  99. main()
  100. except Exception as e:
  101. print('Failed to post: ' + str(e))
  102. postDict.clear()
  103. time.sleep(1800)
  104. main()
  105. print('Posting finished!')
  106. postDict.clear()
  107. print('\nBeginning shilling..')
  108. for submission in reddit.subreddit('news+Worldnews+The_Donald').rising(limit=None):
  109. if submission.saved or str(submission.subreddit).lower() == 'POTUSWatch'.lower():
  110. continue
  111. if submission.url in [post.url for post in reddit.subreddit('POTUSWatch').new(limit=100)]:
  112. submission.save()
  113. reply = submission.reply('\This submission looks like it also fits r/POTUSWatch, can you please post it there as well ?\n\n^^beep boop I\'m a bot, PM u/Aevann if you want this subreddit excluded')
  114. print('http://reddit.com{}'.format(reply.permalink()))
  115. print('Shilling finished!')
  116. time.sleep(10)
  117. main()
  118. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement