@@ -268,6 +268,23 @@ async def get_full_user(username: Union[int, str], account: str = None) -> str:
268268 except Exception :
269269 personal_channel = str (personal_channel_id )
270270
271+ # Birthday is exposed in UserFull for Premium users who set it and allow
272+ # contacts to see it. The `year` component is optional (often hidden).
273+ # Returns ISO `YYYY-MM-DD` when year is present, else `--MM-DD` (vCard
274+ # RFC 6350 style for year-less dates); None when not available.
275+ birthday = getattr (full_user , "birthday" , None )
276+ birthday_str = None
277+ if birthday is not None :
278+ b_day = getattr (birthday , "day" , None )
279+ b_month = getattr (birthday , "month" , None )
280+ b_year = getattr (birthday , "year" , None )
281+ if b_day and b_month :
282+ birthday_str = (
283+ f"{ b_year :04d} -{ b_month :02d} -{ b_day :02d} "
284+ if b_year
285+ else f"--{ b_month :02d} -{ b_day :02d} "
286+ )
287+
271288 result = {
272289 "id" : user .id if user else None ,
273290 "first_name" : sanitize_name (getattr (user , "first_name" , None )) if user else None ,
@@ -276,6 +293,7 @@ async def get_full_user(username: Union[int, str], account: str = None) -> str:
276293 "phone" : getattr (user , "phone" , None ) if user else None ,
277294 "bio" : sanitize_user_content (full_user .about or "" , max_length = 1024 ),
278295 "personal_channel" : personal_channel ,
296+ "birthday" : birthday_str ,
279297 "bot" : getattr (user , "bot" , False ) if user else False ,
280298 "verified" : getattr (user , "verified" , False ) if user else False ,
281299 "premium" : getattr (user , "premium" , False ) if user else False ,
0 commit comments