This is a plugin for the Limnoria IRC Bot. It looks for URLs posted in the channel and responds with a preview of the linked content.
This is the previewer for everything that hasn't a specific previewer. It assumes the URL points to an HTML document and searches for tags like <title> and <meta> tags that describe the document.
Currently searches for name, date and description from these tags:
- schema.org data found in json-ld
<script>tags <title>,<meta description="name">,<meta description="description">and<meta description="date">tags- Twitter Summary Cards
<meta>tags - Open Graph
<meta>tags - Dublin Core
<meta>tags
Requires API key
previews Twitter Status ("Tweets") and Profiles links.
Requires API key
previews YouTube video links.
rewrites URLs to npr.org to text.npr.org equivalents to avoid the cookie consent page, then uses the generic previewer on them.
- requests to connect
- Beautiful Soup to parse HTML with the
genericextractor - python-dateutil for parsing date strings
- regex – because regular
redoesn't handle unicode properly - Install humanize to enable nicer timestamps, like "yesterday" instead of a date string.
Install the requirements in the environment where limnoria runs – if you use pip you can copy this:
pip install beautifulsoup4 humanize python-dateutil regex
Then place the files from this repo into plugins/URLpreviewer and tell your bot to load URLpreviewer.
| Name | Type | Scope | Default | Description |
|---|---|---|---|---|
enabled |
Boolean | channel | True |
controls if the plugin is enabled for the channel |
generic_enabled |
Boolean | global | True |
controls if the generic previewer is enabled |
twitter_enabled |
Boolean | global | False |
controls if the twitter previewer is enabled |
twitter_api_key |
String | global | "" |
holds the Twitter API OAuth 2.0 Bearer token required for the twitter previewer |
youtube_enabled |
Boolean | global | False |
controls if the youtube previewer is enabled |
youtube_api_key |
String | global | "" |
holds the Google Simple API access key required for the youtube previewer |
- This plugin only looks at the first thing that looks vaguely like a URL per message, and gives up if that string can't be previewed.
- some websites don't return anything helpful to a user agent that has JS disabled. Such websites can be added to the blacklist in
previewers/generic.py.
The generic extractor GETs arbitrary URLs. If the bot can access anything via http(s) that's sensitive and not available from the general internet, it might be possible for a user to trick it into doing something nasty.
Loading of the previewers is based on Guido Diepen's blog post Implementing a simple plugin framework in Python. Thank you!