Compare commits

...

3 Commits

Author SHA1 Message Date
Luna 17d0c36343 tests: support new guild.properties field 2023-05-26 20:43:52 -03:00
Luna 48015b5bdb fix typo 2023-05-26 20:43:47 -03:00
Luna ac1a0eb580 support undocumented api fields 2023-05-26 20:26:35 -03:00
4 changed files with 52 additions and 4 deletions

View File

@ -96,6 +96,16 @@ IDENTIFY_SCHEMA = {
}, },
"browser_user_agent": {"type": "string", "required": False}, "browser_user_agent": {"type": "string", "required": False},
"browser_version": {"type": "string", "required": False}, "browser_version": {"type": "string", "required": False},
"native_build_number": {
"type": "number",
"required": False,
"nullable": True,
},
"design_id": {
"type": "number",
"required": False,
"nullable": True,
},
}, },
}, },
"capabilities": {"type": "number", "required": False}, "capabilities": {"type": "number", "required": False},
@ -125,6 +135,10 @@ IDENTIFY_SCHEMA = {
"type": "string", "type": "string",
"required": False, "required": False,
}, },
"api_code_version": {
"type": "number",
"required": False,
},
}, },
}, },
"guild_subscriptions": {"type": "boolean", "required": False}, "guild_subscriptions": {"type": "boolean", "required": False},

View File

@ -167,6 +167,7 @@ async def _compute_supplemental(app, base_ready, user_ready, users_to_send: dict
supplemental["guilds"].append( supplemental["guilds"].append(
{ {
"embedded_activities": [],
"voice_states": [], "voice_states": [],
"id": guild["id"], "id": guild["id"],
} }
@ -778,11 +779,12 @@ class GatewayWebsocket:
async def handle_2(self, payload: Dict[str, Any]): async def handle_2(self, payload: Dict[str, Any]):
"""Handle the OP 2 Identify packet.""" """Handle the OP 2 Identify packet."""
# do not validate given guild_hashes # do not validate given guild_hashes, guild_versions
payload_copy = dict(payload) payload_copy = dict(payload)
payload_copy["d"].get("client_state", {"guild_hashes": None}).pop( client_state = payload_copy["d"].get("client_state")
"guild_hashes" if client_state:
) client_state.pop("guild_hashes", None)
client_state.pop("guild_versions", None)
validate(payload_copy, IDENTIFY_SCHEMA) validate(payload_copy, IDENTIFY_SCHEMA)
data = payload["d"] data = payload["d"]
token = data["token"] token = data["token"]

View File

@ -236,6 +236,37 @@ class Storage:
# feature won't be impl'd # feature won't be impl'd
drow["guild_scheduled_events"] = [] drow["guild_scheduled_events"] = []
# this is NOT a part of documented v10 behavior
FIELDS_MIRRORED_TO_PROPERTIES = (
"max_members",
"afk_channel_id",
"features",
"owner_id",
"explicit_content_filter",
"verification_level",
"mfa_level",
"id",
"system_channel_id",
"afk_timeout",
"vanity_url_code",
"public_updates_channel_id",
"icon",
"rules_channel_id",
"banner",
"nsfw",
"discovery_splash",
"splash",
"default_message_notifications",
"application_id",
"home_header",
"name",
"system_channel_flags",
"preferred_locale",
)
drow["properties"] = {}
for field in FIELDS_MIRRORED_TO_PROPERTIES:
drow["properties"][field] = drow.get(field)
return drow return drow
async def _member_basic(self, guild_id: int, member_id: int): async def _member_basic(self, guild_id: int, member_id: int):

View File

@ -143,6 +143,7 @@ class WrappedGuild:
voice_states: list voice_states: list
large: Optional[bool] = None large: Optional[bool] = None
properties: Optional[dict] = None
async def delete(self): async def delete(self):
await delete_guild(self.id) await delete_guild(self.id)