Initial commit.

This commit is contained in:
oddluck 2019-12-05 09:49:10 +00:00
parent 69b956580d
commit 8c6240fdb2
8 changed files with 29 additions and 21 deletions

View File

@ -1,4 +1,4 @@
# NBA # NBAScores
A [Limnoria](https://github.com/ProgVal/Limnoria) plugin to retrieve NBA scores from NBA.com. A [Limnoria](https://github.com/ProgVal/Limnoria) plugin to retrieve NBA scores from NBA.com.

View File

@ -29,7 +29,7 @@
### ###
""" """
NBA: Get scores from NBA.com NBAScores: Get scores from NBA.com
""" """
import supybot import supybot
@ -37,17 +37,25 @@ import supybot.world as world
# Use this for the version of this plugin. You may wish to put a CVS keyword # 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. # in here if you're keeping the plugin in CVS or some similar system.
__version__ = "0.1" __version__ = ""
# XXX Replace this with an appropriate author or supybot.Author instance. # XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.authors.unknown __author__ = supybot.Author('Santiago Gil', 'santigl', '')
__maintainer__ = getattr(supybot.authors, 'oddluck',
supybot.Author('oddluck', 'oddluck', 'oddluck@riseup.net'))
# This is a dictionary mapping supybot.Author instances to lists of # This is a dictionary mapping supybot.Author instances to lists of
# contributions. # contributions.
__contributors__ = {} if not hasattr(supybot.authors, 'cottongin') or not hasattr(supybot.authors, 'santigl'):
supybot.authors.cottongin = supybot.Author('cottongin', 'cottongin',
'cottongin@cottongin.club')
supybot.authors.santigl = supybot.Author('Santiago Gil', 'santigl', '')
__contributors__ = {supybot.authors.santigl: ['original plugin base'],
supybot.authors.cottongin: ['code enhancement']}
# This is a url where the most recent plugin package can be downloaded. # This is a url where the most recent plugin package can be downloaded.
__url__ = 'https://github.com/santigl/limnoria-nba' __url__ = 'https://github.com/oddluck/limnoria-plugins/'
from . import config from . import config
from . import plugin from . import plugin

View File

@ -32,7 +32,7 @@ import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('NBA') _ = PluginInternationalization('NBAScores')
except: except:
# Placeholder that allows to run the plugin on a bot # Placeholder that allows to run the plugin on a bot
# without the i18n module # without the i18n module
@ -45,10 +45,10 @@ def configure(advanced):
# user or not. You should effect your configuration by manipulating the # user or not. You should effect your configuration by manipulating the
# registry as appropriate. # registry as appropriate.
from supybot.questions import expect, anything, something, yn from supybot.questions import expect, anything, something, yn
conf.registerPlugin('NBA', True) conf.registerPlugin('NBAScores', True)
NBA = conf.registerPlugin('NBA') NBA = conf.registerPlugin('NBAScores')
# This is where your configuration variables (if any) should go. For example: # This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(NBA, 'someConfigVariableName', # conf.registerGlobalValue(NBA, 'someConfigVariableName',
# registry.Boolean(False, _("""Help for someConfigVariableName."""))) # registry.Boolean(False, _("""Help for someConfigVariableName.""")))

View File

@ -27,7 +27,7 @@ import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('NBA') _ = PluginInternationalization('NBAScores')
except ImportError: except ImportError:
# Placeholder that allows to run the plugin on a bot # Placeholder that allows to run the plugin on a bot
# without the i18n module # without the i18n module
@ -40,7 +40,7 @@ import json
import pytz import pytz
from xml.etree import ElementTree from xml.etree import ElementTree
class NBA(callbacks.Plugin): class NBAScores(callbacks.Plugin):
"""Get scores from NBA.com.""" """Get scores from NBA.com."""
_ENDPOINT_BASE_URL = 'https://data.nba.net' _ENDPOINT_BASE_URL = 'https://data.nba.net'
@ -63,7 +63,7 @@ class NBA(callbacks.Plugin):
'BKN', 'POR', 'GSW', 'LAC', 'WAS')) 'BKN', 'POR', 'GSW', 'LAC', 'WAS'))
def __init__(self, irc): def __init__(self, irc):
self.__parent = super(NBA, self) self.__parent = super(NBAScores, self)
self.__parent.__init__(irc) self.__parent.__init__(irc)
self._http = httplib2.Http('.cache') self._http = httplib2.Http('.cache')
@ -131,7 +131,7 @@ class NBA(callbacks.Plugin):
nba = wrap(nba, [optional('somethingWithoutSpaces'), nba = wrap(nba, [optional('somethingWithoutSpaces'),
optional('somethingWithoutSpaces')]) optional('somethingWithoutSpaces')])
def tv(self, irc, msg, args, team): def nbatv(self, irc, msg, args, team):
"""[<TTT>] """[<TTT>]
Given a team, if there is a game scheduled for today, Given a team, if there is a game scheduled for today,
@ -154,9 +154,9 @@ class NBA(callbacks.Plugin):
broadcasters_string = self._broadcastersToString(game['tv_broadcasters']) broadcasters_string = self._broadcastersToString(game['tv_broadcasters'])
irc.reply('{} on: {}'.format(game_string, broadcasters_string)) irc.reply('{} on: {}'.format(game_string, broadcasters_string))
tv = wrap(tv, ['somethingWithoutSpaces']) nbatv = wrap(nbatv, ['somethingWithoutSpaces'])
def next(self, irc, msg, args, n, team, team2): def nbanext(self, irc, msg, args, n, team, team2):
"""[<n>] <TTT> [<TTT>] """[<n>] <TTT> [<TTT>]
Get the next <n> games (1 by default; max. 10) for a given team Get the next <n> games (1 by default; max. 10) for a given team
@ -205,11 +205,11 @@ class NBA(callbacks.Plugin):
irc.reply(self._upcomingGameToString(game)) irc.reply(self._upcomingGameToString(game))
next = wrap(next, [optional('positiveInt'), nbanext = wrap(nbanext, [optional('positiveInt'),
'somethingWithoutSpaces', 'somethingWithoutSpaces',
optional('somethingWithoutSpaces')]) optional('somethingWithoutSpaces')])
def last(self, irc, msg, args, n, team, team2): def nbalast(self, irc, msg, args, n, team, team2):
"""[<n>] <TTT> [<TTT>] """[<n>] <TTT> [<TTT>]
Get the last <n> games (1 by default; max. 10) for a given team Get the last <n> games (1 by default; max. 10) for a given team
@ -259,7 +259,7 @@ class NBA(callbacks.Plugin):
irc.reply(self._pastGameToString(game)) irc.reply(self._pastGameToString(game))
last = wrap(last, [optional('positiveInt'), nbalast = wrap(nbalast, [optional('positiveInt'),
'somethingWithoutSpaces', 'somethingWithoutSpaces',
optional('somethingWithoutSpaces')]) optional('somethingWithoutSpaces')])
@ -814,6 +814,6 @@ class NBA(callbacks.Plugin):
return url return url
Class = NBA Class = NBAScores
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -0,0 +1 @@
pytz

View File

@ -32,7 +32,7 @@ from supybot.test import *
class NBATestCase(PluginTestCase): class NBATestCase(PluginTestCase):
plugins = ('NBA',) plugins = ('NBAScores',)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # 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