-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
56 lines (46 loc) · 1.75 KB
/
index.py
File metadata and controls
56 lines (46 loc) · 1.75 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import praw
import requests
import time
import json
import os
from flask import Flask
port = int(os.environ.get('PORT', 5000))
app = Flask(__name__)
app.run(host='0.0.0.0', port=port)
main()
threads = []
keywords = ['trump', 'the_donald', 'administration', 'president', 'impeach', 'Trump', 'Impeach', 'Administration', 'The_Donald', 'The_donald', 'President', 'Mueller', 'mueller', 'investigation', 'Investigation', 'Russia', 'russia', 'Kremlin', 'kremlin']
subs = []
counter = 0
pastes = []
api = {
'key': 'fe41e9b514efe2d0118ceb24eb99bd35',
'dev_key': 'b36153beb0b6dd9098d5de1a31cf7eff',
'post': 'https://pastebin.com/api/api_post.php',
'user': 's0i',
'password': 'KQC-U3n-WXM-cuZ'
}
def main():
counter = 0
bot = praw.Reddit(user_agent='AutoMirrorBot v0.1',
client_id='A9R6EChehHwOFg',
client_secret='toXo534cDEp7gGioGYqdJ7tHPqE',
username='AutoMirrorBot',
password='cnS-QgK-K9U-XSQ')
subreddit = bot.subreddit('Politics+WorldNews+WorldPolitics+WorldEvents+Business+USPolitics+AmericanPolitics+Libertarian+Conservative+Democrats+Socialism+Democracy')
for sub in subreddit.stream.submissions():
if any(keyword in sub.title for keyword in keywords):
if not any(sub.title in thread['title'] for thread in threads):
threads.append({'title': sub.title, 'time': time.time()})
print(sub.title)
subs.append(sub.title + '\n')
counter += 1
if counter == 10:
post()
counter = 0
def post():
r = requests.post(api['post'], data={ 'api_dev_key': api['dev_key'], 'api_option': 'paste', 'api_paste_code': ''.join(subs), 'api_user_key': api['key'], 'api_paste_private': '1', 'api_paste_name': time.time() })
pastes.append({'url': r.text, 'key': r.text.rsplit('/', 1)[-1]})
print(pastes[-1]['url'])
if __name__ == '__main__':
main()