Skip to content

cbcb/limnoria-URLpreview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Bundled Previewers

Generic

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:

Twitter

Requires API key

previews Twitter Status ("Tweets") and Profiles links.

YouTube

Requires API key

previews YouTube video links.

NPR

rewrites URLs to npr.org to text.npr.org equivalents to avoid the cookie consent page, then uses the generic previewer on them.

Requirements

  • requests to connect
  • Beautiful Soup to parse HTML with the generic extractor
  • python-dateutil for parsing date strings
  • regex – because regular re doesn't handle unicode properly
  • Install humanize to enable nicer timestamps, like "yesterday" instead of a date string.

Installation

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.

Configuration variables

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

Limitations

  • 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.

Security

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.

Useful links

Acknowledgments

Loading of the previewers is based on Guido Diepen's blog post Implementing a simple plugin framework in Python. Thank you!

About

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.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages