How to use the pastepwn.scraping.pastebin.exceptions.IPNotRegisteredError function in pastepwn

To help you get started, we’ve selected a few pastepwn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d-Rickyy-b / pastepwn / pastepwn / scraping / pastebin / pastebinscraper.py View on Github external
def _check_error(self, body, key=None):
        """Checks if an error occurred and raises an exception if it did"""
        pattern = r"^YOUR IP: ((\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})|((([0-9A-Fa-f]{1,4}:){7})([0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,6}:)(([0-9A-Fa-f]{1,4}:){0,4})([0-9A-Fa-f]{1,4}))) DOES NOT HAVE ACCESS\.\s+VISIT: https:\/\/pastebin\.com\/doc_scraping_api TO GET ACCESS!"

        if 131 >= len(body) and re.match(pattern, body):
            self._exception_event.set()
            raise IPNotRegisteredError(body)

        if body is None or body == "":
            raise PasteEmptyException("The paste '{0}' or its body was set to None!".format(key))
        if body == "File is not ready for scraping yet. Try again in 1 minute.":
            # The pastebin API was not ready yet to deliver this paste -
            # We raise an exception to re-download it again after some time has passed
            raise PasteNotReadyException("The paste '{0}' could not be fetched yet!".format(key))
        elif body == "Error, we cannot find this paste.":
            # The paste has been deleted before we could download it.
            # We raise an exception to delete the paste from the queue
            raise PasteDeletedException("The paste '{0}' has been deleted!".format(key))