2022-04-26 00:02:51 +08:00
|
|
|
package models
|
|
|
|
|
2024-01-10 20:16:04 +08:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
2024-05-22 22:14:55 +08:00
|
|
|
"fmt"
|
2024-01-10 20:16:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// MaybeInaccessibleMessageType https://core.telegram.org/bots/api#maybeinaccessiblemessage
|
|
|
|
type MaybeInaccessibleMessageType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
MaybeInaccessibleMessageTypeMessage MaybeInaccessibleMessageType = iota
|
|
|
|
MaybeInaccessibleMessageTypeInaccessibleMessage
|
|
|
|
)
|
|
|
|
|
|
|
|
// MaybeInaccessibleMessage https://core.telegram.org/bots/api#maybeinaccessiblemessage
|
|
|
|
type MaybeInaccessibleMessage struct {
|
|
|
|
Type MaybeInaccessibleMessageType
|
|
|
|
|
|
|
|
Message *Message
|
|
|
|
InaccessibleMessage *InaccessibleMessage
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mim *MaybeInaccessibleMessage) UnmarshalJSON(data []byte) error {
|
|
|
|
v := struct {
|
|
|
|
Date int `json:"date"`
|
|
|
|
}{}
|
|
|
|
err := json.Unmarshal(data, &v)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.Date == 0 {
|
|
|
|
mim.Type = MaybeInaccessibleMessageTypeInaccessibleMessage
|
|
|
|
mim.InaccessibleMessage = &InaccessibleMessage{}
|
|
|
|
return json.Unmarshal(data, mim.InaccessibleMessage)
|
|
|
|
}
|
|
|
|
|
|
|
|
mim.Type = MaybeInaccessibleMessageTypeMessage
|
|
|
|
mim.Message = &Message{}
|
|
|
|
return json.Unmarshal(data, mim.Message)
|
|
|
|
}
|
|
|
|
|
2024-05-22 22:14:55 +08:00
|
|
|
func (mim *MaybeInaccessibleMessage) MarshalJSON() ([]byte, error) {
|
|
|
|
switch mim.Type {
|
|
|
|
case MaybeInaccessibleMessageTypeMessage:
|
|
|
|
return json.Marshal(mim.Message)
|
|
|
|
case MaybeInaccessibleMessageTypeInaccessibleMessage:
|
|
|
|
return json.Marshal(mim.InaccessibleMessage)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("unsupported MaybeInaccessibleMessage type")
|
|
|
|
}
|
|
|
|
|
2024-01-10 20:16:04 +08:00
|
|
|
// InaccessibleMessage https://core.telegram.org/bots/api#inaccessiblemessage
|
|
|
|
type InaccessibleMessage struct {
|
|
|
|
Chat Chat `json:"chat"`
|
|
|
|
MessageID int `json:"message_id"`
|
|
|
|
Date int `json:"date"`
|
|
|
|
}
|
|
|
|
|
2022-04-26 00:02:51 +08:00
|
|
|
type MessageID struct {
|
|
|
|
ID int `json:"message_id"`
|
|
|
|
}
|
|
|
|
|
2022-04-29 17:21:42 +08:00
|
|
|
// MessageAutoDeleteTimerChanged https://core.telegram.org/bots/api#messageautodeletetimerchanged
|
|
|
|
type MessageAutoDeleteTimerChanged struct {
|
|
|
|
MessageAutoDeleteTime int `json:"message_auto_delete_time"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Message https://core.telegram.org/bots/api#message
|
2022-04-26 00:02:51 +08:00
|
|
|
type Message struct {
|
2022-04-29 17:21:42 +08:00
|
|
|
ID int `json:"message_id"`
|
2022-11-06 00:31:41 +08:00
|
|
|
MessageThreadID int `json:"message_thread_id,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
From *User `json:"from,omitempty"`
|
|
|
|
SenderChat *Chat `json:"sender_chat,omitempty"`
|
2024-02-19 16:56:20 +08:00
|
|
|
SenderBoostCount int `json:"sender_boost_count,omitempty"`
|
2024-04-02 23:09:36 +08:00
|
|
|
SenderBusinessBot *User `json:"sender_business_bot,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
Date int `json:"date"`
|
2024-04-02 23:09:36 +08:00
|
|
|
BusinessConnectionID string `json:"business_connection_id,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
Chat Chat `json:"chat"`
|
2024-01-10 20:16:04 +08:00
|
|
|
ForwardOrigin *MessageOrigin `json:"forward_origin,omitempty"`
|
2022-11-06 00:31:41 +08:00
|
|
|
IsTopicMessage bool `json:"is_topic_message,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
IsAutomaticForward bool `json:"is_automatic_forward,omitempty"`
|
|
|
|
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
|
2024-01-10 20:16:04 +08:00
|
|
|
ExternalReply *ExternalReplyInfo `json:"external_reply,omitempty"`
|
|
|
|
Quote *TextQuote `json:"quote,omitempty"`
|
2024-02-19 16:56:20 +08:00
|
|
|
ReplyToStore *Story `json:"reply_to_store,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
ViaBot *User `json:"via_bot,omitempty"`
|
|
|
|
EditDate int `json:"edit_date,omitempty"`
|
|
|
|
HasProtectedContent bool `json:"has_protected_content,omitempty"`
|
2024-04-02 23:09:36 +08:00
|
|
|
IsFromOffline bool `json:"is_from_offline,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
MediaGroupID string `json:"media_group_id,omitempty"`
|
|
|
|
AuthorSignature string `json:"author_signature,omitempty"`
|
|
|
|
Text string `json:"text,omitempty"`
|
|
|
|
Entities []MessageEntity `json:"entities,omitempty"`
|
2024-01-10 20:16:04 +08:00
|
|
|
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
|
2024-05-29 19:08:43 +08:00
|
|
|
EffectID string `json:"effect_id,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
Animation *Animation `json:"animation,omitempty"`
|
|
|
|
Audio *Audio `json:"audio,omitempty"`
|
|
|
|
Document *Document `json:"document,omitempty"`
|
2024-07-18 22:37:31 +08:00
|
|
|
PaidMedia *PaidMediaInfo `json:"paid_media,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
Photo []PhotoSize `json:"photo,omitempty"`
|
|
|
|
Sticker *Sticker `json:"sticker,omitempty"`
|
2023-08-24 16:29:23 +08:00
|
|
|
Story *Story `json:"story,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
Video *Video `json:"video,omitempty"`
|
|
|
|
VideoNote *VideoNote `json:"video_note,omitempty"`
|
|
|
|
Voice *Voice `json:"voice,omitempty"`
|
|
|
|
Caption string `json:"caption,omitempty"`
|
|
|
|
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
2024-05-29 19:08:43 +08:00
|
|
|
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
|
2023-01-10 16:18:24 +08:00
|
|
|
HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
Contact *Contact `json:"contact,omitempty"`
|
|
|
|
Dice *Dice `json:"dice,omitempty"`
|
|
|
|
Game *Game `json:"game,omitempty"`
|
|
|
|
Poll *Poll `json:"poll,omitempty"`
|
|
|
|
Venue *Venue `json:"venue,omitempty"`
|
|
|
|
Location *Location `json:"location,omitempty"`
|
|
|
|
NewChatMembers []User `json:"new_chat_members,omitempty"`
|
|
|
|
LeftChatMember *User `json:"left_chat_member,omitempty"`
|
|
|
|
NewChatTitle string `json:"new_chat_title,omitempty"`
|
|
|
|
NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
|
|
|
|
DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
|
|
|
|
GroupChatCreated bool `json:"group_chat_created,omitempty"`
|
|
|
|
SupergroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
|
|
|
|
ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
|
|
|
|
MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed,omitempty"`
|
2023-01-13 22:18:22 +08:00
|
|
|
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
|
|
|
|
MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
|
2024-01-10 20:16:04 +08:00
|
|
|
PinnedMessage MaybeInaccessibleMessage `json:"pinned_message,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
Invoice *Invoice `json:"invoice,omitempty"`
|
|
|
|
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
|
2024-07-18 22:37:31 +08:00
|
|
|
RefundedPayment *RefundedPayment `json:"refunded_payment,omitempty"`
|
2024-01-10 20:16:04 +08:00
|
|
|
UsersShared *UsersShared `json:"users_shared,omitempty"`
|
2023-02-06 15:54:44 +08:00
|
|
|
ChatShared *ChatShared `json:"chat_shared,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
ConnectedWebsite string `json:"connected_website,omitempty"`
|
2023-01-10 16:18:24 +08:00
|
|
|
WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
PassportData *PassportData `json:"passport_data,omitempty"`
|
|
|
|
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
|
2024-02-19 16:56:20 +08:00
|
|
|
BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"`
|
2024-05-20 17:07:43 +08:00
|
|
|
ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"`
|
2022-11-06 00:31:41 +08:00
|
|
|
ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"`
|
2023-01-10 16:18:24 +08:00
|
|
|
ForumTopicEdited *ForumTopicEdited `json:"forum_topic_edited,omitempty"`
|
2022-11-06 00:31:41 +08:00
|
|
|
ForumTopicClosed *ForumTopicClosed `json:"forum_topic_closed,omitempty"`
|
|
|
|
ForumTopicReopened *ForumTopicReopened `json:"forum_topic_reopened,omitempty"`
|
2023-01-10 16:18:24 +08:00
|
|
|
GeneralForumTopicHidden *GeneralForumTopicHidden `json:"general_forum_topic_hidden,omitempty"`
|
|
|
|
GeneralForumTopicUnhidden *GeneralForumTopicUnhidden `json:"general_forum_topic_unhidden,omitempty"`
|
2024-01-10 20:16:04 +08:00
|
|
|
GiveawayCreated *GiveawayCreated `json:"giveaway_created,omitempty"`
|
|
|
|
Giveaway *Giveaway `json:"giveaway,omitempty"`
|
|
|
|
GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"`
|
|
|
|
GiveawayCompleted *GiveawayCompleted `json:"giveaway_completed,omitempty"`
|
2022-04-29 17:21:42 +08:00
|
|
|
VoiceChatScheduled *VoiceChatScheduled `json:"voice_chat_scheduled,omitempty"`
|
|
|
|
VoiceChatStarted *VoiceChatStarted `json:"voice_chat_started,omitempty"`
|
|
|
|
VoiceChatEnded *VoiceChatEnded `json:"voice_chat_ended,omitempty"`
|
|
|
|
VoiceChatParticipantsInvited *VoiceChatParticipantsInvited `json:"voice_chat_participants_invited,omitempty"`
|
|
|
|
WebAppData *WebAppData `json:"web_app_data,omitempty"`
|
2023-04-26 15:50:59 +08:00
|
|
|
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
2022-04-26 00:02:51 +08:00
|
|
|
}
|
2024-11-18 16:37:50 +08:00
|
|
|
|
|
|
|
// PreparedInlineMessage https://core.telegram.org/bots/api#preparedinlinemessage
|
|
|
|
type PreparedInlineMessage struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
ExpirationDate int `json:"expiration_date"`
|
|
|
|
}
|