
    i|                         d dl Z d dlZd dlmZ d dlmZ d dlmZ ddlm	Z	m
Z
 e j                  rd dlmZ d dlmZ dd	lmZ  G d
 de	      Zy)    N)
ip_address)gettext)EngineResults   )Plugin
PluginInfo)SearchWithPlugins)SXNG_Request)	PluginCfgc                   D     e Zd ZdZdZddgZd fdZdddd	d
efdZ xZ	S )
SXNGPluginzSimple plugin that displays information about user's request, including
    the IP or HTTP User-Agent.  The information is displayed in area for the
    "answers".
    	self_infoipz
user-agentc                 (   t         |   |       t        j                  dt        j                        | _        t        j                  dt        j                        | _        t        | j                  t        d      t        d      d      | _
        y )Nz^ipz^user-agentzSelf InformationzWDisplays your IP if the query is "ip" and your user agent if the query is "user-agent".query)idnamedescriptionpreference_section)super__init__recompile
IGNORECASEip_regexua_regexr   r   r   info)selfplg_cfg	__class__s     (/root/searxng/searx/plugins/self_info.pyr   zSXNGPlugin.__init__   sh    !

62==9

>2==Aww+,m  '
	    requestr
   searchr	   returnc                 `   t               }|j                  j                  dkD  r|S | j                  j	                  |j                  j
                        r`|j                  rT|j                  |j                  j                  t        d      t        |j                        j                  z                | j                  j                  |j                  j
                        rJ|j                  |j                  j                  t        d      t        |j                         z                |S )z.Returns a result list only for the first page.r   zYour IP is: )answerzYour user-agent is: )r   search_querypagenor   r$   r   remote_addraddtypesAnswerr   r   
compressedr   matchstr
user_agent)r   r#   r$   resultss       r!   post_searchzSXNGPlugin.post_search,   s    /%%)N== 3 3 9 9:w?R?RKK$$GN,CjQXQdQdFeFpFp,p$q ==v22889KK,,G<R4SVYZaZlZlVm4m,nor"   )r   r   )
__name__
__module____qualname____doc__r   keywordsr   r   r3   __classcell__)r    s   @r!   r   r      s:    
 
Bl#H
> ;N S` r"   r   )typingr   	ipaddressr   flask_babelr   searx.result_typesr    r   r   TYPE_CHECKINGsearx.searchr	   searx.extended_typesr
   r   r    r"   r!   <module>rC      s7     	    ,  	.1' 'r"   