bot.userdata Module#

A custom user data class.

bot.userdata.CCT

Type alias for telegram.ext.CallbackContext with UserData as user data.

alias of CallbackContext[ExtBot, UserData, dict, dict]

class bot.userdata.UserData(user_id=None, username=None, first_name=None, full_name=None, photo_file_unique_id=None, fallback_photo=None, sticker_file_ids=None, temp_file_ids=None, store_stickers=True, tzinfo='UTC', text_direction='ltr')

Bases: object

Custom class to store information relevant for each user.

Parameters:
  • user_id (Optional[int]) – The users id.

  • username (Optional[str]) – The users username

  • first_name (Optional[str]) – The users first name.

  • full_name (Optional[str]) – The users full name.

  • photo_file_unique_id (Optional[str]) – The users current photos unique file id.

  • fallback_photo (Optional[PhotoSize]) – The users fallback photo

  • sticker_file_ids (Dict[str, str]) – Mapping file unique id → file id of stickers sent by the user for later use.

  • temp_file_ids (Dict[str, Tuple[str, str]]) – Temporarily saved file ids of stickers generated by the user.

  • store_stickers (Optional[bool]) – Whether or not this users wants to store stickers. Defaults to True.

  • tzinfo (str) – Users timezone. Defaults to UTC.

  • text_direction (str) – Users preferred text direction. Defaults to left-to-right.

user_id

The users id.

username

The users username

first_name

The users first name.

full_name

The users full name.

photo_file_unique_id

The users current photos unique file id.

fallback_photo

The users fallback photo

sticker_file_ids

Mapping file unique id → file id of stickers sent by the user for later use.

temp_file_ids

Temporarily saved file ids of stickers generated by the user.

store_stickers

Whether or not this users wants to store stickers. Defaults to True.

inline_query_task

Optional. A asyncio.Task which answers the current inline query.

inline_query_event

Optional. An tasking.Event. Setting this event will cause inline_query_task to terminate.

tzinfo

Users timezone.

text_direction

Users preferred text direction.

update_fallback_photo(fallback_photo)

Updates fallback photo for this user.

Parameters:

fallback_photo (Optional[PhotoSize]) – The new fallback photo.

Return type:

None

update_user_info(user, photo_file_unique_id)

Updates the stored info about the user with the fresh users instance.

Parameters:
  • user (User) – The User instance.

  • photo_file_unique_id (Optional[str]) – The up to date unique file id.

Return type:

None