Skip to content

Commit

Permalink
Merge pull request #6 from benja810/config-team-urls
Browse files Browse the repository at this point in the history
Config team urls
  • Loading branch information
jspayne authored Jul 5, 2023
2 parents 25ea1e1 + 1b18851 commit fda9775
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bots/lemmy_mlb_game_threads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def __init__(self, bot, settings):
if self.settings.get("Bot", {}).get("TEMPLATE_PATH", "") != "":
self.BOT_TEMPLATE_PATH.append(self.settings["Bot"]["TEMPLATE_PATH"])
self.BOT_TEMPLATE_PATH.append(os.path.join(self.BOT_PATH, "templates"))

self.LOOKUP = TemplateLookup(directories=self.BOT_TEMPLATE_PATH)
self.BOT_CONFIG_PATH = self.settings.get("Bot", {}).get("CONFIG_PATH", "") or os.path.join(self.BOT_PATH, "config")

def run(self):
self.log = logger.init_logger(
Expand Down Expand Up @@ -3996,7 +3996,14 @@ def collect_data(self, gamePk):
{"nextGame": self.get_nextGame(self.myTeam["id"])}
)

# Include team community dict
# Update team community dict
team_url_file = os.path.join(self.BOT_CONFIG_PATH, self.settings.get("Lemmy", {}).get("TEAM_URL_FILE") or "team_urls.json")
with open(team_url_file, 'r') as f:
team_subs = json.load(f)
# Convert the keys to int to coincide with the MLB data
# If the config file is empty or incomplete, this will use self.teamSubs as the default.
for key, val in team_subs.items():
self.teamSubs[int(key)] = val
pkData.update({"teamSubs": self.teamSubs})

# Team leaders (hitting, pitching)
Expand Down Expand Up @@ -5847,7 +5854,6 @@ def convert_timezone(self, dt, convert_to="America/New_York"):
120: "/c/nationals@fanaticus.social",
144: "/c/braves@fanaticus.social",
0: "/c/baseball@fanaticus.social",
"mlb": "/c/baseball@fanaticus.social",
}

def bot_state(self):
Expand Down
33 changes: 33 additions & 0 deletions bots/lemmy_mlb_game_threads/config/team_urls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"142": "/c/minnesotatwins@fanaticus.social",
"145": "/c/whitesox@fanaticus.social",
"116": "/c/motorcitykitties@fanaticus.social",
"118": "/c/kcroyals@fanaticus.social",
"114": "/c/clevelandguardians@fanaticus.social",
"140": "/c/texasrangers@fanaticus.social",
"117": "/c/astros@fanaticus.social",
"133": "/c/oaklandathletics@fanaticus.social",
"108": "/c/angelsbaseball@fanaticus.social",
"136": "/c/mariners@fanaticus.social",
"111": "/c/redsox@fanaticus.social",
"147": "/c/nyyankees@fanaticus.social",
"141": "/c/torontobluejays@fanaticus.social",
"139": "/c/tampabayrays@fanaticus.social",
"110": "/c/orioles@fanaticus.social",
"138": "/c/cardinals@fanaticus.social",
"113": "/c/reds@fanaticus.social",
"134": "/c/buccos@fanaticus.social",
"112": "/c/chicubs@fanaticus.social",
"158": "/c/brewers@fanaticus.social",
"137": "/c/sfgiants@fanaticus.social",
"109": "/c/azdiamondbacks@fanaticus.social",
"115": "/c/coloradorockies@fanaticus.social",
"119": "/c/dodgers@fanaticus.social",
"135": "/c/padres@fanaticus.social",
"143": "/c/phillies@fanaticus.social",
"121": "/c/newyorkmets@fanaticus.social",
"146": "/c/miamimarlins@fanaticus.social",
"120": "/c/nationals@fanaticus.social",
"144": "/c/braves@fanaticus.social",
"0": "/c/baseball@fanaticus.social"
}
37 changes: 37 additions & 0 deletions bots/lemmy_mlb_game_threads_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,16 @@
"options": [],
"subkeys": [],
"parent_key": null
},
{
"key": "CONFIG_PATH",
"description": "Path where custom configuration files are stored (defaults to the bot config directory).",
"type": "str",
"val": "",
"options": [],
"subkeys": [],
"parent_key": null

}
],
"Weekly Thread": [
Expand Down Expand Up @@ -1409,6 +1419,33 @@
"options": [],
"subkeys": [],
"parent_key": ""
},
{
"key": "USERNAME",
"description": "Username of bot user",
"type": "str",
"val": "",
"options": [],
"subkeys": [],
"parent_key": ""
},
{
"key": "PASSWORD",
"description": "Password for bot user",
"type": "str",
"val": "",
"options": [],
"subkeys": [],
"parent_key": ""
},
{
"key": "TEAM_URL_FILE",
"description": "JSON file containing a map of team URLs. Keys are the MLB id number for each team. Use a relative URL to ensure it will work for remote instances.",
"type": "str",
"val": "",
"options": [],
"subkeys": [],
"parent_key": ""
}
]
}

0 comments on commit fda9775

Please sign in to comment.