1
0
telegram/pin_chat_message.go

31 lines
914 B
Go
Raw Normal View History

2017-12-14 07:08:19 +00:00
package telegram
import json "github.com/pquerna/ffjson/ffjson"
2017-12-14 07:08:19 +00:00
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"`
MessageID int `json:"message_id"`
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.
2018-08-21 11:05:04 +00:00
func (bot *Bot) PinChatMessage(params *PinChatMessageParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
2018-08-21 11:05:04 +00:00
return
}
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 {
2018-08-21 11:05:04 +00:00
return
2017-12-14 07:08:19 +00:00
}
2018-08-21 11:05:04 +00:00
err = json.Unmarshal(*resp.Result, &ok)
return
2017-12-14 07:08:19 +00:00
}