3
@6^                 @   s8   d dl Z d dlZd dlmZmZmZ G dd deZdS )    N)
SpiderFootSpiderFootPluginSpiderFootEventc               @   sF   e Zd ZdZi Zi ZdZdZe fddZ	dd Z
dd	 Zd
d ZdS )sfp_callernamezpCallerName:Footprint,Investigate,Passive:Real World::Lookup US phone number location and reputation information.NFc             C   sD   || _ d| _| j | _d| _x"t|j D ]}|| | j|< q*W d S )NZ
CallerNameF)sf__dataSource__tempStorageresults
errorStatelistkeysopts)selfsfcuserOptsopt r   9/var/www/spiderfoot.crq.systems/modules/sfp_callername.pysetup    s    
zsfp_callername.setupc             C   s   dgS )NPHONE_NUMBERr   )r   r   r   r   watchedEvents*   s    zsfp_callername.watchedEventsc             C   s   ddgS )NGEOINFOMALICIOUS_PHONE_NUMBERr   )r   r   r   r   producedEvents.   s    zsfp_callername.producedEventsc             C   s  |j }|j}|j}| jrd S || jkr*d S d| j|< | jjd| d |  |jdsj| jjd|  d S |jdj	dj	dj	dj	d	}|j
 s| jjd
|  d S d| }| jj|| jd | jd d}tjd |d d kr| jjd d S |d dkr| jjd|  d S tjd|d tjtjB }|r|d }	t|	dk sZt|	dkrh| jjd ntd|	| j|}
| j|
 tjd|d }tjd|d }|r|rt|d }t|d }||krd| d d | d  }td!|| j|}
| j|
 d S )"NTzReceived event, z, from z+1zUnsupported phone number: ()- zInvalid phone number: zhttps://callername.com/_fetchtimeout
_useragent)timeout	useragent   contentzNo response from CallerName.comcode200zNo phone information found for z4<div class="callerid"><h4>.*?</h4><p>(.+?)</p></div>r      d   z!Skipping likely invalid location.r   z>SAFE.*?>(\d+) votes?<z>UNSAFE.*?>(\d+) votes?<zCallerName [z]
z<SFURL>z</SFURL>r   )	eventTypemoduledatar
   r	   r   debug
startswithlstripstripisdigitfetchUrlr   timesleeprefindall	MULTILINEDOTALLlenr   __name__notifyListenersint)r   event	eventNamesrcModuleName	eventDatanumberurlresZlocation_matchlocationevtZrep_good_matchZrep_bad_matchZ
good_votesZ	bad_votestextr   r   r   handleEvent2   sR    


"


zsfp_callername.handleEvent)r8   
__module____qualname____doc__r   optdescsr	   r
   dictr   r   r   rE   r   r   r   r   r      s   
r   )r3   r1   sflibr   r   r   r   r   r   r   r   <module>   s   