mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-25 20:41:21 -05:00
SpiffyTitles: cleanup, add default.fileTemplate config
This commit is contained in:
parent
126bf48f0d
commit
3d9d0ac8b6
@ -1,17 +0,0 @@
|
||||
Generate markov replies to channel messages.
|
||||
|
||||
Forked from: https://github.com/ProgVal/Supybot-plugins/tree/master/Markovgen
|
||||
|
||||
Additions:
|
||||
|
||||
plugins.Markovgen.ignorePattern (set regex patterns for the bot to ignore)
|
||||
|
||||
plugins.Markovgen.stripPattern (set regex patterns for the bot to strip)
|
||||
|
||||
plugins.Markovgen.stripURL (determine if the bot will strip URLs)
|
||||
|
||||
plugins.Markovgen.ignoreNicks (list of nicks to ignore)
|
||||
|
||||
plugins.Markovgen.ignoreCommands (ignore commands sent to the bot)
|
||||
|
||||
plugins.Markovgen.stripFormatting (strip bold, underline, and color from messages)
|
@ -1,72 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2014, Valentin Lorentz
|
||||
# Copyright (c) 2020, oddluck <oddluck@riseup.net>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Markovgen: reply to messages with markov generated text
|
||||
"""
|
||||
|
||||
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__ = "2020.02.24+git"
|
||||
|
||||
# XXX Replace this with an appropriate author or supybot.Author instance.
|
||||
|
||||
__author__ = getattr(supybot.authors, 'progval',
|
||||
supybot.Author('Valentin Lorentz', 'ProgVal', 'progval@gmail.com'))
|
||||
__maintainer__ = getattr(supybot.authors, 'oddluck',
|
||||
supybot.Author('oddluck', 'oddluck', 'oddluck@riseup.net'))
|
||||
|
||||
# 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__ = 'https://github.com/oddluck/limnoria-plugins/'
|
||||
|
||||
from . import config
|
||||
from . import plugin
|
||||
from imp import reload
|
||||
# In case we're being reloaded.
|
||||
reload(config)
|
||||
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:
|
@ -1,88 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2014, Valentin Lorentz
|
||||
# Copyright (c) 2020, oddluck <oddluck@riseup.net>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
_ = PluginInternationalization('Markovgen')
|
||||
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('Markovgen', True)
|
||||
|
||||
|
||||
Markovgen = conf.registerPlugin('Markovgen')
|
||||
# This is where your configuration variables (if any) should go. For example:
|
||||
# conf.registerGlobalValue(Markovgen, 'someConfigVariableName',
|
||||
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
||||
conf.registerChannelValue(Markovgen, 'enable',
|
||||
registry.Boolean(False, _("""Determines whether the plugin is enabled
|
||||
on a channel. This defaults to False to avoid useless resources
|
||||
consumption.""")))
|
||||
conf.registerChannelValue(Markovgen, 'probability',
|
||||
registry.Probability(0, _("""Determine the probability the bot has to
|
||||
reply to a message.""")))
|
||||
conf.registerChannelValue(Markovgen, 'stripRelayedNick',
|
||||
registry.Boolean(True, _("""Determines whether the bot will strip
|
||||
strings like <XXX> at the beginning of messages.""")))
|
||||
conf.registerChannelValue(Markovgen, 'ignorePattern',
|
||||
registry.Regexp("", _("""Mesages matching this pattern will be ignored.""")))
|
||||
conf.registerChannelValue(Markovgen, 'stripPattern',
|
||||
registry.Regexp("", _("""Text matching this pattern will be stripped.""")))
|
||||
conf.registerChannelValue(Markovgen, 'stripURL',
|
||||
registry.Boolean(True, _("""Determines whether the bot will strip
|
||||
URLs from messages.""")))
|
||||
conf.registerChannelValue(Markovgen, 'ignoreNicks',
|
||||
registry.SpaceSeparatedListOfStrings([], _("""A list of nicks to be ignored by the bot""")))
|
||||
conf.registerChannelValue(Markovgen, 'stripFormatting',
|
||||
registry.Boolean(True, _("""Determines whether the bot will strip
|
||||
bold, underline, and colors from messages.""")))
|
||||
conf.registerChannelValue(Markovgen, 'ignoreCommands',
|
||||
registry.Boolean(True, _("""Determines whether the bot will ignore commands.""")))
|
||||
|
||||
conf.registerGroup(Markovgen, 'onNick')
|
||||
conf.registerChannelValue(Markovgen.onNick, 'probability',
|
||||
registry.Probability(0, _("""Determine the probability the bot has to
|
||||
reply to a message containing its nick.""")))
|
||||
conf.registerChannelValue(Markovgen.onNick, 'replaceNick',
|
||||
registry.Boolean(True, _("""Determine whether the bot will replace its
|
||||
nick by the original author's when replying to a message containing
|
||||
its nick.""")))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,254 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2014, Valentin Lorentz
|
||||
# Copyright (c) 2020, oddluck <oddluck@riseup.net>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import glob
|
||||
import random
|
||||
import functools
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.world as world
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.callbacks as callbacks
|
||||
import supybot.log as log
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
_ = PluginInternationalization('Markovgen')
|
||||
except ImportError:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
_ = lambda x:x
|
||||
|
||||
try:
|
||||
import markovgen
|
||||
except ImportError:
|
||||
raise callbacks.Error('Cannot load markovgen library. Make sure you '
|
||||
'installed it (%s -m pip install markovgen).'
|
||||
% sys.executable)
|
||||
from imp import reload as r
|
||||
r(markovgen)
|
||||
|
||||
MATCH_MESSAGE_STRIPNICK = re.compile('^(<[^ ]+> )?(?P<message>.*)$')
|
||||
|
||||
CHANNELLOGER_REGEXP_BASE = re.compile('^[^ ]* (<[^ ]+> )?(?P<message>.*)$')
|
||||
CHANNELLOGER_REGEXP_STRIPNICK = re.compile('^[^ ]* (<[^ ]+> )?(<[^ ]+> )?(?P<message>.*)$')
|
||||
|
||||
def get_channelloger_extracter(stripRelayedNick):
|
||||
@markovgen.mixed_encoding_extracting
|
||||
def channelloger_extracter(x):
|
||||
regexp = CHANNELLOGER_REGEXP_STRIPNICK if stripRelayedNick else \
|
||||
CHANNELLOGER_REGEXP_BASE
|
||||
m = regexp.match(x)
|
||||
if m:
|
||||
return m.group('message')
|
||||
return channelloger_extracter
|
||||
|
||||
def get_extracter(name):
|
||||
regexp = re.compile(markovgen.REGEXPS[name])
|
||||
@markovgen.mixed_encoding_extracting
|
||||
def extracter(x):
|
||||
msg = regexp.match(x)
|
||||
if msg:
|
||||
return msg.group('message')
|
||||
return extracter
|
||||
|
||||
def rec_list_files(path):
|
||||
return (os.path.join(dp, f)
|
||||
for dp, dn, filenames in os.walk(path)
|
||||
for f in filenames)
|
||||
|
||||
class Markovgen(callbacks.Plugin):
|
||||
"""Add the help for "@plugin help Markovgen" here
|
||||
This should describe *how* to use this plugin."""
|
||||
threaded = True
|
||||
|
||||
def __init__(self, irc):
|
||||
super(Markovgen, self).__init__(irc)
|
||||
self._markovs = {}
|
||||
|
||||
def _load_from_channellogger(self, irc, channel, m):
|
||||
cb = irc.getCallback('ChannelLogger')
|
||||
if not cb:
|
||||
return
|
||||
extracter = get_channelloger_extracter(
|
||||
self.registryValue('stripRelayedNick', channel))
|
||||
for irc in world.ircs:
|
||||
for filename in glob.glob(cb.getLogDir(irc, channel) + '/*.log'):
|
||||
with open(filename, 'rb') as fd:
|
||||
m.feed_from_file(fd, extracter)
|
||||
|
||||
def _load_from_data(self, irc, channel, m):
|
||||
base_path = os.path.join(conf.supybot.directories.data(), 'Markovgen', channel)
|
||||
if not os.path.isdir(base_path):
|
||||
return
|
||||
for extracter_name in os.listdir(base_path):
|
||||
extracter = get_extracter(extracter_name)
|
||||
path = os.path.join(base_path, extracter_name)
|
||||
path = glob.escape(path)
|
||||
filenames = rec_list_files(path)
|
||||
for filename in filenames:
|
||||
with open(filename, 'rb') as fd:
|
||||
m.feed_from_file(fd, extracter)
|
||||
|
||||
|
||||
def _get_markov(self, irc, channel):
|
||||
if channel not in self._markovs:
|
||||
m = markovgen.Markov()
|
||||
self._markovs[channel] = m
|
||||
self._load_from_channellogger(irc, channel, m)
|
||||
self._load_from_data(irc, channel, m)
|
||||
else:
|
||||
m = self._markovs[channel]
|
||||
return m
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
(channel, message) = msg.args
|
||||
if not irc.isChannel(channel):
|
||||
return
|
||||
if not self.registryValue('enable', channel):
|
||||
return
|
||||
if self.registryValue('ignoreCommands', channel) and callbacks.addressed(irc.nick, msg):
|
||||
return
|
||||
match = False
|
||||
ignore = self.registryValue("ignorePattern", channel)
|
||||
strip = self.registryValue("stripPattern", channel)
|
||||
if ignore:
|
||||
match = re.search(ignore, message)
|
||||
if match:
|
||||
log.debug("Markovgen: %s matches ignorePattern for %s" % (message, channel))
|
||||
return
|
||||
if msg.nick.lower() in self.registryValue('ignoreNicks', channel):
|
||||
log.debug("Markovgen: nick %s in ignoreNicks for %s" % (msg.nick, channel))
|
||||
return
|
||||
m = self._get_markov(irc, channel)
|
||||
if self.registryValue('stripFormatting', channel):
|
||||
message = ircutils.stripFormatting(message)
|
||||
if strip:
|
||||
match = re.findall(strip, message)
|
||||
if match:
|
||||
for x in match:
|
||||
message = message.replace(x, '')
|
||||
message = re.sub('\s+', ' ', message)
|
||||
log.debug("Markovgen: %s matches stripPattern for %s. New message text: %s" % (x, channel, message))
|
||||
if self.registryValue('stripURL', channel):
|
||||
new_message = re.sub(r'(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))', '', message)
|
||||
new_message = re.sub('\s+', ' ', new_message)
|
||||
if new_message != message:
|
||||
log.debug("Markovgen: url(s) stripped from message for %s. New message text: %s" % (channel, new_message))
|
||||
message = new_message
|
||||
if self.registryValue('stripRelayedNick', channel):
|
||||
message = MATCH_MESSAGE_STRIPNICK.match(message).group('message')
|
||||
m.feed(message)
|
||||
tokenized_message = (w.strip(':;,.!?')
|
||||
for w in message.lower().split())
|
||||
if irc.nick.lower() in tokenized_message:
|
||||
if random.random() < self.registryValue('onNick.probability', channel):
|
||||
def replace_nick(s):
|
||||
return re.sub(re.escape(irc.nick), msg.nick, s, re.IGNORECASE)
|
||||
self._answer(irc, message, m, False,
|
||||
postprocessing=replace_nick)
|
||||
else:
|
||||
if random.random() < self.registryValue('probability', channel):
|
||||
self._answer(irc, message, m, False)
|
||||
|
||||
@wrap(['channel', optional('text')])
|
||||
def gen(self, irc, msg, args, channel, message):
|
||||
"""[<channel>] [<seed>]
|
||||
|
||||
Generates a random message based on the logs of a channel
|
||||
and a seed"""
|
||||
if not self.registryValue('enable', channel):
|
||||
irc.error(_('Markovgen is disabled for this channel.'),
|
||||
Raise=True)
|
||||
m = self._get_markov(irc, channel)
|
||||
if message:
|
||||
m.feed(message)
|
||||
self._answer(irc, message or '', m, True)
|
||||
|
||||
|
||||
def _answer(self, irc, message, m, allow_duplicate,
|
||||
postprocessing=lambda x: x):
|
||||
words = message.split()
|
||||
if len(words) == 0:
|
||||
possibilities = list(m.available_seeds())
|
||||
elif len(words) == 1:
|
||||
word = words[0]
|
||||
seeds = list(m.available_seeds())
|
||||
possibilities = [x for x in seeds if word in x]
|
||||
else:
|
||||
message_tuples = set(zip(words, words[1:]))
|
||||
if not message_tuples:
|
||||
return
|
||||
seeds = list(m.available_seeds())
|
||||
possibilities = [x for x in seeds if x in message_tuples]
|
||||
seed = list(random.choice(possibilities))
|
||||
backward_seed = list(reversed(seed))
|
||||
forward = m.generate_markov_text(seed=seed, backward=False)
|
||||
backward = m.generate_markov_text(seed=backward_seed,
|
||||
backward=True)
|
||||
try:
|
||||
answer = '%s %s' % (backward, forward.split(' ', 2)[2])
|
||||
except IndexError:
|
||||
answer = backward
|
||||
if allow_duplicate or message != answer:
|
||||
irc.reply(postprocessing(answer), prefixNick=False)
|
||||
|
||||
@wrap(['channel'])
|
||||
def doge(self, irc, msg, args, channel):
|
||||
"""takes no arguments
|
||||
|
||||
Generates a doge."""
|
||||
if not self.registryValue('enable', channel):
|
||||
irc.error(_('Markovgen is disabled for this channel.'),
|
||||
Raise=True)
|
||||
r = re.compile('^[a-zA-Zéèàù]{5,}$')
|
||||
def pred(x):
|
||||
if not r.match(x):
|
||||
return None
|
||||
else:
|
||||
return x
|
||||
m = self._get_markov(irc, channel)
|
||||
words = m.words
|
||||
words = filter(bool, map(pred, words))
|
||||
words = [x.strip(',?;.:/!') for x in m.words if pred(x)]
|
||||
w2 = random.choice(words)
|
||||
w1 = random.choice(['such', 'many', 'very'])
|
||||
irc.reply('%s %s' % (w1, w2))
|
||||
|
||||
|
||||
Class = Markovgen
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
@ -1 +0,0 @@
|
||||
markovgen
|
@ -40,20 +40,24 @@ import supybot.world as world
|
||||
__version__ = "2020.02.24+git"
|
||||
|
||||
# XXX Replace this with an appropriate author or supybot.Author instance.
|
||||
__author__ = supybot.Author('butterscotchstallion', 'butterscotchstallion', '')
|
||||
__maintainer__ = getattr(supybot.authors, 'oddluck',
|
||||
supybot.Author('oddluck', 'oddluck', 'oddluck@riseup.net'))
|
||||
__author__ = supybot.Author("butterscotchstallion", "butterscotchstallion", "")
|
||||
__maintainer__ = getattr(
|
||||
supybot.authors,
|
||||
"oddluck",
|
||||
supybot.Author("oddluck", "oddluck", "oddluck@riseup.net"),
|
||||
)
|
||||
|
||||
# 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__ = 'https://github.com/oddluck/limnoria-plugins/'
|
||||
__url__ = "https://github.com/oddluck/limnoria-plugins/"
|
||||
|
||||
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
|
||||
|
@ -30,9 +30,11 @@
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
_ = PluginInternationalization('SpiffyTitles')
|
||||
|
||||
_ = PluginInternationalization("SpiffyTitles")
|
||||
except:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
@ -45,269 +47,601 @@ def configure(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)
|
||||
|
||||
conf.registerPlugin("SpiffyTitles", True)
|
||||
|
||||
|
||||
SpiffyTitles = conf.registerPlugin('SpiffyTitles')
|
||||
SpiffyTitles = conf.registerPlugin("SpiffyTitles")
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles, 'maxRetries',
|
||||
registry.Integer(3, _("""Maximum retries upon failure""")))
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles,
|
||||
"maxRetries",
|
||||
registry.Integer(3, _("""Maximum retries upon failure""")),
|
||||
)
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles, 'wallClockTimeoutInSeconds',
|
||||
registry.Integer(8, _("""Timeout for getting a title. If you set this too high, the bot will time out.""")))
|
||||
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""")))
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles, "language", registry.String("en-US", _("""Language code"""))
|
||||
)
|
||||
|
||||
# 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""")))
|
||||
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""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles, "useBold", registry.Boolean(False, _("""Use bold in titles"""))
|
||||
)
|
||||
|
||||
# User agents
|
||||
conf.registerGlobalValue(SpiffyTitles, 'userAgents',
|
||||
registry.CommaSeparatedListOfStrings(["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0"], _("""Reported user agent when fetching links""")))
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles,
|
||||
"userAgents",
|
||||
registry.CommaSeparatedListOfStrings(
|
||||
[
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/79.0.3945.130 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) "
|
||||
"Gecko/20100101 Firefox/73.0",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/80.0.3987.122 Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) "
|
||||
"Gecko/20100101 Firefox/74.0",
|
||||
],
|
||||
_("""Reported user agent when fetching links"""),
|
||||
),
|
||||
)
|
||||
|
||||
# Bad link text
|
||||
conf.registerChannelValue(SpiffyTitles, 'badLinkText',
|
||||
registry.String("Nice link idiot.", _("""Title to return for bad/unsnarfable links.""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles,
|
||||
"badLinkText",
|
||||
registry.String(
|
||||
"Error retrieving title. Check the log for more details.",
|
||||
_("""Title to return for bad/unsnarfable links."""),
|
||||
),
|
||||
)
|
||||
|
||||
# Mime types
|
||||
conf.registerGlobalValue(SpiffyTitles, 'mimeTypes',
|
||||
registry.CommaSeparatedListOfStrings(["text/html"], _("""Acceptable mime types for displaying titles""")))
|
||||
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""")))
|
||||
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""")))
|
||||
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""")))
|
||||
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""")))
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles,
|
||||
"channelBlacklist",
|
||||
registry.CommaSeparatedListOfStrings(
|
||||
[], _("""Never show titles on these channels""")
|
||||
),
|
||||
)
|
||||
|
||||
# Link cache lifetime
|
||||
conf.registerGlobalValue(SpiffyTitles, 'linkCacheLifetimeInSeconds',
|
||||
registry.Integer(60, _("""Link cache lifetime in seconds""")))
|
||||
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.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.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,
|
||||
"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,
|
||||
"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.registerChannelValue(
|
||||
SpiffyTitles,
|
||||
"ignoredTitlePattern",
|
||||
registry.Regexp("", _("""Titles matching this pattern will be ignored.""")),
|
||||
)
|
||||
|
||||
|
||||
# default configs
|
||||
conf.registerGroup(SpiffyTitles, "default")
|
||||
|
||||
#default configs
|
||||
conf.registerGroup(SpiffyTitles, 'default')
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.default, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about regular links""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.default,
|
||||
"enabled",
|
||||
registry.Boolean(
|
||||
True, _("""Whether to add additional information about regular links""")
|
||||
),
|
||||
)
|
||||
|
||||
# default title template - show a warning if redirects to a different domain
|
||||
conf.registerChannelValue(SpiffyTitles.default, 'template',
|
||||
registry.String("{% if redirect %}(REDIRECT) {% endif %}^ {{title}}", _("""Template used for default title responses""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.default,
|
||||
"template",
|
||||
registry.String(
|
||||
"{% if redirect %}(REDIRECT) {% endif %}^ {{title}}",
|
||||
_("""Template used for default title responses"""),
|
||||
),
|
||||
)
|
||||
# default file template - show a warning if redirects to a different domain
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.default,
|
||||
"fileTemplate",
|
||||
registry.String(
|
||||
"{% if type %}[{{type}}] {% endif %}"
|
||||
"{% if size %}({{size}}){% endif %}",
|
||||
_("""Template used for default title responses"""),
|
||||
),
|
||||
)
|
||||
|
||||
# Wikipedia configs
|
||||
conf.registerGroup(SpiffyTitles, "wikipedia")
|
||||
|
||||
# wikipedia enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.wikipedia,
|
||||
"enabled",
|
||||
registry.Boolean(True, _("""Whether to fetch extracts for Wikipedia articles.""")),
|
||||
)
|
||||
|
||||
#Wikipedia configs
|
||||
conf.registerGroup(SpiffyTitles, 'wikipedia')
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.wikipedia,
|
||||
"apiParams",
|
||||
registry.SpaceSeparatedListOfStrings(
|
||||
[],
|
||||
_(
|
||||
"""
|
||||
Add/override API parameters with a space-separated list of key=value pairs.
|
||||
"""
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
#wikipedia enabler
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to fetch extracts for Wikipedia articles.""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.wikipedia,
|
||||
"titleParam",
|
||||
registry.String(
|
||||
"titles",
|
||||
_("""The query parameter that will hold the page title from the URL."""),
|
||||
),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'apiParams',
|
||||
registry.SpaceSeparatedListOfStrings([], _("""Add or override API query parameters with a space-separated list of key=value pairs.""")))
|
||||
# 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, '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(400, _("""Extract will be cut to this length (including '...').""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.wikipedia,
|
||||
"maxChars",
|
||||
registry.Integer(
|
||||
400, _("""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,
|
||||
"removeParentheses",
|
||||
registry.Boolean(True, _("""Remove parenthesized text from output.""")),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.wikipedia, 'extractTemplate',
|
||||
registry.String("^ {{extract}}", _("""Wikipedia template.""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.wikipedia,
|
||||
"extractTemplate",
|
||||
registry.String("^ {{extract}}", _("""Wikipedia template.""")),
|
||||
)
|
||||
|
||||
|
||||
# Reddit configs
|
||||
conf.registerGroup(SpiffyTitles, "reddit")
|
||||
|
||||
#Reddit configs
|
||||
conf.registerGroup(SpiffyTitles, 'reddit')
|
||||
# Reddit enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.reddit,
|
||||
"enabled",
|
||||
registry.Boolean(True, _("""Whether to add additional info about Reddit links.""")),
|
||||
)
|
||||
|
||||
#Reddit enabler
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional info about Reddit links.""")))
|
||||
# Reddit templates
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.reddit,
|
||||
"linkThreadTemplate",
|
||||
registry.String(
|
||||
"/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"""),
|
||||
),
|
||||
)
|
||||
|
||||
#Reddit templates
|
||||
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(
|
||||
"/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, '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(
|
||||
"/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, '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/{{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, '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""")))
|
||||
|
||||
#Reddit max characters
|
||||
conf.registerChannelValue(SpiffyTitles.reddit, 'maxChars',
|
||||
registry.Integer(400, _("""Length of response (title/extract will be cut to fit).""")))
|
||||
# Reddit max characters
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.reddit,
|
||||
"maxChars",
|
||||
registry.Integer(
|
||||
400, _("""Length of response (title/extract will be cut to fit).""")
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# YouTube configs
|
||||
conf.registerGroup(SpiffyTitles, "youtube")
|
||||
|
||||
#YouTube configs
|
||||
conf.registerGroup(SpiffyTitles, 'youtube')
|
||||
|
||||
#youtube enabler
|
||||
conf.registerChannelValue(SpiffyTitles.youtube, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about YouTube videos""")))
|
||||
# youtube enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.youtube,
|
||||
"enabled",
|
||||
registry.Boolean(
|
||||
True, _("""Whether to add additional information about YouTube videos""")
|
||||
),
|
||||
)
|
||||
|
||||
# Youtube API
|
||||
conf.registerGlobalValue(SpiffyTitles.youtube, 'developerKey',
|
||||
registry.String("", _("""Youtube developer key - required for Youtube handler."""), private=True))
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles.youtube,
|
||||
"developerKey",
|
||||
registry.String(
|
||||
"", _("""Youtube developer key - required for Youtube handler."""), private=True
|
||||
),
|
||||
)
|
||||
# YouTube Logo
|
||||
conf.registerChannelValue(SpiffyTitles.youtube, 'logo',
|
||||
registry.String("\x030,4 ► \x031,0YouTube", _("""Logo used with {{yt_logo}} in template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.youtube,
|
||||
"logo",
|
||||
registry.String(
|
||||
"\x030,4 ► \x031,0YouTube", _("""Logo used with {{yt_logo}} in template""")
|
||||
),
|
||||
)
|
||||
# YouTube template
|
||||
conf.registerChannelValue(SpiffyTitles.youtube, 'template',
|
||||
registry.String("^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} :: Duration: {{duration}} :: Views: {{view_count}} :: Uploader: {{channel_title}} :: Uploaded: {{published}} :: {{like_count}} likes :: {{dislike_count}} dislikes :: {{favorite_count}} favorites :: {{comment_count}} comments", _("""Template used for YouTube title responses""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.youtube,
|
||||
"template",
|
||||
registry.String(
|
||||
"^ {{yt_logo}} :: {{title}} {%if timestamp%} @ {{timestamp}}{% endif %} "
|
||||
":: Duration: {{duration}} :: Views: {{view_count}} :: Uploader: "
|
||||
"{{channel_title}} :: Uploaded: {{published}} :: {{like_count}} likes :: "
|
||||
"{{dislike_count}} dislikes :: {{favorite_count}} favorites :: "
|
||||
"{{comment_count}} comments",
|
||||
_("""Template used for YouTube title responses"""),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# imgur configs
|
||||
conf.registerGroup(SpiffyTitles, "imgur")
|
||||
|
||||
#imgur configs
|
||||
conf.registerGroup(SpiffyTitles, 'imgur')
|
||||
|
||||
#imgur enabler
|
||||
conf.registerChannelValue(SpiffyTitles.imgur, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about imgur links""")))
|
||||
# imgur enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.imgur,
|
||||
"enabled",
|
||||
registry.Boolean(
|
||||
True, _("""Whether to add additional information about imgur links""")
|
||||
),
|
||||
)
|
||||
|
||||
# imgur API
|
||||
conf.registerGlobalValue(SpiffyTitles.imgur, 'clientID',
|
||||
registry.String("", _("""imgur client ID"""), private=True))
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles.imgur,
|
||||
"clientID",
|
||||
registry.String("", _("""imgur client ID"""), private=True),
|
||||
)
|
||||
|
||||
conf.registerGlobalValue(SpiffyTitles.imgur, 'clientSecret',
|
||||
registry.String("", _("""imgur client secret"""), private=True))
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles.imgur,
|
||||
"clientSecret",
|
||||
registry.String("", _("""imgur client secret"""), private=True),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.imgur, 'template',
|
||||
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.imgur,
|
||||
"template",
|
||||
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.imgur, 'albumTemplate',
|
||||
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""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.imgur,
|
||||
"albumTemplate",
|
||||
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"""),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# dailymotion configs
|
||||
conf.registerGroup(SpiffyTitles, "dailymotion")
|
||||
|
||||
#dailymotion configs
|
||||
conf.registerGroup(SpiffyTitles, 'dailymotion')
|
||||
|
||||
#dailymotion enabler
|
||||
conf.registerChannelValue(SpiffyTitles.dailymotion, 'enabled',
|
||||
registry.Boolean(True, _("""Enable additional information about dailymotion videos""")))
|
||||
# dailymotion enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.dailymotion,
|
||||
"enabled",
|
||||
registry.Boolean(
|
||||
True, _("""Enable additional information about dailymotion videos""")
|
||||
),
|
||||
)
|
||||
|
||||
# dailymotion template
|
||||
conf.registerChannelValue(SpiffyTitles.dailymotion, 'template',
|
||||
registry.String("^ [{{ownerscreenname}}] {{title}} :: Duration: {{duration}} :: {{views_total}} views", _("""Template used for Vimeo title responses""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.dailymotion,
|
||||
"template",
|
||||
registry.String(
|
||||
"^ [{{ownerscreenname}}] {{title}} :: Duration: {{duration}} :: "
|
||||
"{{views_total}} views",
|
||||
_("""Template used for Vimeo title responses"""),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# Twitch configs
|
||||
conf.registerGroup(SpiffyTitles, "twitch")
|
||||
|
||||
#Twitch configs
|
||||
conf.registerGroup(SpiffyTitles, 'twitch')
|
||||
# twitch enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.twitch,
|
||||
"enabled",
|
||||
registry.Boolean(
|
||||
True, _("""Whether to add additional information about Twitch links""")
|
||||
),
|
||||
)
|
||||
|
||||
#twitch enabler
|
||||
conf.registerChannelValue(SpiffyTitles.twitch, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about Twitch links""")))
|
||||
|
||||
#Twitch API Key
|
||||
conf.registerGlobalValue(SpiffyTitles.twitch, 'clientID',
|
||||
registry.String('', _("""Twitch API Client_ID""")))
|
||||
# Twitch API Key
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles.twitch, "clientID", registry.String("", _("""Twitch API Client_ID"""))
|
||||
)
|
||||
|
||||
# Twitch Logo
|
||||
conf.registerChannelValue(SpiffyTitles.twitch, 'logo',
|
||||
registry.String("\x030,6💬twitch", _("""Logo used with {{twitch_logo}} in template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.twitch,
|
||||
"logo",
|
||||
registry.String(
|
||||
"\x030,6💬twitch", _("""Logo used with {{twitch_logo}} in template""")
|
||||
),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.twitch, 'channelTemplate',
|
||||
registry.String("^ {{twitch_logo}} :: {{display_name}} {%if description%}:: {{description}} {%endif%}:: Viewers: {{view_count}}", _("""twitch.tv channel template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.twitch,
|
||||
"channelTemplate",
|
||||
registry.String(
|
||||
"^ {{twitch_logo}} :: {{display_name}} {%if description%}:: "
|
||||
"{{description}} {%endif%}:: Viewers: {{view_count}}",
|
||||
_("""twitch.tv channel template"""),
|
||||
),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.twitch, 'streamTemplate',
|
||||
registry.String("^ {{twitch_logo}} :: {{display_name}} :: (LIVE) {%if game_name%}[{{game_name}}] {%endif%}{%if title%}:: {{title}} {%endif%}:: Created: {{created_at}} :: Viewers: {{view_count}} {%if description%}:: {{description}}{%endif%}", _("""twitch.tv stream template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.twitch,
|
||||
"streamTemplate",
|
||||
registry.String(
|
||||
"^ {{twitch_logo}} :: {{display_name}} :: (LIVE) "
|
||||
"{%if game_name%}[{{game_name}}] {%endif%}{%if title%}:: {{title}} "
|
||||
"{%endif%}:: Created: {{created_at}} :: Viewers: {{view_count}} "
|
||||
"{%if description%}:: {{description}}{%endif%}",
|
||||
_("""twitch.tv stream template"""),
|
||||
),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.twitch, 'videoTemplate',
|
||||
registry.String("^ {{twitch_logo}} :: {{display_name}} {%if title%}:: {{title}} {%endif%}}:: Duration: {{duration}} :: Created: {{created_at}} {%if description%}:: {{description}} {%endif%}:: Viewers: {{view_count}}", _("""twitch.tv video template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.twitch,
|
||||
"videoTemplate",
|
||||
registry.String(
|
||||
"^ {{twitch_logo}} :: {{display_name}} {%if title%}:: {{title}} {%endif%}}:: "
|
||||
"Duration: {{duration}} :: Created: {{created_at}} {%if description%}:: "
|
||||
"{{description}} {%endif%}:: Viewers: {{view_count}}",
|
||||
_("""twitch.tv video template"""),
|
||||
),
|
||||
)
|
||||
|
||||
conf.registerChannelValue(SpiffyTitles.twitch, 'clipTemplate',
|
||||
registry.String("^ {{twitch_logo}} :: {{display_name}} {%if game_name%}:: [{{game_name}}] {%endif%}{%if title%}:: {{title}} {%endif%}:: Created: {{created_at}} :: Viewers: {{view_count}} {%if description%}:: {{description}}{%endif%}", _("""twitch.tv clip template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.twitch,
|
||||
"clipTemplate",
|
||||
registry.String(
|
||||
"^ {{twitch_logo}} :: {{display_name}} {%if game_name%}:: [{{game_name}}] "
|
||||
"{%endif%}{%if title%}:: {{title}} {%endif%}:: Created: {{created_at}} :: "
|
||||
"Viewers: {{view_count}} {%if description%}:: {{description}}{%endif%}",
|
||||
_("""twitch.tv clip template"""),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# vimeo configs
|
||||
conf.registerGroup(SpiffyTitles, "vimeo")
|
||||
|
||||
#vimeo configs
|
||||
conf.registerGroup(SpiffyTitles, 'vimeo')
|
||||
|
||||
#vimeo enabler
|
||||
conf.registerChannelValue(SpiffyTitles.vimeo, 'enabled',
|
||||
registry.Boolean(True, _("""Enable additional information about Vimeo videos""")))
|
||||
# vimeo enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.vimeo,
|
||||
"enabled",
|
||||
registry.Boolean(True, _("""Enable additional information about Vimeo videos""")),
|
||||
)
|
||||
|
||||
# Vimeo template
|
||||
conf.registerChannelValue(SpiffyTitles.vimeo, 'template',
|
||||
registry.String("^ {{title}} :: Duration: {{duration}} :: {{stats_number_of_plays}} plays :: {{stats_number_of_comments}} comments", _("""Template used for Vimeo title responses""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.vimeo,
|
||||
"template",
|
||||
registry.String(
|
||||
"^ {{title}} :: Duration: {{duration}} :: {{stats_number_of_plays}} plays "
|
||||
":: {{stats_number_of_comments}} comments",
|
||||
_("""Template used for Vimeo title responses"""),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# IMDB configs
|
||||
conf.registerGroup(SpiffyTitles, "imdb")
|
||||
|
||||
#IMDB configs
|
||||
conf.registerGroup(SpiffyTitles, 'imdb')
|
||||
# imdb enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.imdb,
|
||||
"enabled",
|
||||
registry.Boolean(
|
||||
True, _("""Whether to add additional information about IMDB links""")
|
||||
),
|
||||
)
|
||||
|
||||
#imdb enabler
|
||||
conf.registerChannelValue(SpiffyTitles.imdb, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about IMDB links""")))
|
||||
|
||||
#OMDB API Key
|
||||
conf.registerGlobalValue(SpiffyTitles.imdb, 'omdbAPI',
|
||||
registry.String('', _("""OMDB API Key""")))
|
||||
# OMDB API Key
|
||||
conf.registerGlobalValue(
|
||||
SpiffyTitles.imdb, "omdbAPI", registry.String("", _("""OMDB API Key"""))
|
||||
)
|
||||
|
||||
# IMDB Logo
|
||||
conf.registerChannelValue(SpiffyTitles.imdb, 'logo',
|
||||
registry.String("\x031,8 IMDb ", _("""Logo used with {{imdb_logo}} in template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.imdb,
|
||||
"logo",
|
||||
registry.String("\x031,8 IMDb ", _("""Logo used with {{imdb_logo}} in template""")),
|
||||
)
|
||||
|
||||
# IMDB template
|
||||
conf.registerChannelValue(SpiffyTitles.imdb, 'template',
|
||||
registry.String("^ {{imdb_logo}} :: {{title}} ({{year}}, {{country}}, [{{rated}}], {{genre}}, {{runtime}}) :: IMDb: {{imdb_rating}} | MC: {{metascore}} | RT: {{tomatoMeter}} :: {{plot}} :: Director: {{director}} :: Cast: {{actors}} :: Writer: {{writer}}", _("""IMDB title template""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.imdb,
|
||||
"template",
|
||||
registry.String(
|
||||
"^ {{imdb_logo}} :: {{title}} ({{year}}, {{country}}, [{{rated}}], {{genre}}, "
|
||||
"{{runtime}}) :: IMDb: {{imdb_rating}} | MC: {{metascore}} | RT: "
|
||||
"{{tomatoMeter}} :: {{plot}} :: Director: {{director}} :: Cast: {{actors}} "
|
||||
":: Writer: {{writer}}",
|
||||
_("""IMDB title template"""),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# coub configs
|
||||
conf.registerGroup(SpiffyTitles, "coub")
|
||||
|
||||
#coub configs
|
||||
conf.registerGroup(SpiffyTitles, 'coub')
|
||||
|
||||
#coub enabler
|
||||
conf.registerChannelValue(SpiffyTitles.coub, 'enabled',
|
||||
registry.Boolean(True, _("""Whether to add additional information about coub links""")))
|
||||
# coub enabler
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.coub,
|
||||
"enabled",
|
||||
registry.Boolean(
|
||||
True, _("""Whether to add additional information about coub links""")
|
||||
),
|
||||
)
|
||||
|
||||
# coub template
|
||||
conf.registerChannelValue(SpiffyTitles.coub, 'template',
|
||||
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""")))
|
||||
conf.registerChannelValue(
|
||||
SpiffyTitles.coub,
|
||||
"template",
|
||||
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"""),
|
||||
),
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,5 @@
|
||||
html5lib
|
||||
lxml
|
||||
requests
|
||||
beautifulsoup4
|
||||
jinja2
|
||||
imgurpython
|
||||
requests
|
||||
timeout-decorator
|
||||
certifi
|
||||
pendulum
|
||||
imgurpython
|
Loading…
x
Reference in New Issue
Block a user