github.com/fumiama/NanoBot@v0.0.0-20231122134259-c22d8183efca/openapi_pins.go (about)

     1  package nano
     2  
     3  // PinsMessage 精华消息对象
     4  //
     5  // https://bot.q.qq.com/wiki/develop/api/openapi/pins/model.html#pinsmessage
     6  type PinsMessage struct {
     7  	GuildID    string   `json:"guild_id"`
     8  	ChannelID  string   `json:"channel_id"`
     9  	MessageIDs []string `json:"message_ids"`
    10  }
    11  
    12  // PinMessageInChannel 添加子频道 channel_id 内的精华消息
    13  //
    14  // https://bot.q.qq.com/wiki/develop/api/openapi/pins/put_pins_message.html
    15  func (bot *Bot) PinMessageInChannel(channelid, messageid string) (*PinsMessage, error) {
    16  	return bot.putOpenAPIofPinsMessage("/channels/"+channelid+"/pins/"+messageid, nil)
    17  }
    18  
    19  // UnpinMessageInChannel 子频道 channel_id 下指定 message_id 的精华消息
    20  //
    21  // https://bot.q.qq.com/wiki/develop/api/openapi/pins/delete_pins_message.html
    22  //
    23  // 删除子频道内全部精华消息,请将 message_id 设置为 all
    24  func (bot *Bot) UnpinMessageInChannel(channelid, messageid string) error {
    25  	return bot.DeleteOpenAPI("/channels/"+channelid+"/pins/"+messageid, "", nil)
    26  }
    27  
    28  // GetPinMessagesOfChannel 获取子频道 channel_id 内的精华消息
    29  //
    30  // https://bot.q.qq.com/wiki/develop/api/openapi/pins/get_pins_message.html
    31  func (bot *Bot) GetPinMessagesOfChannel(id string) (*PinsMessage, error) {
    32  	return bot.getOpenAPIofPinsMessage("/channels/" + id + "/pins")
    33  }