Skip to main content
Glama

pin_message

Pin important messages in Telegram chats to keep them visible at the top of the conversation. Specify chat and message IDs to organize discussions and highlight key information.

Instructions

Pin a message in a chat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chat_idYes
message_idYes
disable_notificationNo

Implementation Reference

  • Implementation of the pin_message tool, which pins a message in a specified chat using the aiogram bot instance.
    async def pin_message(
        chat_id: int,
        message_id: int,
        disable_notification: bool = False,
    ) -> OkResult:
        """Pin a message in a chat."""
        if not ctx.is_chat_allowed(chat_id):
            result = OkResult(ok=False, error=f"Chat {chat_id} is not allowed.")
            if ctx.audit_logger:
                ctx.audit_logger.log(
                    "pin_message",
                    {"chat_id": chat_id, "message_id": message_id},
                    result.ok,
                    result.error,
                )
            return result
    
        try:
            if ctx.rate_limiter:
                await ctx.rate_limiter.acquire()
            await ctx.bot.pin_chat_message(
                chat_id=chat_id,
                message_id=message_id,
                disable_notification=disable_notification,
            )
            result = OkResult(ok=True)
        except (TelegramBadRequest, TelegramForbiddenError) as exc:
            result = OkResult(ok=False, error=str(exc))
    
        if ctx.audit_logger:
            ctx.audit_logger.log(
                "pin_message",
                {"chat_id": chat_id, "message_id": message_id},

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Py2755/aiogram-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server