Skip to content

Commit 2bad530

Browse files
Use organisation ID instead of members url (#413)
1 parent 7d10065 commit 2bad530

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GROUP_SHORT_NAME=[Replace with the short colloquial name of your community group
2424

2525
# The URL of the page where guests can purchase a full membership to join your community group
2626
# Must be a valid URL
27-
PURCHASE_MEMBERSHIP_URL=[Replace with your group's purchase=membership URL]
27+
PURCHASE_MEMBERSHIP_URL=[Replace with your group\'s purchase=membership URL]
2828

2929

3030
# The minimum level that logs must meet in order to be logged to the console output stream
@@ -36,7 +36,7 @@ CONSOLE_LOG_LEVEL=INFO
3636
# The URL to retrieve the list of IDs of people that have purchased a membership to your community group
3737
# Ensure that all members are visible without pagination. For example, if your members-list is found on the UoB Guild of Students website, ensure the URL includes the "sort by groups" option
3838
# Must be a valid URL
39-
MEMBERS_LIST_URL=[Replace with your group's members-list URL]
39+
ORGANISATION_ID=[Replace with your group\'s MSL Organisation ID]
4040

4141
# !!REQUIRED!!
4242
# The members-list URL session cookie
@@ -99,7 +99,7 @@ STATISTICS_ROLES=Committee,Committee-Elect,Student Rep,Member,Guest,Server Boost
9999
# !!REQUIRED!!
100100
# The URL of the your group's Discord guild moderation document
101101
# Must be a valid URL
102-
MODERATION_DOCUMENT_URL=[Replace with your group's moderation document URL]
102+
MODERATION_DOCUMENT_URL=[Replace with your group\'s moderation document URL]
103103

104104

105105
# The name of the channel, that warning messages will be sent to when a committee-member manually applies a moderation action (instead of using the `/strike` command)

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ You'll also need to set a number of [environment variables](https://wikipedia.or
190190
(This setting is optional.
191191
Error logs will **always** be sent to the [console](https://wikipedia.org/wiki/Terminal_emulator), this setting allows them to also be sent to a [Discord log channel](https://docs.pycord.dev/en/stable/api/models.html#discord.TextChannel).)
192192

193-
* `MEMBERS_LIST_URL`: The [URL](https://wikipedia.org/wiki/URL) to retrieve the list of IDs of people that have purchased a membership to your community group.
194-
(The [CSS](https://cssbham.com)' members-list is currently found on [the Guild of Students website](https://guildofstudents.com).
195-
If your members-list is also found on [the Guild of Students website](https://guildofstudents.com), ensure the [URL](https://wikipedia.org/wiki/URL) includes the "sort by groups" option, so that all members are visible without [pagination](https://wikipedia.org/wiki/Pagination).)
193+
* `ORGANISATION_ID`: Your Guild society ID. This is used to dynamically create the members list among other needed URLs.
196194

197195
* `MEMBERS_LIST_URL_SESSION_COOKIE`: The members-list [URL](https://wikipedia.org/wiki/URL) [session cookie](https://wikipedia.org/wiki/HTTP_cookie#Session_cookie).
198196
(If your group's members-list is stored at a [URL](https://wikipedia.org/wiki/URL) that requires [authentication](https://wikipedia.org/wiki/Authentication), this [session cookie](https://wikipedia.org/wiki/HTTP_cookie#Session_cookie) should [authenticate](https://wikipedia.org/wiki/Authentication) TeX-Bot to view your group's members-list, as if it were [logged in to the website](https://wikipedia.org/wiki/Login_session) as a Committee member.

cogs/make_member.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
".ASPXAUTH": settings["MEMBERS_LIST_AUTH_SESSION_COOKIE"],
6868
}
6969

70-
REQUEST_URL: "Final[str]" = settings["MEMBERS_LIST_URL"]
70+
ORGANISATION_ID: "Final[str]" = settings["ORGANISATION_ID"]
71+
GROUPED_MEMBRS_URL: "Final[str]" = f"https://guildofstudents.com/organisation/memberlist/{ORGANISATION_ID}/?sort=groups"
7172

7273

7374
class MakeMemberCommandCog(TeXBotBaseCog):
@@ -171,7 +172,7 @@ async def make_member(self, ctx: "TeXBotApplicationContext", group_member_id: st
171172
headers=REQUEST_HEADERS,
172173
cookies=REQUEST_COOKIES,
173174
)
174-
async with http_session, http_session.get(REQUEST_URL) as http_response:
175+
async with http_session, http_session.get(GROUPED_MEMBRS_URL) as http_response:
175176
response_html: str = await http_response.text()
176177

177178
MEMBER_HTML_TABLE_IDS: Final[frozenset[str]] = frozenset(

config.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,20 @@ def _setup_roles_messages(cls) -> None:
377377
cls._settings["ROLES_MESSAGES"] = set(messages_dict["roles_messages"]) # type: ignore[call-overload]
378378

379379
@classmethod
380-
def _setup_members_list_url(cls) -> None:
381-
raw_members_list_url: str | None = os.getenv("MEMBERS_LIST_URL")
380+
def _setup_organisation_id(cls) -> None:
381+
raw_organisation_id: str | None = os.getenv("ORGANISATION_ID")
382382

383-
MEMBERS_LIST_URL_IS_VALID: Final[bool] = bool(
384-
raw_members_list_url and validators.url(raw_members_list_url),
383+
ORGANISATION_ID_IS_VALID: Final[bool] = bool(
384+
raw_organisation_id and re.fullmatch(r"\A\d{4,5}\Z", raw_organisation_id),
385385
)
386-
if not MEMBERS_LIST_URL_IS_VALID:
387-
INVALID_MEMBERS_LIST_URL_MESSAGE: Final[str] = (
388-
"MEMBERS_LIST_URL must be a valid URL."
386+
387+
if not ORGANISATION_ID_IS_VALID:
388+
INVALID_ORGANISATION_ID_MESSAGE: Final[str] = (
389+
"ORGANISATION_ID must be an integer 4 to 5 digits long."
389390
)
390-
raise ImproperlyConfiguredError(INVALID_MEMBERS_LIST_URL_MESSAGE)
391+
raise ImproperlyConfiguredError(message=INVALID_ORGANISATION_ID_MESSAGE)
391392

392-
cls._settings["MEMBERS_LIST_URL"] = raw_members_list_url
393+
cls._settings["ORGANISATION_ID"] = raw_organisation_id
393394

394395
@classmethod
395396
def _setup_members_list_auth_session_cookie(cls) -> None:
@@ -701,7 +702,7 @@ def _setup_env_variables(cls) -> None:
701702
cls._setup_ping_command_easter_egg_probability()
702703
cls._setup_welcome_messages()
703704
cls._setup_roles_messages()
704-
cls._setup_members_list_url()
705+
cls._setup_organisation_id()
705706
cls._setup_members_list_auth_session_cookie()
706707
cls._setup_membership_perks_url()
707708
cls._setup_purchase_membership_url()

0 commit comments

Comments
 (0)