Skip to content

Commit 8cdee3c

Browse files
authored
Merge pull request CloudBotIRC#106 from linuxdaemon/gonzobot+sports-fix
Fix issues in sportscores.py with command name not matching game name
2 parents 0dfaa2e + 852f77d commit 8cdee3c

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

plugins/sportscores.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
search_pages = defaultdict(dict)
99

1010

11+
class Game:
12+
__slots__ = ("cmds", "name")
13+
14+
def __init__(self, *cmds, name=None):
15+
self.cmds = cmds
16+
if name is None:
17+
name = cmds[0]
18+
19+
self.name = name
20+
21+
22+
GAMES = (
23+
Game("nfl"),
24+
Game("mlb"),
25+
Game("nba"),
26+
Game("ncb", "ncaab"),
27+
Game("ncf", "ncaaf"),
28+
Game("nhl"),
29+
Game("wnba"),
30+
)
31+
32+
1133
@hook.command("morescore", autohelp=False)
1234
def morescore(text, chan, conn):
1335
"""[pagenum] - if a score list has lots of results the results are pagintated. If the most recent search is paginated the pages are stored for retreival. If no argument is given the next page will be returned else a page number can be specified."""
@@ -65,17 +87,17 @@ def scrape_scores(conn, chan, game, text):
6587

6688
def score_hook(game):
6789
def func(conn, chan, text):
68-
return scrape_scores(conn, chan, game, text)
90+
return scrape_scores(conn, chan, game.name, text)
6991

70-
func.__name__ = "{}_scores".format(game)
92+
func.__name__ = "{}_scores".format(game.name)
7193
func.__doc__ = "[team city] - gets the score or next scheduled game for the specified team. If no team is specified all games will be included."
7294
return func
7395

7496

7597
def init_hooks():
76-
for game in ("nfl", "mlb", "nba", "ncaab", "ncaaf", "nhl", "wnba"):
98+
for game in GAMES:
7799
func = score_hook(game)
78-
globals()[func.__name__] = hook.command(game, autohelp=False)(func)
100+
globals()[func.__name__] = hook.command(*game.cmds, autohelp=False)(func)
79101

80102

81103
init_hooks()

0 commit comments

Comments
 (0)