# 固定消息

## 固定消息

在聊天中，固定消息（Pinned Message）是将重要消息固定在聊天房间或群组对话的顶部的功能。这使得参与者每次打开该聊天时都能轻松看到，从而避免错过重要的信息或通知。以下是固定消息的主要特点和使用方法说明。

### 固定消息的使用方法

* 会议日程公告：将定期会议或重要事件的日程设置为固定消息，以确保参与者不会忘记日程。
* 重要文档链接：将重要文档或资料的链接固定，确保所有参与者可以轻松访问。
* 规则与指南共享：将聊天房间的规则或项目指南设置为固定消息，以便新参与者也能轻松查看指南。
* 紧急公告：迅速通过固定消息分享需要紧急传达的内容或变更。

固定消息功能在各种通讯平台上提供，若能有效利用，将显著提高团队沟通的效率。

### 固定消息创建

在聊天应用程序中，固定消息功能允许将重要消息固定在聊天窗口的顶部，以便用户可以轻松查看。以下是使用 C# 代码在聊天频道中固定消息的方法示例：

```csharp
var newPin = await nc.createPin(channelId, messageId, pinned, pinnedAt, expiredAt);
```

* channelId: 消息将被固定的聊天频道的唯一标识符。&#x20;
* pinned: 要固定的消息内容。&#x20;
* pinnedAt: 消息被固定的时间。&#x20;
* expiredAt: 消息固定将被解除的时间。&#x20;

使用此功能可以轻松突出显示在特定聊天频道中的重要消息。

### 修改固定消息

这是一个用于更新已有固定消息信息的功能。您可以更改消息内容、固定时间或过期时间。

```csharp
var updatedPin = await nc.updatePin(id, channelId, pinned, pinnedAt, expiredAt);
```

* channelId: 要修改消息的频道ID。
* pinned: 修改后的消息内容。
* pinnedAt: 消息被重新固定的时间。
* expiredAt: 消息固定的新过期时间。&#x20;

此代码用于更改已固定消息的详细信息，当消息的重要性发生变化或需要调整固定时间时非常有用。

### 固定消息信息

这是一个用于查询特定消息固定相关信息的功能。您可以查看消息的固定状态、固定时间、过期时间等。

```csharp
var pin = await nc.getPin(channelId, messageId);
```

* channelId: 要查询信息的频道ID。
* messageId: 固定消息的唯一标识符

通过此功能，您可以确认特定消息的当前状态，这有助于管理员或用户更有效地管理频道中的消息。

### 固定消息列表

这是一个用于查询聊天频道中当前所有固定消息列表的功能。此功能支持分页，以便在大规模频道中也能高效处理数据。用户可以通过设置 offset 和 per\_page 来获取所需范围的数据。

```csharp
Hashtable filter = new Hashtable
{
    { "channel_id", channelId },
};
Hashtable sort = new Hashtable
{
    { "created_at", -1 },
};
Hashtable option = new Hashtable
{
    { "offset", 0 },
    { "per_page", 10 },
};
var pins = await nc.getPins(channelId, filter, sort, option);
```

#### 参数说明

* filter: 定义用于筛选查询数据的条件。例如，可以在特定频道中查询固定的消息。
* sort: 定义结果列表的排序方式。在这里，使用了按创建时间（created\_at）降序（-1）排序。
* option: 定义查询时使用的选项。offset 是查询的起始位置，per\_page 是每页显示的消息数量。

#### 选项详细信息

<table><thead><tr><th width="149">ID</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td>offset</td><td>number</td><td>这是获取数据的起始位置。</td></tr><tr><td>per_page</td><td>number</td><td>每页返回的消息数量，最多可以设置为100个。</td></tr></tbody></table>

使用此功能，频道管理员可以轻松监控和管理频道中的重要消息。此外，还可以根据特定用户或时间快速搜索和排序固定消息，从而帮助频道实现高效运作。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gamechat.me/basics/game-chat-v3/game-chat-zhong-wen/kai-shi-shi-yong-v3/gu-ding-xiao-xi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
