Available methods

pinChatMessage()

Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success.

parameters

parametertyperequireddescription
business_connection_idstringoptionalUnique identifier of the business connection on behalf of which the message will be pinned
chat_idnumber | stringrequiredUnique identifier for the target chat or username of the target channel in the format @username
message_idnumberrequiredIdentifier of a message to pin
disable_notificationbooleanoptionalPass True if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.

returns

boolean

usage in yaebal

not (yet) hard-typed on Api — call it through the generic .call<T>() escape hatch documented in @yaebal/types.

bot.ts
import type { PinChatMessageParams } from "@yaebal/types";

await bot.api.call<boolean>("pinChatMessage", {
  chat_id: 123456789,
  message_id: 1,
} satisfies PinChatMessageParams);

context shortcut

also available as ctx.pin() on 10 context types — see @yaebal/contexts.

context shortcut
/** Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns *True* on success. */
ctx.pin(params: Omit<PinChatMessageParams, "chat_id" | "message_id">)