1
0
Fork 0
telegram/pin.go

35 lines
1.1 KiB
Go
Raw Normal View History

2017-12-14 07:08:19 +00:00
package telegram
2018-04-19 13:02:15 +00:00
// PinChatMessageParameters represents data for PinChatMessage method.
type PinChatMessageParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
2018-10-12 11:44:27 +00:00
// Identifier of a message to pin
MessageID int `json:"message_id"`
// Pass 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.
DisableNotification bool `json:"disable_notification"`
}
2017-12-14 07:08:19 +00:00
// PinChatMessage pin a message in a supergroup or a channel. The bot must be an administrator in the
// chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or
// 'can_edit_messages' admin right in the channel. Returns True on success.
2019-07-26 10:09:49 +00:00
func (bot *Bot) PinChatMessage(params *PinChatMessageParameters) (bool, error) {
2019-07-24 09:34:55 +00:00
dst, err := parser.Marshal(params)
if err != nil {
2019-07-26 10:09:49 +00:00
return false, err
}
2017-12-14 07:08:19 +00:00
2018-04-12 11:58:05 +00:00
resp, err := bot.request(dst, MethodPinChatMessage)
2017-12-14 07:08:19 +00:00
if err != nil {
2019-07-26 10:09:49 +00:00
return false, err
2017-12-14 07:08:19 +00:00
}
2019-07-26 10:09:49 +00:00
var ok bool
2019-07-24 09:34:55 +00:00
err = parser.Unmarshal(resp.Result, &ok)
2019-07-26 10:09:49 +00:00
return ok, err
2017-12-14 07:08:19 +00:00
}