Drop files from .gitignore

This commit is contained in:
codey 2024-10-25 08:24:06 -04:00
parent d9343bc909
commit 0b42bd4e05
13 changed files with 0 additions and 708 deletions

View File

@ -1,6 +0,0 @@
Implements an **`fml`** command, displaying entries from [fmylife.com](https://www.fmylife.com/).
Fixed ("forked"), from https://github.com/jlu5/SupyPlugins originally - author had removed the plugin from the repo as it no longer functioned due to site changes.
Revised code functions, however only queries random FML entries and does not allow for a specific FML ID to be queried. I don't believe querying a specific ID is very useful/worth re-implementing. Additionally, FML article links are not provided, as the link structure has changed and correcting that also seems to add no value, as the entire article contents are returned by the plugin.

View File

@ -1,68 +0,0 @@
###
# Copyright (c) 2014-2015, James Lu
# 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.
###
"""
FML: Displays entries from fmylife.com.
"""
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__ = "2021.08.01"
__author__ = getattr(supybot.authors, 'jlu',
supybot.Author('James Lu', 'jlu5', 'james@overdrivenetworks.com'))
# 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/jlu5/SupyPlugins/'
from . import config
from . import plugin
from importlib 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:

View File

@ -1,55 +0,0 @@
###
# Copyright (c) 2014-2015, James Lu
# 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('FML')
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('FML', True)
FML = conf.registerPlugin('FML')
conf.registerChannelValue(FML, 'showInfo',
registry.Boolean(True, _("""Determines whether the bot should show more info (ID, category, and URL) in FML posts.""")))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -1 +0,0 @@
# Stub so local is a module, used for third-party modules

View File

@ -1,127 +0,0 @@
###
# Copyright (c) 2014-2018, James Lu <james@overdrivenetworks.com>
# 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 collections
import re
from supybot import utils, plugins, ircutils, callbacks, log
from supybot.commands import *
try:
from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('FML')
except ImportError:
# Placeholder that allows to run the plugin on a bot
# without the i18n module
_ = lambda x: x
from bs4 import BeautifulSoup
class FML(callbacks.Plugin):
"""Displays entries from fmylife.com."""
threaded = True
URL_RANDOM = 'https://www.fmylife.com/random'
cached_results = collections.deque()
@staticmethod
def _parse_panel(panel, fml_id=None):
"""Parses a FML entry panel for data. Returns a (fml_id, text, num_upvotes, num_downvotes) tuple."""
if panel:
content = panel
# log.info(f"FML: parent found: {parent}")
log.debug("FML: parsing panel %s", panel)
log.debug("FML: parsing content %s", content)
if not content:
return
text = content.text.strip()
if not text.endswith(' FML'): # Ignore ads, promos, previews
log.info.debug(f"FML: Text did not end with \sFML: {text}")
return (0, 'Got something that didn\'t look like an FML :(', 0, 0)
# If not given, extract the FML ID from the link
if fml_id is None and content.name == 'a':
link = content['href']
fml_id = link.rsplit('_', 1)[-1].split('.', 1)[0]
vote_counts = panel.parent.find_all('span', attrs={'class': 'vote-btn-count'})
votes = {
'yls': re.sub(r'\s', ',', vote_counts[0].text.strip()),
'ydi': re.sub(r'\s', ',', vote_counts[1].text.strip()),
}
upvotes = votes.get('yls', 0)
downvotes = votes.get('ydi', 0)
data = (fml_id, text, upvotes, downvotes)
return data
def _get_random_entries(self):
"""Fetches and caches random FML entries. Returns the amount of entries retrieved."""
html = utils.web.getUrl(self.URL_RANDOM)
soup = BeautifulSoup(html)
results_count = 0
for panel in soup.select('article > a'):
data = self._parse_panel(panel)
if data:
self.log.info('FML: got entry: %s', str(data))
self.cached_results.append(data)
results_count += 1
self.log.info('FML: got total of %s results, cache size: %s', results_count,
len(self.cached_results))
return results_count
def fml(self, irc, msg, args):
"""
Displays a random entry from fmylife.com."""
if not len(self.cached_results):
if not self._get_random_entries():
irc.error("Could not fetch new FML entries - try again later.", Raise=True)
data = self.cached_results.popleft()
if not data:
irc.error(_("Entry not found or error processing data."), Raise=True)
fml_id, text, num_upvotes, num_downvotes = data
votes = ircutils.bold("[Agreed: %s / Deserved: %s]" % (num_upvotes, num_downvotes))
if self.registryValue("showInfo", msg.args[0]):
s = format('\x02#%i\x02: %s - %s', fml_id, text, votes)
else:
s = format('%s - %s', text, votes)
irc.reply(s)
fml = wrap(fml)
Class = FML
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -1,44 +0,0 @@
###
# Copyright (c) 2014-2018, James Lu <james@overdrivenetworks.com>
# 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.
###
from supybot.test import *
class FMLTestCase(PluginTestCase):
plugins = ('FML',)
@unittest.skipUnless(network, "Network-based tests have been disabled via "
"--no-network")
def testFML(self):
self.assertNotError('fml')
self.assertNotError('fml 165130')
self.assertError('fml 1') # This one doesn't exist
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -1 +0,0 @@
Song Lyrics Search

View File

@ -1,68 +0,0 @@
###
# Copyright (c) 2024, codey
# 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.
###
"""
Lyrics: Song Lyrics Search
"""
import sys
import supybot
from supybot import world
# Use this for the version of this plugin.
__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 importlib 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:

View File

@ -1,94 +0,0 @@
###
# Copyright (c) 2024, codey
# 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.
###
from supybot import conf, registry
try:
from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('Lyrics')
except:
_ = lambda x: x
def configure(advanced):
from supybot.questions import expect, anything, something, yn
conf.registerPlugin('Lyrics', True)
Lyrics = conf.registerPlugin('Lyrics')
conf.registerChannelValue(Lyrics,
"enable",
registry.Boolean(
True, _("""Should Lyrics respond in this channel?""")
))
conf.registerChannelValue(Lyrics,
"truncate",
registry.Boolean(
True, _("""Should Lyrics responses be truncated in this channel?""")
))
conf.registerChannelValue(Lyrics,
"lines",
registry.Integer(
1, _("""If truncate is set to true, how many lines should be sent (initially)?""")
))
conf.registerChannelValue(Lyrics,
"mores",
registry.Boolean(
True, _("""If truncate is set to true, should mores be used to allow responses to be continued?""")
))
conf.registerChannelValue(Lyrics,
"quiet",
registry.Boolean(
False, _("""If quiet is set True, Searching... and Found: output will be entirely suppressed.""")
))
conf.registerChannelValue(Lyrics,
"verbose",
registry.Boolean(
False, _("""Send Searching... and Found: output to command context instead of privately via notice. Has no impact if quiet is set to True.""")
))
conf.registerGlobalValue(Lyrics,
"floodexempt",
registry.Boolean(
False, _("""If set, the bot will not delay messages sent when truncation is set to False. This usually requires the bot to have a special connect/oper class, to prevent SendQ/RecvQ quits.""")
))
conf.registerGlobalValue(Lyrics, "host", registry.String(
"https://api.codey.lol/lyric_search/", _("""API Host for Lyric Search"""), private=True,
))

View File

@ -1 +0,0 @@
# Stub so local is a module, used for third-party modules

View File

@ -1,170 +0,0 @@
###
# Copyright (c) 2024, codey
# 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 textwrap
import time
import re
import requests
from supybot import utils, plugins, ircutils, callbacks, conf, ircdb
from supybot.commands import *
from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring
_ = PluginInternationalization('Lyrics')
class SearchException(Exception):
pass
class Lyrics(callbacks.Plugin):
"""Song Lyrics Search"""
threaded = True
@wrap(['text'])
def sing(self, irc, msg, args, query):
"""<query>
Sing <artist> : <song>
"""
"""Check if Lyrics Search is enabled in this context/channel"""
if not(self.registryValue('enable', network=irc.network, channel=msg.channel)):
return irc.noReply()
"""Check for botwide ignores"""
if ircdb.checkIgnored(msg.prefix, msg.args[0]):
return irc.noReply()
use_mores = self.registryValue('mores', network=irc.network, channel=msg.channel)
truncate = self.registryValue('truncate', network=irc.network, channel=msg.channel)
lines_to_send = self.registryValue('lines', network=irc.network, channel=msg.channel)
quiet = self.registryValue('quiet', network=irc.network, channel=msg.channel)
verbose = self.registryValue('verbose', network=irc.network, channel=msg.channel)
can_flood = self.registryValue('floodexempt')
subsearch = None
trailer = " [...]"
query = "".join(query.strip())
colons = len(re.findall(r':', query))
dashes = len(re.findall(r'\s-\s', query))
has_subsearch = (colons > 1)
"""Check for valid query ( must contain : or - )"""
if not(colons) and not(dashes):
irc.reply("\002\00304Invalid query! " \
"Query format should be either <artist> : <song>, <artist> - <song>, or optionally " \
"<artist> : <song> : <subsearch>", prefixNick=False)
return
if colons:
artist = query.split(":")[0].strip()
song = query.split(":")[1].strip()
else:
artist = query.split(" - ", maxsplit=1)[0].strip()
song = query.split(" - ", maxsplit=1)[1].strip()
searchObj = {
'a': artist,
's': song,
'src': 'IRC-SHARED',
'extras': True
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0',
'Content-Type': 'application/json; charset=utf-8'
}
if has_subsearch:
subsearch = query.split(":")[2].strip()
searchObj['sub'] = subsearch
try:
if not(quiet):
irc.reply("\002\00307Searching...",
private=not(verbose), notice=not(verbose), prefixNick=False)
request = requests.post(self.registryValue('host'),
json=searchObj,
timeout=(10, 20), verify=False, headers=headers)
request.raise_for_status()
response = request.json()
if response.get('err'):
raise SearchException(response.get('errorText'))
returned_artist = response.get('artist')
returned_song = response.get('song')
if not(quiet):
irc.reply("\002\00309Found: %s - %s"
% (returned_artist, returned_song),
notice=not(verbose), private=not(verbose),
prefixNick=False)
lyrics = response.get('lyrics')
lyrics = re.sub(r'<br>', ' / ', lyrics)
if truncate and use_mores:
irc.reply(lyrics, prefixNick=False)
return
wrapped_lyrics = textwrap.wrap(text=lyrics,
width=360,
break_on_hyphens=True,
break_long_words=True)
if not(truncate):
lines_to_send = len(wrapped_lyrics)
for idx, line in enumerate(wrapped_lyrics):
line = re.sub(r'/(\s{0,})$', '', line).strip()
if idx >= lines_to_send:
break
truncated = (idx+1 == lines_to_send and truncate)
irc.reply(line.strip() + (trailer if truncated else ''), prefixNick=False)
if idx >= 5 and not(can_flood):
time.sleep(0.5) # Avoid RecvQ by sleeping for 0.5s starting with the 5th line of output
return
except Exception as e:
irc.reply(f"\002\00304Error: {str(e)}", prefixNick=False)
return
Class = Lyrics

View File

@ -1,35 +0,0 @@
###
# Copyright (c) 2024, codey
# 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.
###
from supybot.setup import plugin_setup
plugin_setup(
'Lyrics',
)

View File

@ -1,38 +0,0 @@
###
# Copyright (c) 2024, codey
# 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.
###
from supybot.test import *
class LyricsTestCase(PluginTestCase):
plugins = ('Lyrics',)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: