|
8 | 8 | search_pages = defaultdict(dict) |
9 | 9 |
|
10 | 10 |
|
| 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 | + |
11 | 33 | @hook.command("morescore", autohelp=False) |
12 | 34 | def morescore(text, chan, conn): |
13 | 35 | """[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): |
65 | 87 |
|
66 | 88 | def score_hook(game): |
67 | 89 | def func(conn, chan, text): |
68 | | - return scrape_scores(conn, chan, game, text) |
| 90 | + return scrape_scores(conn, chan, game.name, text) |
69 | 91 |
|
70 | | - func.__name__ = "{}_scores".format(game) |
| 92 | + func.__name__ = "{}_scores".format(game.name) |
71 | 93 | 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." |
72 | 94 | return func |
73 | 95 |
|
74 | 96 |
|
75 | 97 | def init_hooks(): |
76 | | - for game in ("nfl", "mlb", "nba", "ncaab", "ncaaf", "nhl", "wnba"): |
| 98 | + for game in GAMES: |
77 | 99 | 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) |
79 | 101 |
|
80 | 102 |
|
81 | 103 | init_hooks() |
0 commit comments