-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.py
44 lines (33 loc) · 1.63 KB
/
config.py
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
import os
import praw
from tinydb import TinyDB
from dotenv import load_dotenv, find_dotenv
from psaw import PushshiftAPI
from redis import StrictRedis
def env(key, fallback = None):
return os.getenv(key, fallback)
load_dotenv(find_dotenv())
BOTNAME = 'wordscounterbot'
SUBREDDIT = 'all'
USER_AGENT = 'u/wordscounterbot. By /u/alashow, [email protected]'
REDIS_HOST=env("REDIS_HOST", 'localhost')
REDIS_PORT=env("REDIS_PORT", 6379)
REDIS_PASSWORD=env("REDIS_PASSWORD", "")
N_WORDS = ["nigga", "niggas", "nigger", "niggers"]
DEFAULT_TARGET_WORDS = N_WORDS
CENSOR_WORDS_MAP = ('nigga', 'n-word'), ('nigger', 'n-word-R')
COUNTER_REPLY_TEMPLATE = "Hey, I've searched u/{user}'s history and found **{count}** matches for word(s): {words}"
COUNTER_REPLY_TEMPLATE_NWORD = """Thank you for the request, comrade.
I have looked through u/{user}'s posting history and found {count} N-words, of which {countNR} were hard-Rs."""
COUNTER_REPLY_TEMPLATE_NWORD_NONE = """Thank you for the request, comrade.
u/{user} has not said the N-word."""
COUNTER_REPLY_NO_SNITCHING_ON_ME = """I ain't snitching on myself"""
TARGET_USER_BLACKLIST=open('data/banned_targets.txt').read().split('\n')
CALLER_USER_BLACKLIST=open('data/banned_callers.txt').read().split('\n')
COMMAND_PATTERN = r"(\/?u\/({bot}|nwordcountbot)) ?(\/?u\/([a-zA-Z0-9-_]{{1,100}}))? ?(\'(.*){{1,100}}\')? ?(with links)?".format(bot=BOTNAME)
reddit = praw.Reddit(BOTNAME, user_agent=USER_AGENT)
sub = reddit.subreddit(SUBREDDIT)
api = PushshiftAPI()
apiReddit = PushshiftAPI(reddit)
db = TinyDB('data/stats.db')
redis = StrictRedis(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWORD, db=0, decode_responses=True)