.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.plugins.self_info.SXNGPlugin Class Reference
+ Inheritance diagram for searx.plugins.self_info.SXNGPlugin:
+ Collaboration diagram for searx.plugins.self_info.SXNGPlugin:

Public Member Functions

 __init__ (self)
 
EngineResults post_search (self, "SXNG_Request" request, "SearchWithPlugins" search)
 
- Public Member Functions inherited from searx.plugins._core.Plugin
None __init__ (self)
 
int __hash__ (self)
 
 __eq__ (self, other)
 
bool init (self, flask.Flask app)
 
bool pre_search (self, SXNG_Request request, "SearchWithPlugins" search)
 
bool on_result (self, SXNG_Request request, "SearchWithPlugins" search, Result result)
 

Public Attributes

 ip_regex = re.compile(r"^ip", re.IGNORECASE)
 
 ua_regex = re.compile(r"^user-agent", re.IGNORECASE)
 
 info
 

Additional Inherited Members

- Static Public Attributes inherited from searx.plugins._core.Plugin
typing id .ClassVar[str]
 
typing default_on .ClassVar[bool]
 
list keywords = []
 
logging log .Logger
 

Detailed Description

Simple plugin that displays information about user's request, including
the IP or HTTP User-Agent.  The information is displayed in area for the
"answers".

Definition at line 19 of file self_info.py.

Constructor & Destructor Documentation

◆ __init__()

searx.plugins.self_info.SXNGPlugin.__init__ ( self)

Definition at line 29 of file self_info.py.

29 def __init__(self):
30 super().__init__()
31
32 self.ip_regex = re.compile(r"^ip", re.IGNORECASE)
33 self.ua_regex = re.compile(r"^user-agent", re.IGNORECASE)
34
35 self.info = PluginInfo(
36 id=self.id,
37 name=gettext("Self Information"),
38 description=gettext(
39 """Displays your IP if the query is "ip" and your user agent if the query is "user-agent"."""
40 ),
41 preference_section="query",
42 )
43

References __init__().

Referenced by __init__().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ post_search()

EngineResults searx.plugins.self_info.SXNGPlugin.post_search ( self,
"SXNG_Request" request,
"SearchWithPlugins" search )
Returns a result list only for the first page.

Reimplemented from searx.plugins._core.Plugin.

Definition at line 44 of file self_info.py.

44 def post_search(self, request: "SXNG_Request", search: "SearchWithPlugins") -> EngineResults:
45 """Returns a result list only for the first page."""
46 results = EngineResults()
47
48 if search.search_query.pageno > 1:
49 return results
50
51 if self.ip_regex.search(search.search_query.query):
52 results.add(results.types.Answer(answer=gettext("Your IP is: ") + get_real_ip(request)))
53
54 if self.ua_regex.match(search.search_query.query):
55 results.add(results.types.Answer(answer=gettext("Your user-agent is: ") + str(request.user_agent)))
56
57 return results

References ip_regex, and ua_regex.

Member Data Documentation

◆ info

searx.plugins.self_info.SXNGPlugin.info
Initial value:
= PluginInfo(
id=self.id,
name=gettext("Self Information"),
description=gettext(
),
preference_section="query",
)

Definition at line 35 of file self_info.py.

◆ ip_regex

searx.plugins.self_info.SXNGPlugin.ip_regex = re.compile(r"^ip", re.IGNORECASE)

Definition at line 32 of file self_info.py.

Referenced by post_search().

◆ ua_regex

searx.plugins.self_info.SXNGPlugin.ua_regex = re.compile(r"^user-agent", re.IGNORECASE)

Definition at line 33 of file self_info.py.

Referenced by post_search().


The documentation for this class was generated from the following file: