TikTokLive.proto package

Submodules

TikTokLive.proto.custom_proto module

class TikTokLive.proto.custom_proto.ExtendedGift(*args: Any, image: ImageModel | None = <factory>, describe: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, duration: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, id: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, for_linkmic: bool = <factory>, combo: bool = <factory>, type: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, diamond_count: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, is_displayed_on_panel: bool = <factory>, primary_effect_id: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, gift_label_icon: ImageModel | None = <factory>, name: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, icon: ImageModel | None = <factory>, gold_effect: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, preview_image: ImageModel | None = <factory>, gift_panel_banner: GiftPanelBanner | None = <factory>, is_broadcast_gift: bool = <factory>, is_effect_befview: bool = <factory>, is_random_gift: bool = <factory>, is_box_gift: bool = <factory>, can_put_in_gift_box: bool = <factory>, gift_box_info: GiftBoxInfo | None = <factory>, tracker_params: dict[str, str]=<factory>, lock_info: GiftLockInfo | None = <factory>, color_infos: list[GiftColorInfo] = <factory>, gift_rank_recommend_info: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, random_effect_info: GiftRandomEffectInfo | None = <factory>, gift_sub_type: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, gift_vertical_scenarios: list[~typing.Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=-2147483648), Le(le=2147483647)])]] = <factory>, group_in_tab: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, is_gallery_gift: bool = <factory>, gift_sponsor_info: GiftSponsorInfo | None = <factory>, gift_skins: list[GiftSkin] = <factory>, gift_label_type: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, gift_texts: list[GiftText] = <factory>, gift_skin_to_gift_texts_infos: list[GiftSkinToGiftTextsInfo] = <factory>, expiration_timestamp: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, batch_gift_info: BatchGiftInfo | None = <factory>, is_global_gift: bool = <factory>, disable_gallery_banner: bool = <factory>, ug_gift_info: UgGiftStructInfo | None = <factory>, cross_screen_effect_info: CrossScreenEffectInfo | None = <factory>, beacon_bubble: GiftPanelBeaconBubble | None = <factory>, gift_resources: dict[str, ~TikTokLiveProto.v3.webcast.model.gift.model.GiftResource]=<factory>, resource_id: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, biz_extra: dict[int, str]=<factory>, lynx_cross_screen_effect_info: LynxCrossScreenEffectInfo | None = <factory>, gift_struct_hash: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, scheme_info: SchemeInfo | None = <factory>, series_info: GiftSeriesInfo | None = <factory>, strategy_event: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>)

Bases: Gift

Extended gift object with clearer streak handling

property gift_image

v2 alias; v3 reverted this field to image.

property gift_name

v2 alias; v3 reverted this field to name.

property gift_type

Legacy alias; v2 renamed type to gift_type, v3 reverted.

property streakable: bool

Whether a gift is capable of streaking.

class TikTokLive.proto.custom_proto.ExtendedUser(*args: Any, id: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, deprecated1: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, nickname: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, deprecated2: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, bio_description: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, deprecated3: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, deprecated4: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, deprecated5: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, avatar_thumb: ImageModel | None = <factory>, avatar_medium: ImageModel | None = <factory>, avatar_large: ImageModel | None = <factory>, verified: bool = <factory>, deprecated6: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, deprecated7: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, status: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, create_time: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, modify_time: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, secret: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, share_qrcode_uri: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, deprecated8: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, badge_image_list: list[ImageModel] = <factory>, follow_info: FollowInfo | None = <factory>, pay_grade: UserHonor | None = <factory>, fans_club: FansClubMember | None = <factory>, border: BorderInfo | None = <factory>, special_id: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, avatar_border: ImageModel | None = <factory>, medal: ImageModel | None = <factory>, real_time_icons: list[ImageModel] = <factory>, new_real_time_icons: list[ImageModel] = <factory>, top_vip_no: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, user_attr: UserAttr | None = <factory>, own_room: OwnRoom | None = <factory>, pay_score: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, ticket_count: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, anchor_info: AnchorInfo | None = <factory>, link_mic_stats: LinkmicStatus = <factory>, display_id: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, with_commerce_permission: bool = <factory>, with_fusion_shop_entry: bool = <factory>, deprecated21: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, webcast_anchor_level: AnchorLevel | None = <factory>, verified_content: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, author_stats: Author | None = <factory>, top_fans: list[User] = <factory>, sec_uid: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, user_role: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, deprecated9: bytes = <factory>, activity_reward: ActivityRewardInfo | None = <factory>, deprecated10: bytes = <factory>, deprecated11: bytes = <factory>, personal_card: ImageModel | None = <factory>, authentication_info: AuthenticationInfo | None = <factory>, deprecated12: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, deprecated13: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, deprecated14: bytes = <factory>, media_badge_image_list: list[ImageModel] = <factory>, deprecated15: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, user_vip_info: bytes = <factory>, commerce_webcast_config_ids: list[~typing.Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=-9223372036854775808), Le(le=9223372036854775807)])]] = <factory>, border_list: list[BorderInfo] = <factory>, combo_badge_info: ComboBadgeInfo | None = <factory>, subscribe_info: SubscribeInfo | None = <factory>, badge_list: list[BadgeStruct] = <factory>, mint_type_label: list[~typing.Annotated[int, FieldInfo(annotation=NoneType, required=True, metadata=[Ge(ge=-9223372036854775808), Le(le=9223372036854775807)])]] = <factory>, fans_club_info: FansClubInfo | None = <factory>, deprecated19: bool = <factory>, allow_find_by_contacts: bool = <factory>, allow_others_download_video: bool = <factory>, allow_others_download_when_sharing_video: bool = <factory>, allow_share_show_profile: bool = <factory>, allow_show_in_gossip: bool = <factory>, allow_show_my_action: bool = <factory>, allow_strange_comment: bool = <factory>, allow_unfollower_comment: bool = <factory>, allow_use_linkmic: bool = <factory>, anchor_level: AnchorLevel | None = <factory>, avatar_jpg: ImageModel | None = <factory>, bg_img_url: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, deprecated18: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, deprecated16: bool = <factory>, block_status: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, comment_restrict: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, constellation: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, disable_ichat: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, enable_ichat_img: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, exp: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, fan_ticket_count: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, fold_stranger_chat: bool = <factory>, follow_status: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, deprecated28: bool = <factory>, deprecated29: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, ichat_restrict_type: Annotated[int, ~annotated_types.Ge(ge=-2147483648), ~annotated_types.Le(le=2147483647)] = <factory>, id_str: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, is_follower: bool = <factory>, is_following: bool = <factory>, need_profile_guide: bool = <factory>, pay_scores: Annotated[int, ~annotated_types.Ge(ge=-9223372036854775808), ~annotated_types.Le(le=9223372036854775807)] = <factory>, push_comment_status: bool = <factory>, push_digg: bool = <factory>, push_follow: bool = <factory>, push_friend_action: bool = <factory>, push_ichat: bool = <factory>, push_status: bool = <factory>, push_video_post: bool = <factory>, push_video_recommend: bool = <factory>, stats: bytes = <factory>, deprecated17: bool = <factory>, verified_reason: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, with_car_management_permission: bool = <factory>, upcoming_event_list: list[LiveEventInfo] = <factory>, scm_label: Annotated[str, ~pydantic.functional_validators.AfterValidator(func=~betterproto2.validators.proto_types.validate_string)] = <factory>, ecommerce_entrance: EcommerceEntrance | None = <factory>, is_block: bool = <factory>, is_subscribe: bool = <factory>, is_anchor_marked: bool = <factory>, enigma_info: EnigmaInfo | None = <factory>)

Bases: User

Extended user object with backwards compatibility

property badges

v2 alias; v3 reverted this field to badge_list.

classmethod from_user(user: User) ExtendedUser

Convert a user to an ExtendedUser object

Parameters:

user – Original user object

Returns:

ExtendedUser instance

property get_all_badges: List[Tuple[str, str]]

Retrieve all badges with their types and levels.

Returns:

List of (badge_type, level) tuples

property gifter_level: int | None

What is the user’s “gifter level” overall? An actual number specific to their level.

Returns:

The parsed gifter level from the gifter level badge

has_badge(badge_type: str, level: str | int | None = None) bool

Check if the user has a specific badge type with optional level validation.

Parameters:
  • badge_type – Badge type to check (e.g., “SUBSCRIBER”).

  • level – Optional level to validate.

Returns:

True if the badge exists with matching criteria, False otherwise.

property is_friend: bool

Is the user friends with the streamer

Returns:

Whether the user is friends with the streamer

property is_moderator: bool

Is the user a moderator in the stream

Returns:

Whether the user has the moderator badge

property is_top_gifter: bool

Is the user a top gifter in the stream

Returns:

Whether the user has the top gifter badge

property member_level: int | None

What is the user’s “member level” in the stream? This is a number.

Returns:

The parsed member level badge

property member_rank: int | None

What is the user’s “member rank” in the stream?

Historically these were roman-numeral strings; in v2 the badge carries the integer level directly, so this returns the parsed level (an alias of member_level).

property nick_name

Legacy alias; v3 exposes this field as nickname.

property unique_id: str | None

Legacy alias for the @-handle. v3 exposes it as display_id.

property username

Legacy alias; v3 exposes this field as display_id.

TikTokLive.proto.custom_proto.proto_extension(cls: Type[_MessageType]) Type[_MessageType]

Betterproto doesn’t properly handle inheriting existing messages. This method takes the superclass proto metadata and assigns that to this one.

Parameters:

cls – Class to wrap

Returns:

The class, wrapped.

TikTokLive.proto.proto_utils module

TikTokLive.proto.proto_utils.badge_match(badge: BadgeStruct, p: Pattern) Match | None

Search & extract text from any TikTok badge variant.

v2 represents badge contents as a betterproto2 oneof under the badgeType group (image/text/str/combine).

TikTokLive.proto.proto_utils.badge_match_user(user: User, p: Pattern) List[Tuple[Match, BadgeStruct]]

Search a user’s badges for a given regex pattern, and return the matches.

TikTokLive.proto.proto_utils.common_display_type(common: CommonMessageData | None) str

Safely read common.display_text.key through the v3 nullable chain.

v2 exposed this as display_text.display_type; v3 renamed Text field 1 (same wire number, same string type) to key.

Module contents