Ejemplo n.º 1
0
    def getPublishedAddress(self, fromnumber, frommessage):

        self.logger.info('Checking messages from user %s', fromnumber)
        try:
            match = re.search(self.BITCOINREGEX, frommessage)
            if not match: return None
            self.logger.debug('Found %s', match.group(0))
            address = match.group(0)
            if bitcoin_address.validate(address):
                return address
        except twilio.TwilioRestException as e:
            self.logger.debug('TwilioRestException: %r', e)
        except Error as e:
            self.logger.error('Encountered an error: %r', e)

        return None
Ejemplo n.º 2
0
    def getPublishedAddress(self, fromnumber, frommessage):

        self.logger.info('Checking messages from user %s', fromnumber)
        try:
            match = re.search(self.BITCOINREGEX, frommessage)
            if not match: return None
            self.logger.debug('Found %s', match.group(0))
            address = match.group(0)
            if bitcoin_address.validate(address):
                return address
        except twilio.TwilioRestException as e:
            self.logger.debug('TwilioRestException: %r', e)
        except Error as e:
            self.logger.error('Encountered an error: %r', e)

        return None
Ejemplo n.º 3
0
    def getPublishedAddress(self, screen_name):
        self.logger.info('Getting published address for Twitter user %s', screen_name)
        try:
            userinfo = self.t.users.show(screen_name=screen_name)
            if 'description' not in userinfo: return None
            match = re.search(self.BITCOINREGEX, userinfo['description'])
            if not match: return None
            self.logger.debug('Found %s', match.group(0))
            address = match.group(0)
            if bitcoin_address.validate(address):
                return address
        except TwitterHTTPError as e:
            self.logger.debug('TwitterHTTPError: %r', e.response_data)
        except Error as e:
            self.logger.error('Encountered an error: %r', e)

        return None
Ejemplo n.º 4
0
 def getMostFrequentAddress(self):
     theresult = None
     if not self.thepage:
         return theresult
     soup = BeautifulSoup(self.thepage)
     self.logger.debug('Testing against regex: %s', self.BITCOINREGEX)
     regexmatches = soup.find_all(text=re.compile(self.BITCOINREGEX))
     self.logger.info('Regex matches: %s', regexmatches)
     mostcommon = Counter(regexmatches).most_common()
     for addresstuple in mostcommon:
         address, count = addresstuple
         self.logger.debug('Checking address for vailidity: %s', address)
         if bitcoin_address.validate(address):
             theresult = address
             break
     self.logger.info('Best guess bitcoin address: %s', theresult)
     return theresult
Ejemplo n.º 5
0
    def getPublishedAddress(self, screen_name):
        self.logger.info('Getting published address for Twitter user %s',
                         screen_name)
        try:
            userinfo = self.t.users.show(screen_name=screen_name)
            if 'description' not in userinfo: return None
            match = re.search(self.BITCOINREGEX, userinfo['description'])
            if not match: return None
            self.logger.debug('Found %s', match.group(0))
            address = match.group(0)
            if bitcoin_address.validate(address):
                return address
        except TwitterHTTPError as e:
            self.logger.debug('TwitterHTTPError: %r', e.response_data)
        except Error as e:
            self.logger.error('Encountered an error: %r', e)

        return None
Ejemplo n.º 6
0
    def getDns(self, domain_name):
        self.logger.info('Getting DNS TXT for %s', domain_name)
        result = None
        try:
            answers = dns.resolver.query(domain_name, 'TXT')
        except Exception as e:
            msg = 'Unable to read DNS entries for domain ' + domain_name + ': ' + str(e)
            self.logger.warning(msg)
            #raise NetworkError(msg)
        else:
            for rdata in answers:
                data = rdata.to_text()
                if data.startswith(self.QUOTESTRING) and data.endswith(self.QUOTESTRING):
                    data = data[len(self.QUOTESTRING):-1 * len(self.QUOTESTRING)]
                self.logger.info('Found %s', data)

                if bitcoin_address.validate(data):
                    result = data
                    break
        
        self.logger.info('Found %s', result)
        return result