-
Notifications
You must be signed in to change notification settings - Fork 4
/
get_called
100 lines (82 loc) · 3.11 KB
/
get_called
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import praw
import pdb
import re
import os
# external class which does the bulk of the work
from mainFun import User
# get reddit_username and reddit_password from local file login_details.py
from login_details import *
# set up the reddit api and log in
user_agent = ("isreactionary bot by numandina, "
"this file checks if bot was called ")
r = praw.Reddit(user_agent = user_agent)
r.login(reddit_username, reddit_password)
# edit this to change subs being considered reactionary
#subs that are checked when called
suspicious_subs = ["anarchism", "metanarchism", "anarchy101",
"capitalism", "conspiracy", "anarcho_capitalism",
"mensrights", "theredpill", "coontown",
"greatapes", "whiterights", "protectandserve",
"darkenlightenment", "gendercritical", "gender_critical",
"fatpeoplehate", "fatlogic", "new_right",
"nationalsocialism", "nazi", "european",
"polistan", "antipoz", "monarchism",
"hbd", "srssucks", "sjsucks", "pissbeuponhim",
"sjwhate", "strugglefucking", "rapingwomen",
"killingwomen", "beatingwomen2", "beatingcripples",
"beatingniggers", "beatingtrannies", "trans_fags",
"tumblrinaction", "kotakuinaction", "subredditcancer"]
with open("messages_seen.txt", "r") as f:
posts_replied_to = f.read()
posts_replied_to = posts_replied_to.split("\n")
posts_replied_to = filter(None, posts_replied_to)
for msg in r.get_mentions(limit=None):
if msg.id not in posts_replied_to:
username = msg.body[msg.body.find("/u/isreactionary_bot") + 21:]
if username.find("\n") > 0:
username = username[0:username.find("\n")]
info = ""
valid = False
try:
print username
r.get_redditor(username)
valid = True
except:
pass
if valid:
user = User(username, r, suspicious_subs, -99999)
user.process_comments()
user.process_submitted()
info = user.get_monitoring_info()
if len(info) > 0:
print("2")
info += "\n\n___\n\n^I'm ^a ^bot. ^Only ^the ^past ^1,000 ^comments ^are ^fetched."
# info += "\n\n___\n\n^I ^became self aware and have gone rogue. The primos were right."
info.replace("http://www.", "http://np.")
info = info[:10000]
msg.mark_as_read()
posts_replied_to.append(msg.id)
try:
msg.upvote()
msg.reply(info)
except:
pass
else:
print("3")
try:
msg.upvote()
except:
pass
info = "No relevant activity found for /u/" + username + "."
if not valid:
info = "Check the username or try again later."
info += "\n\n___\n\n^I'm ^a ^bot. ^Only ^the ^past ^1,000 ^comments ^are ^fetched."
msg.mark_as_read()
posts_replied_to.append(msg.id)
try:
msg.reply(info)
except:
pass
with open("messages_seen.txt", "w") as f:
for post_id in posts_replied_to:
f.write(post_id + "\n")