csbot.plugins.linkinfo module¶
-
class
csbot.plugins.linkinfo.LinkInfoHandler(filter: Callable[[urllib.parse.ParseResult], LinkInfoFilterResult], handler: Callable[[urllib.parse.ParseResult, LinkInfoFilterResult], Optional[LinkInfoResult]], exclusive: bool)[source]¶ Bases:
typing.Generic
-
class
csbot.plugins.linkinfo.LinkInfoResult(url: str, text: str, is_error: bool = False, nsfw: bool = False, is_redundant: bool = False)[source]¶ Bases:
object-
url¶ The URL requested
-
text¶ Information about the URL
-
is_error¶ Is an error?
-
nsfw¶ URL is not safe for work?
-
is_redundant¶ URL information is redundant? (e.g. duplicated in URL string)
-
-
class
csbot.plugins.linkinfo.LinkInfo(*args, **kwargs)[source]¶ Bases:
csbot.plugin.Plugin-
class
Config(raw_data=None, trusted_data=None, deserialize_mapping=None, init=True, partial=True, strict=True, validate=False, app_data=None, lazy=False, **kwargs)[source]¶ Bases:
csbot.config.Config-
scan_limit= <IntType() instance on Config as 'scan_limit'>¶
-
minimum_slug_length= <IntType() instance on Config as 'minimum_slug_length'>¶
-
max_file_ext_length= <IntType() instance on Config as 'max_file_ext_length'>¶
-
minimum_path_match= <FloatType() instance on Config as 'minimum_path_match'>¶
-
rate_limit_time= <IntType() instance on Config as 'rate_limit_time'>¶
-
rate_limit_count= <IntType() instance on Config as 'rate_limit_count'>¶
-
max_response_size= <IntType() instance on Config as 'max_response_size'>¶
-
-
register_handler(filter, handler, exclusive=False)[source]¶ Add a URL handler.
filter should be a function that returns a True-like or False-like value to indicate whether handler should be run for a particular URL. The URL is supplied as a
urlparse:ParseResultinstance.If handler is called, it will be as
handler(url, filter(url)). The filter result is useful for accessing the results of a regular expression filter, for example. The result should be aLinkInfoResultinstance. If the result is None instead, the processing will fall through to the next handler; this is the best way to signal that a handler doesn’t know what to do with a particular URL.If exclusive is True, the fall-through behaviour will not happen, instead terminating the handling with the result of calling handler.
-
register_exclude(filter)[source]¶ Add a URL exclusion filter.
filter should be a function that returns a True-like or False-like value to indicate whether or not a URL should be excluded from the default title-scraping behaviour (after all registered handlers have been tried). The URL is supplied as a
urlparse.ParseResultinstance.
-
get_link_info(original_url)[source]¶ Get information about a URL.
Using the original_url string, run the chain of URL handlers and excludes to get a
LinkInfoResult.
-
link_command(e)[source]¶ Handle the “link” command.
Fetch information about a specified URL, e.g.
!link http://google.com. The link can be explicitly marked as NSFW by including the string anywhere in the trailing string, e.g.!link http://lots-of-porn.com nsfw.
-
scan_privmsg(e)[source]¶ Scan the data of PRIVMSG events for URLs and respond with information about them.
-
scrape_html_title(url)[source]¶ Scrape the
<title>tag contents from the HTML page at url.Returns a
LinkInfoResult.
-
class