def __init__(self):
     self.config = Config()
     self.redlock = get_redlock_factory(self.config)
     self.reddit = get_reddit_instance(self.config)
     self.reddit_manager = RedditManager(self.reddit)
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging(config=self.config)
     notification_svc = NotificationService(self.config)
     self.response_handler = ResponseHandler(
         self.reddit_manager,
         self.uowm,
         self.event_logger,
         source='summons',
         live_response=self.config.live_responses,
         notification_svc=notification_svc)
     dup_image_svc = DuplicateImageService(self.uowm,
                                           self.event_logger,
                                           self.reddit,
                                           config=self.config)
     response_builder = ResponseBuilder(self.uowm)
     self.summons_handler = SummonsHandler(
         self.uowm,
         dup_image_svc,
         self.reddit_manager,
         response_builder,
         self.response_handler,
         event_logger=self.event_logger,
         summons_disabled=False,
         notification_svc=notification_svc)
Esempio n. 2
0
 def __init__(self):
     self.config = Config()
     from redditrepostsleuth.core.services.duplicateimageservice import DuplicateImageService
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.notification_svc = NotificationService(self.config)
     self.event_logger = EventLogging()
     self.reddit = get_reddit_instance(self.config)
     self.dup_service = DuplicateImageService(self.uowm, self.event_logger,
                                              self.reddit)
Esempio n. 3
0
 def __init__(self):
     self.config = Config()
     self.reddit = RedditManager(get_reddit_instance(self.config))
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging(config=self.config)
     self.response_handler = ResponseHandler(
         self.reddit,
         self.uowm,
         self.event_logger,
         live_response=self.config.live_responses)
Esempio n. 4
0
def remove_post(uowm: SqlAlchemyUnitOfWorkManager, post):
    with uowm.start() as uow:
        image_post = uow.image_post.get_by_post_id(post.post_id)
        image_post_current = uow.image_post_current.get_by_post_id(
            post.post_id)
        investigate_post = uow.investigate_post.get_by_post_id(post.post_id)
        link_repost = uow.link_repost.get_by_repost_of(post.post_id)
        image_reposts = uow.image_repost.get_by_repost_of(post.post_id)
        comments = uow.bot_comment.get_by_post_id(post.post_id)
        summons = uow.summons.get_by_post_id(post.post_id)
        image_search = uow.image_search.get_by_post_id(post.post_id)
        user_reports = uow.user_report.get_by_post_id(post.post_id)

        #uow.posts.remove(post)
        if image_post:
            log.debug('Deleting image post %s', image_post.id)
            uow.image_post.remove(image_post)
        if image_post_current:
            log.debug('Deleting image post current %s', image_post_current.id)
            uow.image_post_current.remove(image_post_current)
        if investigate_post:
            log.debug('Deleting investigate %s', investigate_post.id)
            uow.investigate_post.remove(investigate_post)
        if link_repost:
            for r in link_repost:
                log.debug('Deleting link repost %s', r.id)
                uow.link_repost.remove(r)
        if image_reposts:
            for r in image_reposts:
                log.debug('Deleting image repost %s', r.id)
                uow.image_repost.remove(r)
        if comments:
            for c in comments:
                log.debug('Deleting comment %s', c.id)
                uow.bot_comment.remove(c)
        if summons:
            for s in summons:
                log.debug('deleting summons %s', s.id)
                uow.summons.remove(s)
        if image_search:
            for i in image_search:
                log.debug('Deleting image search %s', i.id)
                uow.image_search.remove(i)
        if user_reports:
            for u in user_reports:
                log.debug('Deleting report %s', u.id)
                uow.user_report.remove(u)

        uow.commit()
Esempio n. 5
0
 def __init__(self):
     self.config = Config()
     self.reddit = RedditManager(get_reddit_instance(self.config))
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging(config=self.config)
     self.response_handler = ResponseHandler(
         self.reddit,
         self.uowm,
         self.event_logger,
         live_response=self.config.live_responses)
     self.notification_svc = NotificationService(self.config)
     self.config_updater = SubredditConfigUpdater(
         self.uowm,
         self.reddit.reddit,
         self.response_handler,
         self.config,
         notification_svc=self.notification_svc)
 def __init__(self):
     self.config = Config()
     self.reddit = get_reddit_instance(self.config)
     self.reddit_manager = RedditManager(self.reddit)
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     event_logger = EventLogging(config=self.config)
     response_handler = ResponseHandler(
         self.reddit_manager,
         self.uowm,
         event_logger,
         source='submonitor',
         live_response=self.config.live_responses)
     dup_image_svc = DuplicateImageService(self.uowm,
                                           event_logger,
                                           self.reddit,
                                           config=self.config)
     response_builder = ResponseBuilder(self.uowm)
     self.sub_monitor = SubMonitor(dup_image_svc,
                                   self.uowm,
                                   self.reddit_manager,
                                   response_builder,
                                   response_handler,
                                   event_logger=event_logger,
                                   config=self.config)
Esempio n. 7
0
import threading
import time
# TODO - Mega hackery, figure this out.
import sys

sys.path.append('./')
from redditrepostsleuth.core.config import Config
from redditrepostsleuth.core.db.db_utils import get_db_engine
from redditrepostsleuth.core.db.uow.sqlalchemyunitofworkmanager import SqlAlchemyUnitOfWorkManager
from redditrepostsleuth.core.util.reddithelpers import get_reddit_instance
from redditrepostsleuth.summonssvc.summonsmonitor import SummonsMonitor

if __name__ == '__main__':
    config = Config(
        '/home/barry/PycharmProjects/RedditRepostSleuth/sleuth_config.json')
    uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(config))
    summons = SummonsMonitor(get_reddit_instance(config), uowm, config)
    threading.Thread(target=summons.monitor_for_mentions,
                     name='mention_summons').start()
    #threading.Thread(target=summons.monitor_for_summons_pushshift, name='pushshift_summons').start()
    threading.Thread(target=summons.monitor_for_summons,
                     name='praw_summons',
                     args=(config.summons_subreddits, )).start()
    #threading.Thread(target=summons.monitor_for_summons, name='praw_summons_all').start()

    while True:
        time.sleep(10)
Esempio n. 8
0
from redditrepostsleuth.core.logging import log
from redditrepostsleuth.core.services.eventlogging import EventLogging
from redditrepostsleuth.core.services.reddit_manager import RedditManager
from redditrepostsleuth.core.services.response_handler import ResponseHandler
from redditrepostsleuth.core.db.db_utils import get_db_engine
from redditrepostsleuth.core.db.uow.sqlalchemyunitofworkmanager import SqlAlchemyUnitOfWorkManager
from redditrepostsleuth.core.services.responsebuilder import ResponseBuilder

from redditrepostsleuth.core.util.helpers import get_reddit_instance, get_redis_client
from redditrepostsleuth.core.services.duplicateimageservice import DuplicateImageService
from redditrepostsleuth.submonitorsvc.submonitor import SubMonitor

if __name__ == '__main__':
    config = Config()
    event_logger = EventLogging(config=config)
    uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(config))
    response_builder = ResponseBuilder(uowm)
    reddit = get_reddit_instance(config)
    reddit_manager = RedditManager(reddit)
    dup = DuplicateImageService(uowm, event_logger, reddit, config=config)
    monitor = SubMonitor(dup,
                         uowm,
                         reddit_manager,
                         response_builder,
                         ResponseHandler(reddit_manager,
                                         uowm,
                                         event_logger,
                                         source='submonitor',
                                         live_response=config.live_responses),
                         event_logger=event_logger,
                         config=config)
Esempio n. 9
0
 def __init__(self):
     self.config = Config()
     self.uowm = SqlAlchemyUnitOfWorkManager(get_db_engine(self.config))
     self.event_logger = EventLogging()