Add 'SpiffyTitles/' from commit '0e67019adcb16c9fea5e295e11cdfecf0c7056f9'
git-subtree-dir: SpiffyTitles git-subtree-mainline:fbacaad20b
git-subtree-split:0e67019adc
This commit is contained in:
commit
4cb0bb44bf
|
@ -0,0 +1,324 @@
|
|||
# SpiffyTitles #
|
||||
|
||||
The ONLY gluten-free plugin for displaying link titles.
|
||||
|
||||
## Notable features
|
||||
|
||||
- Configurable template so you can decide how titles are displayed and what they say
|
||||
- Additional information about [Youtube](https://youtube.com) videos
|
||||
- Additional information about [imgur](https://imgur.com) links
|
||||
- Article extracts from [Wikipedia](https://en.wikipedia.org) links
|
||||
- Rate limiting to mitigate abuse
|
||||
- Configurable white/black list to control where titles are disabled
|
||||
- Configurable list of user agents
|
||||
- Ability to ignore domains using a regular expression
|
||||
|
||||
Check out the [available options](#available-options)!
|
||||
|
||||
## Install SpiffyTitles
|
||||
- `git clone https://github.com/butterscotchstallion/limnoria-plugins.git`
|
||||
- `cd limnoria-plugins`
|
||||
- `cp -r SpiffyTitles ~/your_bot_directory/plugins`
|
||||
- `cd ~/your_bot_directory/plugins/SpiffyTitles`
|
||||
- `pip install -r requirements.txt --user --upgrade`
|
||||
- If you need to install `certifi` you may have to restart the bot afterwards
|
||||
|
||||
You should `!unload Web` and any other plugins that show link titles for best results
|
||||
|
||||
Load SpiffyTitles:
|
||||
|
||||
!load SpiffyTitles
|
||||
|
||||
Pro Tip: Observe the logs when loading the plugin and afterwards to see if there are any errors.
|
||||
|
||||
You can increase the verbosity of the logging in SpiffyTitles by issuing the following command:
|
||||
|
||||
|
||||
`!config supybot.log.level DEBUG`
|
||||
|
||||
|
||||
## On-Demand Titles
|
||||
You can retrieve titles on demand using the `t` command. If something goes wrong, `onDemandTitleError`
|
||||
will be sent instead of the link title.
|
||||
|
||||
## Available Options
|
||||
|
||||
### Note
|
||||
Almost all of the below options can be customized per-channel.
|
||||
|
||||
Example:
|
||||
|
||||
`!config channel ##example-channel-one supybot.plugins.SpiffyTitles.defaultTitleTemplate "^ {{title}}"`
|
||||
|
||||
`!config channel ##example-channel-two supybot.plugins.SpiffyTitles.defaultTitleTemplate ":: {{title}}"`
|
||||
|
||||
This means that you can change whether a handler is enabled, or what the template looks like for any channel.
|
||||
|
||||
### Default handler
|
||||
|
||||
`defaultHandlerEnabled` - Whether to show additional information about links that aren't handled elsewhere. You'd really only want to disable this if all of the other handlers were enabled. In this scenario, the bot would only show information for websites with custom handlers, like Youtube, IMDB, and imgur.
|
||||
|
||||
`defaultTitleTemplate` - This is the template used when showing the title of a link.
|
||||
|
||||
Default value: `^ {{title}}`
|
||||
|
||||
Example output:
|
||||
|
||||
^ Google.com
|
||||
|
||||
### Youtube handler
|
||||
|
||||
Note: as of April 20 2015 version 2 of the Youtube API was deprecated. As a result, this feature now
|
||||
requires a [developer key](https://code.google.com/apis/youtube/dashboard/gwt/index.html#settings).
|
||||
|
||||
- Obtain a [developer key](https://code.google.com/apis/youtube/dashboard/gwt/index.html#settings)
|
||||
- Click the link on the left to go to the `Credentials` area under `APIs and auth`
|
||||
- Click `Create new Key` under `Public API access`
|
||||
- Choose `Server key`
|
||||
- Click `Create` as shown in the screenshot below
|
||||
|
||||

|
||||
|
||||
- You may specify allowed IPs but be aware that this setting seems to cache. It is easier to test using the URL listed in the console to verify requests from that machine are working.
|
||||
- Make sure the YouTube API is enabled in [the developer console](https://developers.google.com/console/help/#activatingapis).
|
||||
- Set the key: `!config supybot.plugins.SpiffyTitles.youtubeDeveloperKey your_developer_key_here`
|
||||
- Observe the logs to check for errors
|
||||
|
||||
### Youtube handler options
|
||||
|
||||
`youtubeHandlerEnabled` - Whether to show additional information about Youtube links
|
||||
|
||||
`youtubeTitleTemplate` - This is the template used when showing the title of a YouTube video
|
||||
|
||||
Default value: `^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} uploaded by {{channel_title}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites`
|
||||
|
||||
Example output:
|
||||
|
||||
^ Snoop Dogg - Pump Pump feat. Lil Malik uploaded by GeorgeRDR3218 @ 00:45:: Duration: 04:41 :: 203,218 views :: 933 likes :: 40 dislikes :: 0 favorites :: 112 comments
|
||||
|
||||
### Available variables for the Youtube template ###
|
||||
|
||||
Variable | Description
|
||||
---------------|------------
|
||||
yt_logo | Colored YouTube logo
|
||||
title | Video title
|
||||
channel_title | Channel title
|
||||
duration | Duration
|
||||
view_count | Number of views
|
||||
like_count | Number of likes
|
||||
dislike_count | Number of dislikes
|
||||
favorite_count | Number of favorites
|
||||
comment_count | Number of comments
|
||||
timestamp | If specified, the start time of the video
|
||||
|
||||
Tip: You can use irc colors colors in your templates, but be sure to quote the value
|
||||
|
||||
### imdb handler
|
||||
Queries the [OMDB API](http://www.omdbapi.com) to get additional information about [IMDB](http://imdb.com) links
|
||||
|
||||
`omdbAPI` - Set your OMDB API key here
|
||||
|
||||
`imdbHandlerEnabled` - Whether to show additional information about [IMDB](http://imdb.com) links
|
||||
|
||||
`imdbTemplate` - This is the template used for [IMDB](http://imdb.com) links
|
||||
|
||||
Default value: `^ {{Title}} ({{Year}}, {{Country}}) - Rating: {{imdbRating}} :: {{Plot}}`
|
||||
|
||||
### imgur handler
|
||||
|
||||
`imgurTemplate` - This is the template used when showing information about an [imgur](https://imgur.com) link.
|
||||
|
||||
Default value
|
||||
|
||||
^ {%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{type}} {{width}}x{{height}} {{file_size}} :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}
|
||||
|
||||
Example output:
|
||||
|
||||
^ [pics] He really knows nothing... :: image/jpeg 700x1575 178.8KiB :: 809 views :: safe for work
|
||||
|
||||
`imgurAlbumTemplate` - This is the template used when showing information about an imgur album link.
|
||||
|
||||
Default value
|
||||
|
||||
^ {%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{image_count}} images :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}
|
||||
|
||||
Example output:
|
||||
|
||||
^ [compsci] Regex Fractals :: 33 images :: 21,453 views :: safe for work
|
||||
|
||||
### Using the imgur handler
|
||||
|
||||
- You'll need to [register an application with imgur](https://api.imgur.com/oauth2/addclient)
|
||||
- Select "OAuth 2 authorization without a callback URL"
|
||||
- Once registered, set your client id and client secret
|
||||
|
||||
`!config supybot.plugins.SpiffyTitles.imgurClientID`
|
||||
|
||||
`!config supybot.plugins.SpiffyTitles.imgurClientSecret`
|
||||
|
||||
### Notes on the imgur handler
|
||||
|
||||
- If there is a problem reaching the API the default handler will be used as a fallback. See logs for details.
|
||||
- The API seems to report information on the originally uploaded image and not other formats
|
||||
- If you see something from [the imgur api](https://api.imgur.com/models/image) that you want and is not available
|
||||
in the above example, [please open an issue!](https://github.com/butterscotchstallion/limnoria-plugins/issues/new)
|
||||
|
||||
### coub handler
|
||||
|
||||
`coubTemplate` - Template for [coub](http://coub.com) links.
|
||||
|
||||
Default value: `^ {%if not_safe_for_work %}NSFW{% endif %} [{{channel.title}}] {{title}} :: {{views_count}} views :: {{likes_count}} likes :: {{recoubs_count}} recoubs`
|
||||
|
||||
`coubHandlerEnabled` - Whether to enable additional information about coub videos.
|
||||
|
||||
### vimeo handler
|
||||
|
||||
`vimeoTitleTemplate` - Template for [vimeo](https://vimeo.com) links.
|
||||
|
||||
Default value: `^ {{title}} :: Duration: {{duration}} :: {{stats_number_of_plays}} plays :: {{stats_number_of_comments}} comments`
|
||||
|
||||
`vimeoHandlerEnabled` - Whether to enable additional information about vimeo videos.
|
||||
|
||||
### dailymotion handler
|
||||
|
||||
`dailymotionVideoTitleTemplate` - Template for [dailymotion](https://www.dailymotion.com) links.
|
||||
|
||||
Default value: `^ [{{ownerscreenname}}] {{title}} :: Duration: {{duration}} :: {{views_total}} views`
|
||||
|
||||
`dailymotionHandlerEnabled` - Whether to enable additional information about dailymotion videos.
|
||||
|
||||
### wikipedia handler
|
||||
|
||||
`wikipedia.enabled` - Whether to fetch extracts for Wikipedia articles.
|
||||
|
||||
`wikipedia.extractTemplate` - Wikipedia template.
|
||||
|
||||
Default value: "^ {{extract}}"
|
||||
|
||||
`wikipedia.maxChars` - Extract will be cut to this length (including '...').
|
||||
|
||||
Default value: 240
|
||||
|
||||
`wikipedia.removeParentheses` - Whether to remove parenthesized text from output.
|
||||
|
||||
`wikipedia.ignoreSectionLinks` - Whether to ignore links to specific article sections.
|
||||
|
||||
`wikipedia.apiParams` - Add or override API query parameters with a space-separated list of key=value pairs.
|
||||
|
||||
`wikipedia.titleParam` - The query parameter that will hold the page title from the URL.
|
||||
|
||||
|
||||
## Other options
|
||||
|
||||
`useBold` - Whether to bold the title. Default value: `False`
|
||||
|
||||
`linkCacheLifetimeInSeconds` - Caches the title of links. This is useful for reducing API usage and
|
||||
improving performance. Default value: `60`
|
||||
|
||||
`wallClockTimeoutInSeconds` - Timeout for total elapsed time when retrieving a title. If you set this value too
|
||||
high, the bot may time out. Default value: `8` (seconds). You must `!reload SpiffyTitles` for this setting to take effect.
|
||||
|
||||
`channelWhitelist` - a comma separated list of channels in which titles should be displayed. If `""`,
|
||||
titles will be shown in all channels. Default value: `""`
|
||||
|
||||
`channelBlacklist` - a comma separated list of channels in which titles should never be displayed. If `""`,
|
||||
titles will be shown in all channels. Default value: `""`
|
||||
|
||||
### About white/black lists
|
||||
- Channel names must be in lowercase
|
||||
- If `channelWhitelist` and `channelBlacklist` are empty, then titles will be displayed in every channel
|
||||
- If `channelBlacklist` has #foo, then titles will be displayed in every channel except #foo
|
||||
- If `channelWhitelist` has #foo then `channelBlacklist` will be ignored
|
||||
|
||||
### Examples
|
||||
|
||||
### Show titles in every channel except #foo
|
||||
|
||||
!config supybot.plugins.SpiffyTitles.channelBlacklist #foo
|
||||
|
||||
### Only show titles in #bar
|
||||
|
||||
!config supybot.plugins.SpiffyTitles.channelWhitelist #bar
|
||||
|
||||
### Only show titles in #baz and #bar
|
||||
|
||||
!config supybot.plugins.SpiffyTitles.channelWhitelist #baz,#bar
|
||||
|
||||
### Remove channel whitelist
|
||||
|
||||
!config supybot.plugins.SpiffyTitles.channelWhitelist ""
|
||||
|
||||
`ignoredDomainPattern` - ignore domains matching this pattern. Default value: `""`
|
||||
|
||||
`whitelistDomainPattern` - ignore any link without a domain matching this pattern. Default value: `""`
|
||||
|
||||
### Pro Tip
|
||||
|
||||
You can ignore domains that you know aren't websites. This prevents a request from being made at all.
|
||||
|
||||
### Examples
|
||||
|
||||
Ignore all links with the domain `buzzfeed.com`
|
||||
|
||||
!config supybot.plugins.SpiffyTitles.ignoredDomainPattern (buzzfeed\.com)
|
||||
|
||||
Ignore `*.tk` and `buzzfeed.com`
|
||||
|
||||
!config supybot.plugins.SpiffyTitles.ignoredDomainPattern (\.tk|buzzfeed\.com)
|
||||
|
||||
Ignore all links except youtube, imgur, and reddit
|
||||
|
||||
!config supybot.plugins.SpiffyTitles.whitelistDomainPattern /(reddit\.com|youtube\.com|youtu\.be|imgur\.com)/
|
||||
|
||||
`userAgents` - A comma separated list of strings of user agents randomly chosen when requesting.
|
||||
|
||||
`urlRegularExpression` - A regular expression used to match URLs. You shouldn't need to change this.
|
||||
|
||||
`linkMessageIgnorePattern` - If a message matches this pattern, it will be ignored. This differs from `ignoredDomainPattern` in that it compares against the entire message rather than just the domain.
|
||||
|
||||
Example: `!config supybot.plugins.SpiffyTitles.linkMessageIgnorePattern "/\[tw\]/"`
|
||||
|
||||
This would ignore any message that contains "[tw]".
|
||||
|
||||
`ignoreActionLinks` (Boolean) - By default SpiffyTitles will ignore links that appear in an action, like `/me`.
|
||||
|
||||
`requireCapability` (String) - If defined, SpiffyTitles will only acknowledge links from users with this capability. Useful for hostile environments. [Refer to Limnoria's documentation on capabilities for more information](http://doc.supybot.aperio.fr/en/latest/use/capabilities.html)
|
||||
|
||||
`ignoredTitlePattern` (Regexp) - If the parsed title matches this regular expression, it will be ignored.
|
||||
|
||||
Example: `!config channel #example supybot.plugins.SpiffyTitles.ignoredTitlePattern m/^\^ Google$|- Google Search$|^\^ Google Maps$|^\^ Imgur: The most awesome images on the Internet$|^\^ Pastebin \| IRCCloud|^\^ Instagram|^\^ Urban Dictionary:|– Wikipedia$|- Wikipedia, the free encyclopedia$|- Wiktionary$| - RationalWiki$|^\^ Meet Google Drive|- Wikia$|^\^ Imgur$|^\^ Google Trends|^\^ reactiongifs/`
|
||||
|
||||
This line would ignore any link which results in a title matching the above pattern.
|
||||
|
||||
### FAQ
|
||||
|
||||
Q: I have a question. Where can I get help?
|
||||
|
||||
A: Join #limnoria on chat.freenode.net
|
||||
|
||||
Q: I'm getting the error `Error: That configuration variable is not a channel-specific configuration variable.`
|
||||
when I try to change a configuration value.
|
||||
|
||||
A: Some configuration values were previously global. Simply restart your bot to fix this error.
|
||||
|
||||
Q: How can I only show information about certain links?
|
||||
|
||||
A: You can use the settings `defaultHandlerEnabled`, `youtubeHandlerEnabled`, `imgurHandlerEnabled`, and `imdbHandlerEnabled` to choose which links you want to show information about.
|
||||
|
||||
Q: Why not use the [Web](https://github.com/ProgVal/Limnoria/tree/master/plugins/Web) plugin?
|
||||
|
||||
A: My experience was that it didn't work very well and lacked the ability to customize the options
|
||||
I wanted to change.
|
||||
|
||||
Q: What about [Supybot-Titler](https://github.com/reticulatingspline/Supybot-Titler) ?
|
||||
|
||||
A: I couldn't get this to work on my system and it has a lot of features I didn't want
|
||||
|
||||
Q: It doesn't work for me. What can I do?
|
||||
|
||||
A: [Open an issue](https://github.com/butterscotchstallion/limnoria-plugins/issues/new) and include at minimum the following:
|
||||
|
||||
- Brief description of the problem
|
||||
- Any errors that were logged (Look for the ones prefixed "SpiffyTitles")
|
||||
- How to reproduce the effect
|
||||
- Any other information you think would be helpful
|
|
@ -0,0 +1,44 @@
|
|||
###
|
||||
# Copyright (c) 2015, butterscotchstallion
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
###
|
||||
|
||||
"""
|
||||
SpiffyTitles: Displays link titles when posted in a channel
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = ""
|
||||
|
||||
# XXX Replace this with an appropriate author or supybot.Author instance.
|
||||
__author__ = supybot.authors.unknown
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
# This is a url where the most recent plugin package can be downloaded.
|
||||
__url__ = ''
|
||||
|
||||
from . import config
|
||||
from . import plugin
|
||||
from imp import reload
|
||||
# In case we're being reloaded.
|
||||
reload(plugin)
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
from . import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
|
@ -0,0 +1,209 @@
|
|||
###
|
||||
# Copyright (c) 2015, butterscotchstallion
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
_ = PluginInternationalization('SpiffyTitles')
|
||||
except:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
_ = lambda x: x
|
||||
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified themself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('SpiffyTitles', True)
|
||||
|
||||
|
||||
SpiffyTitles = conf.registerPlugin('SpiffyTitles')
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles, 'maxRetries',
|
||||
registry.Integer(3, _("""Maximum retries upon failure""")))
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles, 'verifySSL',
|
||||
registry.Boolean(True, _("""Request websites if SSL cert verification fails?""")))
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles, 'wallClockTimeoutInSeconds',
|
||||
registry.Integer(8, _("""Timeout for getting a title. If you set this too high, the bot will time out.""")))
|
||||
|
||||
# Language
|
||||
conf.registerGlobalValue(SpiffyTitles, 'language',
|
||||
registry.String("en-US", _("""Language code""")))
|
||||
|
||||
# enable/disable toggles
|
||||
conf.registerChannelValue(SpiffyTitles, 'coubHandlerEnabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about coub links""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'defaultHandlerEnabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about regular links""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'youtubeHandlerEnabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about YouTube videos""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'imgurHandlerEnabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about imgur links""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'imdbHandlerEnabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about IMDB links""")))
|
||||
|
||||
# URL regex
|
||||
conf.registerGlobalValue(SpiffyTitles, 'urlRegularExpression',
|
||||
registry.String(r"(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})", _("""This regular expression will be used to match URLs""")))
|
||||
|
||||
# Bold
|
||||
conf.registerChannelValue(SpiffyTitles, 'useBold',
|
||||
registry.Boolean(False, _("""Use bold in titles""")))
|
||||
|
||||
# Title template - show a warning if redirects to a different domain
|
||||
conf.registerChannelValue(SpiffyTitles, 'defaultTitleTemplate',
|
||||
registry.String("{% if redirect %}(REDIRECT) {% endif %}^ {{title}}", _("""Template used for default title responses""")))
|
||||
|
||||
#OMDB API Key
|
||||
conf.registerGlobalValue(SpiffyTitles, 'omdbAPI',
|
||||
registry.String('', _("""OMDB API Key""")))
|
||||
|
||||
# imdb template
|
||||
conf.registerChannelValue(SpiffyTitles, 'imdbTemplate',
|
||||
registry.String("^ {{Title}} ({{Year}}, {{Country}}) - Rating: {{imdbRating}} :: {{Plot}}", _("""Uses http://www.omdbapi.com to provide additional information about IMDB links""")))
|
||||
|
||||
# alternative imdb template:
|
||||
# ^ {{Title}} ({{Year}} - {{Director}}) :: [i:{{imdbRating}} r:{{tomatoMeter}} m:{{Metascore}}] {{Plot}}
|
||||
|
||||
# coub template
|
||||
conf.registerChannelValue(SpiffyTitles, 'coubTemplate',
|
||||
registry.String("^ {%if not_safe_for_work %}NSFW{% endif %} [{{channel.title}}] {{title}} :: {{views_count}} views :: {{likes_count}} likes :: {{recoubs_count}} recoubs", _("""Uses Coub API to get additional information about coub.com links""")))
|
||||
|
||||
# YouTube template
|
||||
conf.registerChannelValue(SpiffyTitles, 'youtubeTitleTemplate',
|
||||
registry.String("^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} uploaded by {{channel_title}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites", _("""Template used for YouTube title responses""")))
|
||||
|
||||
# Vimeo template
|
||||
conf.registerChannelValue(SpiffyTitles, 'vimeoTitleTemplate',
|
||||
registry.String("^ {{title}} :: Duration: {{duration}} :: {{stats_number_of_plays}} plays :: {{stats_number_of_comments}} comments", _("""Template used for Vimeo title responses""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'vimeoHandlerEnabled',
|
||||
registry.Boolean(True, _("""Enable additional information about Vimeo videos""")))
|
||||
|
||||
# dailymotion template
|
||||
conf.registerChannelValue(SpiffyTitles, 'dailymotionVideoTitleTemplate',
|
||||
registry.String("^ [{{ownerscreenname}}] {{title}} :: Duration: {{duration}} :: {{views_total}} views", _("""Template used for Vimeo title responses""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'dailymotionHandlerEnabled',
|
||||
registry.Boolean(True, _("""Enable additional information about dailymotion videos""")))
|
||||
|
||||
# User agents
|
||||
conf.registerGlobalValue(SpiffyTitles, 'userAgents',
|
||||
registry.CommaSeparatedListOfStrings(["Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.60 Safari/537.36", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"], _("""Reported user agent when fetching links""")))
|
||||
|
||||
# Mime Types
|
||||
conf.registerGlobalValue(SpiffyTitles, 'mimeTypes',
|
||||
registry.CommaSeparatedListOfStrings(["text/html"], _("""Acceptable mime types for displaying titles""")))
|
||||
|
||||
# Ignored domain pattern
|
||||
conf.registerChannelValue(SpiffyTitles, 'ignoredDomainPattern',
|
||||
registry.Regexp("", _("""Domains matching this patterns will be ignored""")))
|
||||
|
||||
# Whitelist domain pattern
|
||||
conf.registerChannelValue(SpiffyTitles, 'whitelistDomainPattern',
|
||||
registry.Regexp("", _("""Domains not matching this patterns will be ignored""")))
|
||||
|
||||
# Channel whitelist
|
||||
conf.registerGlobalValue(SpiffyTitles, 'channelWhitelist',
|
||||
registry.CommaSeparatedListOfStrings([], _("""Only show titles on these channels, or all if empty""")))
|
||||
|
||||
# Channel blacklist
|
||||
conf.registerGlobalValue(SpiffyTitles, 'channelBlacklist',
|
||||
registry.CommaSeparatedListOfStrings([], _("""Never show titles on these channels""")))
|
||||
|
||||
# imgur API
|
||||
conf.registerGlobalValue(SpiffyTitles, 'imgurClientID',
|
||||
registry.String("", _("""imgur client ID"""), private=True))
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles, 'imgurClientSecret',
|
||||
registry.String("", _("""imgur client secret"""), private=True))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'imgurTemplate',
|
||||
registry.String("^{%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{type}} {{width}}x{{height}} {{file_size}} :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}", _("""imgur template""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'imgurAlbumTemplate',
|
||||
registry.String("^{%if section %} [{{section}}] {% endif -%}{%- if title -%} {{title}} :: {% endif %}{{image_count}} images :: {{view_count}} views :: {%if nsfw == None %}not sure if safe for work{% elif nsfw == True %}not safe for work!{% else %}safe for work{% endif %}", _("""imgur template""")))
|
||||
|
||||
# Youtube API
|
||||
conf.registerGlobalValue(SpiffyTitles, 'youtubeDeveloperKey',
|
||||
registry.String("", _("""Youtube developer key - required for Youtube handler."""), private=True))
|
||||
|
||||
# Link cache lifetime
|
||||
conf.registerGlobalValue(SpiffyTitles, 'linkCacheLifetimeInSeconds',
|
||||
registry.Integer(60, _("""Link cache lifetime in seconds""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'onDemandTitleError',
|
||||
registry.String("Error retrieving title.", _("""This error message is used when there is a problem getting an on-demand title""")))
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles, 'linkMessageIgnorePattern',
|
||||
registry.Regexp("", _("""Messages matching this pattern will be ignored.""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'ignoreActionLinks',
|
||||
registry.Boolean(True, _("""Ignores URLs that appear in an action such as /me""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'requireCapability',
|
||||
registry.String("", _("""If defined, SpiffyTitles will only acknowledge links from users with this capability. Useful for hostile environments.""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles, 'ignoredTitlePattern',
|
||||
registry.Regexp("", _("""Titles matching this pattern will be ignored.""")))
|
||||
|
||||
|
||||
conf.registerGroup(SpiffyTitles, 'wikipedia')
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to fetch extracts for Wikipedia articles.""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'apiParams',
|
||||
registry.SpaceSeparatedListOfStrings([], _("""Add or override API query parameters with a space-separated list of key=value pairs.""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'titleParam',
|
||||
registry.String("titles", _("""The query parameter that will hold the page title from the URL.""")))
|
||||
|
||||
# Ideally, links to specific article sections would produce the relevant output for that section. This is not currently implemented.
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'ignoreSectionLinks',
|
||||
registry.Boolean(True, _("""Ignore links to specific article sections.""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'maxChars',
|
||||
registry.Integer(240, _("""Extract will be cut to this length (including '...').""")))
|
||||
|
||||
# Remove parenthesized text from output.
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'removeParentheses',
|
||||
registry.Boolean(True, _("""Remove parenthesized text from output.""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'extractTemplate',
|
||||
registry.String("^ {{extract}}", _("""Wikipedia template.""")))
|
||||
|
||||
|
||||
conf.registerGroup(SpiffyTitles, 'reddit')
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional info about Reddit links.""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'linkThreadTemplate',
|
||||
registry.String(u"/r/{{subreddit}}{% if title %} :: {{title}}{% endif %} :: {{score}} points ({{percent}}) :: {{comments}} comments :: Posted {{age}} by {{author}}{% if url %} :: {{url}} ({{domain}}){% endif %}", _("""Template used for Reddit link thread title responses""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'textThreadTemplate',
|
||||
registry.String(u"/r/{{subreddit}}{% if title %} :: {{title}}{% endif %}{% if extract %} :: {{extract}}{% endif %} :: {{score}} points ({{percent}}) :: {{comments}} comments :: Posted {{age}} by {{author}}", _("""Template used for Reddit text thread title responses""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'commentTemplate',
|
||||
registry.String(u"/r/{{subreddit}}{% if extract %} :: {{extract}}{% endif %} :: {{score}} points :: Posted {{age}} by {{author}} on \"{{title}}\"", _("""Template used for Reddit comment title responses""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'userTemplate',
|
||||
registry.String(u"/u/{{user}}{% if gold %} :: (GOLD{% if mod %}, MOD{% endif %}){% endif %} :: Joined: {{created}} :: Link karma: {{link_karma}} :: Comment karma: {{comment_karma}}", _("""Template used for Reddit user page title responses""")))
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'maxChars',
|
||||
registry.Integer(400, _("""Length of response (title/extract will be cut to fit).""")))
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,9 @@
|
|||
html5lib
|
||||
lxml
|
||||
beautifulsoup4
|
||||
jinja2
|
||||
imgurpython
|
||||
requests
|
||||
timeout-decorator
|
||||
certifi
|
||||
pytz
|
|
@ -0,0 +1,20 @@
|
|||
###
|
||||
# Copyright (c) 2015, butterscotchstallion
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
|
||||
class SpiffyTitlesTestCase(ChannelPluginTestCase):
|
||||
plugins = ('SpiffyTitles',)
|
||||
|
||||
def setUp(self):
|
||||
ChannelPluginTestCase.setUp(self)
|
||||
|
||||
self.assertNotError('reload SpiffyTitles')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
Loading…
Reference in New Issue