MessageActivityInput 类

使用生成器方法创建消息活动的输入模型。

通过分析和验证关键字参数中的输入数据来创建新模型。

引发 [ValidationError][pydantic_core。如果无法验证输入数据以形成有效的模型,则 ValidationError]。

self 是显式位置仅允许 自己 作为字段名称。

构造函数

MessageActivityInput(*, serviceUrl: str | None = None, timestamp: datetime | None = None, locale: str | None = None, localTimestamp: datetime | None = None, channelId: Literal['webchat', 'msteams'] | str | None = None, from_: Account | None = None, conversation: ConversationAccount | None = None, replyToId: str | None = None, entities: List[ClientInfoEntity | MentionEntity | MessageEntity | AIMessageEntity | StreamInfoEntity | CitationEntity | SensitiveUsageEntity | ProductInfoEntity | QuotedReplyEntity | TargetedMessageInfoEntity | UnknownEntity] | None = None, channelData: ChannelData | None = None, type: Literal['message'] = 'message', id: str | None = None, recipient: Account | None = None, text: str | None = None, summary: str | None = None, textFormat: Literal['markdown', 'plain', 'xml'] | None = None, attachmentLayout: AttachmentLayout | None = None, attachments: List[Attachment] | None = None, suggestedActions: SuggestedActions | None = None, deliveryMode: Literal['normal', 'notification', 'expectReplies', 'ephemeral'] | None = None, value: Any | None = None, **extra_data: Any)

仅限关键字的参数

名称 说明
serviceUrl
默认值: None
timestamp
默认值: None
locale
默认值: None
localTimestamp
默认值: None
channelId
默认值: None
from_
默认值: None
conversation
默认值: None
replyToId
默认值: None
entities
默认值: None
channelData
默认值: None
type
默认值: message
id
默认值: None
recipient
默认值: None
text
默认值: None
summary
默认值: None
textFormat
默认值: None
attachmentLayout
默认值: None
attachments
默认值: None
suggestedActions
默认值: None
deliveryMode
默认值: None
value
默认值: None

方法

add_ai_generated

添加“由 AI 生成的”标签。

add_attachments

向邮件添加附件。

add_card

向邮件添加卡片附件。

add_citation

添加引文。

add_feedback

启用消息反馈。

add_mention

向消息添加提及(@mention)。

add_quote

添加带引号的消息引用,并将占位符追加到文本中。 Teams 将带引号的消息呈现为响应文本上方的预览气泡。 如果提供了文本,则会将其追加到带引号的消息占位符。

Warning

即将推出

此 API 即将推出,将来可能会更改。

诊断:ExperimentalTeamsQuotedReplies

add_stream_final

添加流信息,使其成为最终流消息。

add_targeted_message_info

添加 targetedMessageInfo 实体,以便进行提示预览。

如果已存在类型 "targetedMessageInfo" 实体,则不会再次添加该实体(每条消息一个提示预览)。

添加实体时,将删除任何 quotedReply 实体和匹配 <quoted messageId="..."/> 的占位符文本,以避免与提示预览冲突。

add_text

向消息追加文本。

get_account_mention

按帐户 ID 获取提及实体。

is_recipient_mentioned

检查邮件中是否提到收件人帐户。

prepend_quote

在现有文本之前追加 quotedReply 实体和占位符。 由 reply()/quote()用于上述引号。

Warning

即将推出

此 API 即将推出,将来可能会更改。

诊断:ExperimentalTeamsQuotedReplies

with_attachment_layout

设置多个附件的布局提示。

with_delivery_mode

设置活动的传递模式。

with_recipient

设置收件人。

with_suggested_actions

设置活动的建议操作。

with_summary

如果通道无法呈现卡片,请设置要显示的文本。

with_text

设置邮件的文本内容。

with_text_format

设置文本字段的格式。

add_ai_generated

添加“由 AI 生成的”标签。

add_ai_generated() -> Self

add_attachments

向邮件添加附件。

add_attachments(*attachments: Attachment) -> Self

参数

名称 说明
*attachments
必需

要添加的附件

返回

类型 说明

自链接方法

add_card

向邮件添加卡片附件。

add_card(card: AdaptiveCard) -> Self

参数

名称 说明
card
必需

要添加的卡片附件

content
必需

卡片内容

返回

类型 说明

自链接方法

add_citation

添加引文。

add_citation(position: int, appearance: CitationAppearance) -> Self

参数

名称 说明
position
必需
appearance
必需

add_feedback

启用消息反馈。

add_feedback(mode: Literal['default', 'custom'] = 'default') -> Self

参数

名称 说明
mode

“default”显示 Teams 的内置拇指向上/向下 UI。 “custom”触发消息/fetchTask 调用,以便机器人可以返回其自己的任务模块对话框。

默认值: default

add_mention

向消息添加提及(@mention)。

add_mention(account: Account, text: str | None = None, add_text: bool = True) -> Self

参数

名称 说明
account
必需

要提及的帐户

text

提及的自定义文本(默认为 account.name)

默认值: None
add_text

是否将提及文本追加到消息

默认值: True

返回

类型 说明

自链接方法

add_quote

添加带引号的消息引用,并将占位符追加到文本中。 Teams 将带引号的消息呈现为响应文本上方的预览气泡。 如果提供了文本,则会将其追加到带引号的消息占位符。

Warning

即将推出

此 API 即将推出,将来可能会更改。

诊断:ExperimentalTeamsQuotedReplies

add_quote(message_id: str, text: str | None = None) -> Self

参数

名称 说明
message_id
必需

要引用的消息的 ID

text

可选文本,追加到带引号的消息占位符

默认值: None

返回

类型 说明

自链接方法

add_stream_final

添加流信息,使其成为最终流消息。

add_stream_final() -> Self

返回

类型 说明

自链接方法

add_targeted_message_info

添加 targetedMessageInfo 实体,以便进行提示预览。

如果已存在类型 "targetedMessageInfo" 实体,则不会再次添加该实体(每条消息一个提示预览)。

添加实体时,将删除任何 quotedReply 实体和匹配 <quoted messageId="..."/> 的占位符文本,以避免与提示预览冲突。

add_targeted_message_info(message_id: str) -> Self

参数

名称 说明
message_id
必需

目标消息的消息 ID。

返回

类型 说明

自链接方法

add_text

向消息追加文本。

add_text(text: str) -> Self

参数

名称 说明
text
必需

要追加的文本

返回

类型 说明

自链接方法

get_account_mention

按帐户 ID 获取提及实体。

get_account_mention(account_id: str) -> MentionEntity | None

参数

名称 说明
account_id
必需

要搜索的帐户 ID

返回

类型 说明

如果找到提及实体,则为 None;否则为 None

is_recipient_mentioned

检查邮件中是否提到收件人帐户。

is_recipient_mentioned() -> bool

返回

类型 说明

如此 如果提及收件人

prepend_quote

在现有文本之前追加 quotedReply 实体和占位符。 由 reply()/quote()用于上述引号。

Warning

即将推出

此 API 即将推出,将来可能会更改。

诊断:ExperimentalTeamsQuotedReplies

prepend_quote(message_id: str) -> Self

参数

名称 说明
message_id
必需

要引用的消息的 IC3 消息 ID

返回

类型 说明

自链接方法

with_attachment_layout

设置多个附件的布局提示。

with_attachment_layout(attachment_layout: AttachmentLayout) -> Self

参数

名称 说明
attachment_layout
必需

附件布局(列表,轮播)

返回

类型 说明

自链接方法

with_delivery_mode

设置活动的传递模式。

with_delivery_mode(delivery_mode: Literal['normal', 'notification', 'expectReplies', 'ephemeral']) -> Self

参数

名称 说明
delivery_mode
必需

传送模式(正常,通知)

返回

类型 说明

自链接方法

with_recipient

设置收件人。

with_recipient(value: Account, is_targeted: bool | None = None) -> Self

参数

名称 说明
value
必需

收件人帐户

is_targeted

如果为 True,则将其标记为仅对此收件人可见的目标邮件。 如果为 False,则显式清除目标。 如果为 None(默认值),则现有is_targeted值保持不变。

默认值: None

返回

类型 说明

自链接方法

with_suggested_actions

设置活动的建议操作。

with_suggested_actions(suggested_actions: SuggestedActions) -> Self

参数

名称 说明
suggested_actions
必需

建议操作

返回

类型 说明

自链接方法

with_summary

如果通道无法呈现卡片,请设置要显示的文本。

with_summary(summary: str) -> Self

参数

名称 说明
summary
必需

摘要文本

返回

类型 说明

自链接方法

with_text

设置邮件的文本内容。

with_text(text: str) -> Self

参数

名称 说明
text
必需

要设置的文本

返回

类型 说明

自链接方法

with_text_format

设置文本字段的格式。

with_text_format(text_format: Literal['markdown', 'plain', 'xml']) -> Self

参数

名称 说明
text_format
必需

文本格式(markdown、plain、xml)

返回

类型 说明

自链接方法

属性

model_config

模型的配置应为符合 [ConfigDict][pydantic.config的字典。ConfigDict]。

model_config: ClassVar[ConfigDict] = {'alias_generator': AliasGenerator(alias=None, validation_alias=<staticmethod(<function CustomBaseModel.validation_alias_generator>)>, serialization_alias=<staticmethod(<function CustomBaseModel.serialization_alias_generator>)>), 'arbitrary_types_allowed': True, 'extra': 'allow', 'populate_by_name': True, 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}