Skip to content

Commit

Permalink
FEATURE: Decide if you want to store all pastes
Browse files Browse the repository at this point in the history
  • Loading branch information
d-Rickyy-b committed Sep 3, 2019
1 parent cc7edf4 commit e04f476
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pastepwn/core/pastepwn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

class PastePwn(object):

def __init__(self, database=None, proxies=None):
def __init__(self, database=None, proxies=None, store_all_pastes=True):
"""
Basic PastePwn object handling the connection to pastebin and all the analyzers and actions
:param database: Database object extending AbstractDB
:param proxies: Dict of proxies as defined in the requests documentation
:param store_all_pastes: Bool to decide if all pastes should be stored into the db
"""
self.logger = logging.getLogger(__name__)
self.database = database
self.paste_queue = Queue()
Expand All @@ -36,14 +42,16 @@ def __init__(self, database=None, proxies=None):
self.action_handler = ActionHandler(action_queue=self.action_queue,
exception_event=self.__exception_event)

if self.database is not None:
if self.database is not None and store_all_pastes:
# Save every paste to the database with the AlwaysTrueAnalyzer
self.logger.info("Database provided! Storing pastes in there.")
database_action = DatabaseAction(self.database)
always_true = AlwaysTrueAnalyzer(database_action)
self.add_analyzer(always_true)
else:
elif store_all_pastes:
self.logger.info("No database provided!")
else:
self.logger.info("Not storing all pastes!")

def add_scraper(self, scraper):
scraper.init_exception_event(self.__exception_event)
Expand Down

0 comments on commit e04f476

Please sign in to comment.