Add helpers, change some items to pointers, add more inline results.
parent
109da1a19f
commit
1ceb22b273
26
helpers.go
26
helpers.go
|
@ -209,6 +209,17 @@ func NewVoiceShare(chatID int64, fileID string) VoiceConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewContact allows you to send a shared contact.
|
||||||
|
func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig {
|
||||||
|
return ContactConfig{
|
||||||
|
BaseChat: BaseChat{
|
||||||
|
ChatID: chatID,
|
||||||
|
},
|
||||||
|
PhoneNumber: phoneNumber,
|
||||||
|
FirstName: firstName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewLocation shares your location.
|
// NewLocation shares your location.
|
||||||
//
|
//
|
||||||
// chatID is where to send it, latitude and longitude are coordinates.
|
// chatID is where to send it, latitude and longitude are coordinates.
|
||||||
|
@ -216,14 +227,25 @@ func NewLocation(chatID int64, latitude float64, longitude float64) LocationConf
|
||||||
return LocationConfig{
|
return LocationConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
ReplyToMessageID: 0,
|
|
||||||
ReplyMarkup: nil,
|
|
||||||
},
|
},
|
||||||
Latitude: latitude,
|
Latitude: latitude,
|
||||||
Longitude: longitude,
|
Longitude: longitude,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewVenue allows you to send a venue and its location.
|
||||||
|
func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig {
|
||||||
|
return VenueConfig{
|
||||||
|
BaseChat: BaseChat{
|
||||||
|
ChatID: chatID,
|
||||||
|
},
|
||||||
|
Title: title,
|
||||||
|
Address: address,
|
||||||
|
Latitude: latitude,
|
||||||
|
Longitude: longitude,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewChatAction sets a chat action.
|
// NewChatAction sets a chat action.
|
||||||
// Actions last for 5 seconds, or until your next action.
|
// Actions last for 5 seconds, or until your next action.
|
||||||
//
|
//
|
||||||
|
|
111
types.go
111
types.go
|
@ -20,10 +20,10 @@ type APIResponse struct {
|
||||||
// Update is an update response, from GetUpdates.
|
// Update is an update response, from GetUpdates.
|
||||||
type Update struct {
|
type Update struct {
|
||||||
UpdateID int `json:"update_id"`
|
UpdateID int `json:"update_id"`
|
||||||
Message Message `json:"message"`
|
Message *Message `json:"message"`
|
||||||
InlineQuery InlineQuery `json:"inline_query"`
|
InlineQuery *InlineQuery `json:"inline_query"`
|
||||||
ChosenInlineResult ChosenInlineResult `json:"chosen_inline_result"`
|
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"`
|
||||||
CallbackQuery CallbackQuery `json:"callback_query"`
|
CallbackQuery *CallbackQuery `json:"callback_query"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// User is a user on Telegram.
|
// User is a user on Telegram.
|
||||||
|
@ -91,28 +91,28 @@ func (c *Chat) IsChannel() bool {
|
||||||
// almost anything.
|
// almost anything.
|
||||||
type Message struct {
|
type Message struct {
|
||||||
MessageID int `json:"message_id"`
|
MessageID int `json:"message_id"`
|
||||||
From User `json:"from"` // optional
|
From *User `json:"from"` // optional
|
||||||
Date int `json:"date"`
|
Date int `json:"date"`
|
||||||
Chat Chat `json:"chat"`
|
Chat *Chat `json:"chat"`
|
||||||
ForwardFrom User `json:"forward_from"` // optional
|
ForwardFrom *User `json:"forward_from"` // optional
|
||||||
ForwardDate int `json:"forward_date"` // optional
|
ForwardDate int `json:"forward_date"` // optional
|
||||||
ReplyToMessage *Message `json:"reply_to_message"` // optional
|
ReplyToMessage *Message `json:"reply_to_message"` // optional
|
||||||
Text string `json:"text"` // optional
|
Text string `json:"text"` // optional
|
||||||
Entities []MessageEntity `json:"entities"` // optional
|
Entities *[]MessageEntity `json:"entities"` // optional
|
||||||
Audio Audio `json:"audio"` // optional
|
Audio *Audio `json:"audio"` // optional
|
||||||
Document Document `json:"document"` // optional
|
Document *Document `json:"document"` // optional
|
||||||
Photo []PhotoSize `json:"photo"` // optional
|
Photo *[]PhotoSize `json:"photo"` // optional
|
||||||
Sticker Sticker `json:"sticker"` // optional
|
Sticker *Sticker `json:"sticker"` // optional
|
||||||
Video Video `json:"video"` // optional
|
Video *Video `json:"video"` // optional
|
||||||
Voice Voice `json:"voice"` // optional
|
Voice *Voice `json:"voice"` // optional
|
||||||
Caption string `json:"caption"` // optional
|
Caption string `json:"caption"` // optional
|
||||||
Contact Contact `json:"contact"` // optional
|
Contact *Contact `json:"contact"` // optional
|
||||||
Location Location `json:"location"` // optional
|
Location *Location `json:"location"` // optional
|
||||||
Venue Venue `json:"venue"` // optional
|
Venue *Venue `json:"venue"` // optional
|
||||||
NewChatMember User `json:"new_chat_member"` // optional
|
NewChatMember *User `json:"new_chat_member"` // optional
|
||||||
LeftChatMember User `json:"left_chat_member"` // optional
|
LeftChatMember *User `json:"left_chat_member"` // optional
|
||||||
NewChatTitle string `json:"new_chat_title"` // optional
|
NewChatTitle string `json:"new_chat_title"` // optional
|
||||||
NewChatPhoto []PhotoSize `json:"new_chat_photo"` // optional
|
NewChatPhoto *[]PhotoSize `json:"new_chat_photo"` // optional
|
||||||
DeleteChatPhoto bool `json:"delete_chat_photo"` // optional
|
DeleteChatPhoto bool `json:"delete_chat_photo"` // optional
|
||||||
GroupChatCreated bool `json:"group_chat_created"` // optional
|
GroupChatCreated bool `json:"group_chat_created"` // optional
|
||||||
SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional
|
SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional
|
||||||
|
@ -200,7 +200,7 @@ type Audio struct {
|
||||||
// Document contains information about a document.
|
// Document contains information about a document.
|
||||||
type Document struct {
|
type Document struct {
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
Thumbnail PhotoSize `json:"thumb"` // optional
|
Thumbnail *PhotoSize `json:"thumb"` // optional
|
||||||
FileName string `json:"file_name"` // optional
|
FileName string `json:"file_name"` // optional
|
||||||
MimeType string `json:"mime_type"` // optional
|
MimeType string `json:"mime_type"` // optional
|
||||||
FileSize int `json:"file_size"` // optional
|
FileSize int `json:"file_size"` // optional
|
||||||
|
@ -211,7 +211,7 @@ type Sticker struct {
|
||||||
FileID string `json:"file_id"`
|
FileID string `json:"file_id"`
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
Thumbnail PhotoSize `json:"thumb"` // optional
|
Thumbnail *PhotoSize `json:"thumb"` // optional
|
||||||
FileSize int `json:"file_size"` // optional
|
FileSize int `json:"file_size"` // optional
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ type Video struct {
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
Duration int `json:"duration"`
|
Duration int `json:"duration"`
|
||||||
Thumbnail PhotoSize `json:"thumb"` // optional
|
Thumbnail *PhotoSize `json:"thumb"` // optional
|
||||||
MimeType string `json:"mime_type"` // optional
|
MimeType string `json:"mime_type"` // optional
|
||||||
FileSize int `json:"file_size"` // optional
|
FileSize int `json:"file_size"` // optional
|
||||||
}
|
}
|
||||||
|
@ -320,8 +320,8 @@ type InlineKeyboardButton struct {
|
||||||
// is clicked.
|
// is clicked.
|
||||||
type CallbackQuery struct {
|
type CallbackQuery struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
From User `json:"from"`
|
From *User `json:"from"`
|
||||||
Message Message `json:"message"` // optional
|
Message *Message `json:"message"` // optional
|
||||||
InlineMessageID string `json:"inline_message_id"` // optional
|
InlineMessageID string `json:"inline_message_id"` // optional
|
||||||
Data string `json:"data"` // optional
|
Data string `json:"data"` // optional
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,8 @@ type ForceReply struct {
|
||||||
// InlineQuery is a Query from Telegram for an inline request.
|
// InlineQuery is a Query from Telegram for an inline request.
|
||||||
type InlineQuery struct {
|
type InlineQuery struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
From User `json:"from"`
|
From *User `json:"from"`
|
||||||
Location Location `json:"location"` // optional
|
Location *Location `json:"location"` // optional
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
Offset string `json:"offset"`
|
Offset string `json:"offset"`
|
||||||
}
|
}
|
||||||
|
@ -418,11 +418,64 @@ type InlineQueryResultVideo struct {
|
||||||
InputMessageContent interface{} `json:"input_message_content"`
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InlineQueryResultAudio is an inline query response audio.
|
||||||
|
type InlineQueryResultAudio struct {
|
||||||
|
Type string `json:"type"` // required
|
||||||
|
ID string `json:"id"` // required
|
||||||
|
URL string `json:"audio_url"` // required
|
||||||
|
Title string `json:"title"` // required
|
||||||
|
Performer string `json:"performer"`
|
||||||
|
Duration int `json:"audio_duration"`
|
||||||
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InlineQueryResultVoice is an inline query response voice.
|
||||||
|
type InlineQueryResultVoice struct {
|
||||||
|
Type string `json:"type"` // required
|
||||||
|
ID string `json:"id"` // required
|
||||||
|
URL string `json:"voice_url"` // required
|
||||||
|
Title string `json:"title"` // required
|
||||||
|
Duration int `json:"voice_duration"`
|
||||||
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InlineQueryResultDocument is an inline query response document.
|
||||||
|
type InlineQueryResultDocument struct {
|
||||||
|
Type string `json:"type"` // required
|
||||||
|
ID string `json:"id"` // required
|
||||||
|
Title string `json:"title"` // required
|
||||||
|
Caption string `json:"caption"`
|
||||||
|
URL string `json:"document_url"` // required
|
||||||
|
MimeType string `json:"mime_type"` // required
|
||||||
|
Description string `json:"description"`
|
||||||
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
|
ThumbURL string `json:"thumb_url"`
|
||||||
|
ThumbWidth int `json:"thumb_width"`
|
||||||
|
ThumbHeight int `json:"thumb_height"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InlineQueryResultLocation is an inline query response location.
|
||||||
|
type InlineQueryResultLocation struct {
|
||||||
|
Type string `json:"type"` // required
|
||||||
|
ID string `json:"id"` // required
|
||||||
|
Latitude float64 `json:"latitude"` // required
|
||||||
|
Longitude float64 `json:"longitude"` // required
|
||||||
|
Title string `json:"title"` // required
|
||||||
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup"`
|
||||||
|
InputMessageContent interface{} `json:"input_message_content"`
|
||||||
|
ThumbURL string `json:"thumb_url"`
|
||||||
|
ThumbWidth int `json:"thumb_width"`
|
||||||
|
ThumbHeight int `json:"thumb_height"`
|
||||||
|
}
|
||||||
|
|
||||||
// ChosenInlineResult is an inline query result chosen by a User
|
// ChosenInlineResult is an inline query result chosen by a User
|
||||||
type ChosenInlineResult struct {
|
type ChosenInlineResult struct {
|
||||||
ResultID string `json:"result_id"`
|
ResultID string `json:"result_id"`
|
||||||
From User `json:"from"`
|
From *User `json:"from"`
|
||||||
Location Location `json:"location"`
|
Location *Location `json:"location"`
|
||||||
InlineMessageID string `json:"inline_message_id"`
|
InlineMessageID string `json:"inline_message_id"`
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue