diff --git a/bot_test.go b/bot_test.go index 26c6f9a..cf490c0 100644 --- a/bot_test.go +++ b/bot_test.go @@ -317,7 +317,7 @@ func TestBotProcessUpdate(t *testing.T) { b.ProcessUpdate(Update{Message: &Message{Text: "/start@other_bot"}}) b.ProcessUpdate(Update{Message: &Message{Text: "hello"}}) b.ProcessUpdate(Update{Message: &Message{Text: "text"}}) - b.ProcessUpdate(Update{Message: &Message{PinnedMessage: &InaccessibleMessage{Message: &Message{}}}}) + b.ProcessUpdate(Update{Message: &Message{PinnedMessage: &Message{}}}) b.ProcessUpdate(Update{Message: &Message{Photo: &Photo{}}}) b.ProcessUpdate(Update{Message: &Message{Voice: &Voice{}}}) b.ProcessUpdate(Update{Message: &Message{Audio: &Audio{}}}) @@ -342,7 +342,7 @@ func TestBotProcessUpdate(t *testing.T) { b.ProcessUpdate(Update{Message: &Message{Chat: &Chat{ID: 1}, MigrateTo: 2}}) b.ProcessUpdate(Update{EditedMessage: &Message{Text: "edited"}}) b.ProcessUpdate(Update{ChannelPost: &Message{Text: "post"}}) - b.ProcessUpdate(Update{ChannelPost: &Message{PinnedMessage: &InaccessibleMessage{Message: &Message{}}}}) + b.ProcessUpdate(Update{ChannelPost: &Message{PinnedMessage: &Message{}}}) b.ProcessUpdate(Update{EditedChannelPost: &Message{Text: "edited post"}}) b.ProcessUpdate(Update{Callback: &Callback{MessageID: "inline", Data: "callback"}}) b.ProcessUpdate(Update{Callback: &Callback{Data: "callback"}}) diff --git a/callback.go b/callback.go index e8619f0..bfd8a66 100644 --- a/callback.go +++ b/callback.go @@ -16,7 +16,7 @@ type Callback struct { // Message will be set if the button that originated the query // was attached to a message sent by a bot. - Message *InaccessibleMessage `json:"message"` + Message *Message `json:"message"` // MessageID will be set if the button was attached to a message // sent via the bot in inline mode. diff --git a/context.go b/context.go index df11373..f0ef1ff 100644 --- a/context.go +++ b/context.go @@ -201,12 +201,12 @@ func (c *nativeContext) Message() *Message { case c.u.Message != nil: return c.u.Message case c.u.Callback != nil: - return c.u.Callback.Message.Message + return c.u.Callback.Message case c.u.EditedMessage != nil: return c.u.EditedMessage case c.u.ChannelPost != nil: if c.u.ChannelPost.PinnedMessage != nil { - return c.u.ChannelPost.PinnedMessage.Message + return c.u.ChannelPost.PinnedMessage } return c.u.ChannelPost case c.u.EditedChannelPost != nil: diff --git a/input_types.go b/input_types.go index 8c33096..8e49a7f 100644 --- a/input_types.go +++ b/input_types.go @@ -17,7 +17,7 @@ type InputTextMessageContent struct { ParseMode string `json:"parse_mode,omitempty"` // (Optional) Link preview generation options for the message. - PreviewOptions *PreviewOptions `json:"link_preview_options"` + PreviewOptions *PreviewOptions `json:"link_preview_options,omitempty"` } func (input *InputTextMessageContent) IsInputMessageContent() bool { diff --git a/message.go b/message.go index 13f35a2..f2fc413 100644 --- a/message.go +++ b/message.go @@ -105,9 +105,9 @@ type Message struct { // etc. that appear in the text. Entities Entities `json:"entities,omitempty"` - // (Optional) ReactionOptions used for link preview generation for the message, - // if it is a text message and link preview options were changed - PreviewOptions PreviewOptions `json:"link_preview_options,omitempty"` + // (Optional) PreviewOptions used for link preview generation for the message, + // if it is a text message and link preview options were changed. + PreviewOptions *PreviewOptions `json:"link_preview_options,omitempty"` // Some messages containing media, may as well have a caption. Caption string `json:"caption,omitempty"` @@ -137,7 +137,7 @@ type Message struct { // For a video, information about it. Video *Video `json:"video"` - // For a animation, information about it. + // For an animation, information about it. Animation *Animation `json:"animation"` // For a contact, contact information itself. @@ -255,7 +255,7 @@ type Message struct { // Specified message was pinned. Note that the Message object // in this field will not contain further ReplyTo fields even // if it is itself a reply. - PinnedMessage *InaccessibleMessage `json:"pinned_message"` + PinnedMessage *Message `json:"pinned_message"` // Message is an invoice for a payment. Invoice *Invoice `json:"invoice"` @@ -380,7 +380,7 @@ const ( EntityBlockquote EntityType = "blockquote" ) -// Entities is used to set message's text entities as a send option. +// Entities are used to set message's text entities as a send option. type Entities []MessageEntity // ProximityAlert sent whenever a user in the chat triggers @@ -396,6 +396,11 @@ type AutoDeleteTimer struct { Unixtime int `json:"message_auto_delete_time"` } +// Inaccessible shows whether the message is InaccessibleMessage object. +func (m *Message) Inaccessible() bool { + return m.Sender == nil +} + // MessageSig satisfies Editable interface (see Editable.) func (m *Message) MessageSig() (string, int64) { return strconv.Itoa(m.ID), m.Chat.ID @@ -504,31 +509,6 @@ func (m *Message) Media() Media { } } -// InaccessibleMessage describes a message that was deleted or is otherwise -// inaccessible to the bot. An instance of MaybeInaccessibleMessage object. -type InaccessibleMessage struct { - // A message that can be inaccessible to the bot. - *Message - - // Chat the message belonged to. - Chat *Chat `json:"chat"` - - // Unique message identifier inside the chat. - MessageID int `json:"message_id"` - - // Always 0. The field can be used to differentiate regular and - // inaccessible messages. - DateUnixtime int64 `json:"date"` -} - -func (im *InaccessibleMessage) MessageSig() (string, int64) { - return strconv.Itoa(im.MessageID), im.Chat.ID -} - -func (im *InaccessibleMessage) Time() time.Time { - return time.Unix(im.DateUnixtime, 0) -} - // MessageReaction object represents a change of a reaction on a message performed by a user. type MessageReaction struct { // The chat containing the message the user reacted to.