forked from jamescoxon/xrb_reddit_tipbot
-
Notifications
You must be signed in to change notification settings - Fork 4
/
launch_comments.py
45 lines (31 loc) · 1.48 KB
/
launch_comments.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
45
import datetime
import logging
import dataset
import praw
import comments_scanner
import rpc_wallet
import settings
import tipper
class CommentsLauncher:
# Multiprocessing not completely functional currently, launch the scanners separately
def __init__(self):
self.reddit_client = praw.Reddit(user_agent=settings.user_agent,
client_id=settings.client_id,
client_secret=settings.client_secret,
username=settings.username,
password=settings.password)
self.db = dataset.connect(settings.connection_string)
self.wallet_id = settings.wallet_id
self.rest_wallet = rpc_wallet.RestWallet(settings.node_ip, settings.node_port)
self.subreddit = settings.subreddit
log_file_name = "comments_scanner_" + str(datetime.datetime.now().isoformat()) + ".log"
logging.basicConfig(filename=log_file_name, level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
log = logging.getLogger("comments")
self.log = log
self.tipper = tipper.Tipper(self.db, self.reddit_client, self.wallet_id, self.rest_wallet, self.log)
def main(self):
comments = comments_scanner.CommentsScanner(self.reddit_client, self.subreddit, self.tipper, self.log)
comments.run_scan_loop()
if __name__ == '__main__':
launcher = CommentsLauncher()
launcher.main()