Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open table option #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/bga_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,13 @@ async def parse_options(self, options, table_id):
# options will overwrite defaults if they are there
defaults.update(options)
updated_options = defaults

if "open" not in updated_options \
and "restrictgroup" in updated_options:
updated_options["open"] = "true"

url_data = []
final_url_data = []
for option in updated_options:
value = updated_options[option]
option_data = {}
Expand Down Expand Up @@ -275,6 +281,14 @@ async def parse_options(self, options, table_id):
elif option == "lang":
option_data["path"] = "/table/table/restrictToLanguage.html"
option_data["params"] = {"lang": updated_options[option]}
elif option == "open":
if updated_options["open"].lower() in {"1", "on", "true", "y", "yes"}:
option_data["path"] = "/table/table/openTableNow.html"
option_data["params"] = {}
elif updated_options["open"].lower() in {"0", "off", "false", "n", "no"}:
continue
else:
return f"Option `open` should have value `true` or `false`."
elif option.isdigit():
# If this is an HTML option, set it as such
option_data["path"] = "/table/table/changeoption.html"
Expand All @@ -283,6 +297,7 @@ async def parse_options(self, options, table_id):
return f"Option {option} not a valid option."

url_data.append(option_data)
url_data.extend(final_url_data)
return url_data

async def get_group_id(self, group_name):
Expand Down
2 changes: 2 additions & 0 deletions src/docs/bga_options_msg.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ The default is marked with a *
**lang**: ISO639-1 language code like en, es, fr, de. To find yours: en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Default language is none

**open**: If `true`, the table will be immediately opened for joining. Defaults to `true` if and only if `restrictgroup` is set.

_You can also specify options/values like 200:12 if you know what they are by looking at the HTML._