简体   繁体   English

如何使用 Python 的 SDK 框架在 MS Teams 中发送代码片段?

[英]How do I send code snippets in MS Teams using Python's SDK framework?

I can't seem to find a way to send code snippets using Python's SDK module.我似乎找不到使用 Python 的 SDK 模块发送代码片段的方法。 This is what I'm referring to .这就是我指的

I tried using three backsticks ``` and <codeblock> tags, but these are regular code blocks and not snippet codes.我尝试使用三个 backsticks ```<codeblock>标签,但这些是常规代码块而不是片段代码。

code_snippet = Activity(
    type=ActivityTypes.message,
    text=f'```python\n{out}\n```',
)
await turn_context.send_activity(code_snippet)

Any help would be greatly appreciated!任何帮助将不胜感激!

The TextFormat property of a message can be used to specify the format of the text.消息的 TextFormat 属性可用于指定文本的格式。 The TextFormat property can be set to plain, markdown, or xml. The default value for TextFormat is markdown. TextFormat 属性可以设置为 plain、markdown 或 xml。TextFormat 的默认值为 markdown。

Example:例子:

IMessageActivity message =  Activity.CreateMessageActivity();
message.Text = "Hello!";
message.TextFormat = "plain";
message.Locale = "en-Us";

Ref Doc: https://learn.microsoft.com/en-us/previous-versions/azure/bot-service/do.net/bot-builder-do.net-create-messages?view=azure-bot-service-3.0#customizing-a-message参考文档: https://learn.microsoft.com/en-us/previous-versions/azure/bot-service/do.net/bot-builder-do.net-create-messages?view=azure-bot-service -3.0#customizing-a-消息

There is no any text format available for code snippets.没有可用于代码片段的任何文本格式。

If you wish you can suggest this feature here: Microsoft Teams Community如果您愿意,可以在此处推荐此功能: Microsoft Teams Community

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 python 向 ms 团队中的特定用户发送直接消息? - How to send direct message to specific user in ms teams using python? 使用适用于 Python 的 Bot Framework SDK v4 初始化并向 Microsoft Teams 频道发送消息 - Initial and send a message to a Microsoft Teams channel using Bot Framework SDK v4 for Python 如何修改模型字段,然后使用Python / Django中的Rest框架将其发送? - How do I modify a model field and then send it using the Rest Framework in Python/Django? Python 发帖给 ms teams - Python post to ms teams 如何使用Python获取Google搜索代码段? - How can I get the google search snippets using Python? 如何使用现有代码将 Python 中开发的聊天机器人集成到 Microsoft 团队 - how to integrate chatbot developed in Python to Microsoft teams using existing code 使用 Python 向 Microsoft Teams 发送自动消息 - Send automated messages to Microsoft Teams using Python 如何使用 Python 的“MIME 处理包”发送电子邮件? - How do I send an email using Python's "MIME handling package"? 如何将代码段添加到python docstring(而不是doctest)? - How to add code snippets to python docstring (not as doctest)? 如何使用服务主体和 Python SDK 对 Azure 进行身份验证? - How do I authenticate to Azure using a Service Principal and the Python SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM