Add helpers, change some items to pointers, add more inline results.
parent
109da1a19f
commit
1ceb22b273
28
helpers.go
28
helpers.go
|
@ -209,21 +209,43 @@ 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.
|
||||||
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
|
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
|
||||||
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.
|
||||||
//
|
//
|
||||||
|
|
187
types.go
187
types.go
|
@ -19,11 +19,11 @@ 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.
|
||||||
|
@ -90,36 +90,36 @@ func (c *Chat) IsChannel() bool {
|
||||||
// Message is returned by almost every request, and contains data about
|
// Message is returned by almost every request, and contains data about
|
||||||
// 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
|
||||||
ChannelChatCreated bool `json:"channel_chat_created"` // optional
|
ChannelChatCreated bool `json:"channel_chat_created"` // optional
|
||||||
MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
|
MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional
|
||||||
MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional
|
MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional
|
||||||
PinnedMessage *Message `json:"pinned_message"` // optional
|
PinnedMessage *Message `json:"pinned_message"` // optional
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time converts the message timestamp into a Time.
|
// Time converts the message timestamp into a Time.
|
||||||
|
@ -199,31 +199,31 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sticker contains information about a sticker.
|
// Sticker contains information about a sticker.
|
||||||
type Sticker struct {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video contains information about a video.
|
// Video contains information about a video.
|
||||||
type Video struct {
|
type Video 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"`
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// Voice contains information about a voice.
|
// Voice contains information about a voice.
|
||||||
|
@ -319,11 +319,11 @@ type InlineKeyboardButton struct {
|
||||||
// CallbackQuery is data sent when a keyboard button with callback data
|
// CallbackQuery is data sent when a keyboard button with callback data
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForceReply allows the Bot to have users directly reply to it without
|
// ForceReply allows the Bot to have users directly reply to it without
|
||||||
|
@ -335,11 +335,11 @@ 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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InlineQueryResultArticle is an inline query response article.
|
// InlineQueryResultArticle is an inline query response article.
|
||||||
|
@ -418,13 +418,66 @@ 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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InputTextMessageContent contains text for displaying
|
// InputTextMessageContent contains text for displaying
|
||||||
|
|
Loading…
Reference in New Issue