11from __future__ import annotations
22
33import hashlib
4- from typing import AsyncGenerator , Final , Literal
4+ from typing import AsyncGenerator , Final , Literal , overload
55import zlib
66import base64
77import json
@@ -1071,4 +1071,35 @@ def login(username:str,password:str,load_status:bool=True,*,recaptcha_code:str|N
10711071 Returns:
10721072 _AwaitableContextManager[Session]: await か async with で取得できるセッション
10731073 """
1074- return _AwaitableContextManager (_login (username ,password ,load_status ,recaptcha_code = recaptcha_code ))
1074+ return _AwaitableContextManager (_login (username ,password ,load_status ,recaptcha_code = recaptcha_code ))
1075+
1076+ @overload
1077+ def send_password_reset_email (client :HTTPClient ,* ,username :str ):
1078+ pass
1079+
1080+ @overload
1081+ def send_password_reset_email (client :HTTPClient ,* ,email :str ):
1082+ pass
1083+
1084+ async def send_password_reset_email (client :HTTPClient ,* ,username :str | None = None ,email :str | None = None ):
1085+ """
1086+ パスワードリセットメールを送信する。
1087+ ユーザー名とメールアドレスはどちらかのみ指定できます。
1088+
1089+ Args:
1090+ client (HTTPClient): 通信に使用するHTTPClient
1091+ username (str | None, optional): ユーザー名
1092+ email (str | None, optional): メールアドレス
1093+ """
1094+ data = aiohttp .FormData ({"csrfmiddlewaretoken" :"a" })
1095+ if username is not None :
1096+ if email is not None :
1097+ raise ValueError ()
1098+ data .add_field ("username" ,username )
1099+ else :
1100+ if email is None :
1101+ raise ValueError ()
1102+ data .add_field ("email" ,email )
1103+ response = await client .post ("https://scratch.mit.edu/accounts/password_reset/" ,data = data )
1104+ if response ._response .url == "https://scratch.mit.edu/accounts/password_reset/" :
1105+ raise InvalidData (response )
0 commit comments