Skip to content

Message Models

teams_lib_pzsp2_z1.model.message

Classes

ListMessagesOptions dataclass

Contains options for listing messages (pagination and expansion).

Attributes:

Name Type Description
top Optional[int]

The maximum number of messages to return in one page. Defaults to None (server default).

expand_replies bool

If True, the response will include replies nested within the messages. Defaults to False.

Source code in teams_lib_pzsp2_z1/model/message.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
@dataclass
class ListMessagesOptions:
    """Contains options for listing messages (pagination and expansion).

    Attributes:
        top (Optional[int]): The maximum number of messages to return in one page.
            Defaults to None (server default).
        expand_replies (bool): If True, the response will include replies
            nested within the messages. Defaults to False.
    """

    top: int | None = None
    expand_replies: bool = False

Message dataclass

Represents a Microsoft Teams chat message.

Used in both direct chats and channels.

Attributes:

Name Type Description
id str

The unique identifier of the message.

content str

The actual body text or HTML of the message.

content_type MessageContentType

The format of the content (Text or HTML).

created_date_time datetime

The timestamp when the message was created.

sender MessageFrom

The user who sent the message. Note: Mapped from the From field in the API/Go model to avoid conflict with the Python from keyword.

reply_count int

The number of replies to this message.

Source code in teams_lib_pzsp2_z1/model/message.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@dataclass
class Message:
    """Represents a Microsoft Teams chat message.

    Used in both direct chats and channels.

    Attributes:
        id (str): The unique identifier of the message.
        content (str): The actual body text or HTML of the message.
        content_type (MessageContentType): The format of the content (Text or HTML).
        created_date_time (datetime): The timestamp when the message was created.
        sender (MessageFrom): The user who sent the message.
            **Note:** Mapped from the `From` field in the API/Go model to avoid
            conflict with the Python `from` keyword.
        reply_count (int): The number of replies to this message.
    """

    id: str
    content: str
    content_type: MessageContentType
    created_date_time: datetime
    sender: MessageFrom
    reply_count: int

MessageBody dataclass

Represents the body of a message to be sent.

This class contains the payload structure required to send a new message or reply.

Attributes:

Name Type Description
content_type MessageContentType

The format of the content.

content str

The text or HTML content.

mentions List[Mention]

A list of mentions to include in the message.

Source code in teams_lib_pzsp2_z1/model/message.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@dataclass
class MessageBody:
    """Represents the body of a message to be sent.

    This class contains the payload structure required to send a new message
    or reply.

    Attributes:
        content_type (MessageContentType): The format of the content.
        content (str): The text or HTML content.
        mentions (List[Mention]): A list of mentions to include in the message.
    """

    content_type: MessageContentType
    content: str
    mentions: list[Mention]

    def __dict__(self):
        """Serializes the object keys to PascalCase for the Go backend."""

        return {
            "ContentType": self.content_type.value,
            "Content": self.content,
        }

    def __iter__(self):
        """Allows iteration over fields with PascalCase keys."""

        yield "ContentType", self.content_type.value
        yield "Content", self.content
Functions
__dict__()

Serializes the object keys to PascalCase for the Go backend.

Source code in teams_lib_pzsp2_z1/model/message.py
75
76
77
78
79
80
81
def __dict__(self):
    """Serializes the object keys to PascalCase for the Go backend."""

    return {
        "ContentType": self.content_type.value,
        "Content": self.content,
    }
__iter__()

Allows iteration over fields with PascalCase keys.

Source code in teams_lib_pzsp2_z1/model/message.py
83
84
85
86
87
def __iter__(self):
    """Allows iteration over fields with PascalCase keys."""

    yield "ContentType", self.content_type.value
    yield "Content", self.content

MessageCollection dataclass

Represents a paginated collection of messages.

Attributes:

Name Type Description
messages List[Message]

The list of message objects in the current page.

next_link Optional[str]

The URL to retrieve the next page of results. If None, there are no more messages.

Source code in teams_lib_pzsp2_z1/model/message.py
105
106
107
108
109
110
111
112
113
114
115
116
@dataclass
class MessageCollection:
    """Represents a paginated collection of messages.

    Attributes:
        messages (List[Message]): The list of message objects in the current page.
        next_link (Optional[str]): The URL to retrieve the next page of results.
            If None, there are no more messages.
    """

    messages: list[Message]
    next_link: str | None = None

MessageContentType

Bases: Enum

Represents the type of content in a Microsoft Teams message.

Attributes:

Name Type Description
TEXT

Plain text content.

HTML

HTML formatted content.

Source code in teams_lib_pzsp2_z1/model/message.py
 8
 9
10
11
12
13
14
15
16
17
class MessageContentType(Enum):
    """Represents the type of content in a Microsoft Teams message.

    Attributes:
        TEXT: Plain text content.
        HTML: HTML formatted content.
    """

    TEXT = "text"
    HTML = "html"

MessageFrom dataclass

Represents the sender of a message in Microsoft Teams.

Attributes:

Name Type Description
user_id str

The unique Azure Active Directory (AAD) identifier of the sender.

display_name str

The visible name of the sender.

Source code in teams_lib_pzsp2_z1/model/message.py
20
21
22
23
24
25
26
27
28
29
30
@dataclass
class MessageFrom:
    """Represents the sender of a message in Microsoft Teams.

    Attributes:
        user_id (str): The unique Azure Active Directory (AAD) identifier of the sender.
        display_name (str): The visible name of the sender.
    """

    user_id: str
    display_name: str

teams_lib_pzsp2_z1.model.mention

Classes

Mention dataclass

Represents a mention entity within a Microsoft Teams message.

This object maps a specific entity (User, Channel, etc.) to a placeholder in the message content. Can be obtained by get_mentions() method in the Chats and Channels service.

Attributes:

Name Type Description
kind MentionKind

The type of the mention.

at_id int

The internal identifier used to link this mention to the message content. Example: If the message body contains <at id="0">@John</at>, this field should be 0.

text str

The text to display in the message (e.g., "@John Doe").

target_id str

The unique identifier (UUID) of the entity being mentioned (User ID, Channel ID, or Team ID).

Source code in teams_lib_pzsp2_z1/model/mention.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@dataclass
class Mention:
    """Represents a mention entity within a Microsoft Teams message.

    This object maps a specific entity (User, Channel, etc.) to a placeholder
    in the message content. Can be obtained by get_mentions() method in the Chats and Channels service.

    Attributes:
        kind (MentionKind): The type of the mention.
        at_id (int): The internal identifier used to link this mention to the
            message content.
            *Example:* If the message body contains `<at id="0">@John</at>`,
            this field should be `0`.
        text (str): The text to display in the message (e.g., "@John Doe").
        target_id (str): The unique identifier (UUID) of the entity being mentioned
            (User ID, Channel ID, or Team ID).
    """

    kind: MentionKind
    at_id: int
    text: str
    target_id: str

MentionKind

Bases: Enum

Represents the kind of mention in a Microsoft Teams message.

Attributes:

Name Type Description
USER

Represents a mention of a specific user.

CHANNEL

Represents a mention of the current channel.

TEAM

Represents a mention of the entire team.

EVERYONE

Represents a mention of all participants. Note: This is applicable to Group Chats only.

Source code in teams_lib_pzsp2_z1/model/mention.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
class MentionKind(Enum):
    """Represents the kind of mention in a Microsoft Teams message.

    Attributes:
        USER: Represents a mention of a specific user.
        CHANNEL: Represents a mention of the current channel.
        TEAM: Represents a mention of the entire team.
        EVERYONE: Represents a mention of all participants.
            **Note:** This is applicable to Group Chats only.
    """

    USER = "user"
    CHANNEL = "channel"
    TEAM = "team"
    EVERYONE = "everyone"