2015-06-26 06:26:24 +02:00
|
|
|
package tgbotapi
|
|
|
|
|
|
|
|
import (
|
2016-11-25 06:50:35 +01:00
|
|
|
"log"
|
2015-06-26 06:26:24 +02:00
|
|
|
"net/url"
|
|
|
|
)
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewMessage creates a new Message.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, text is the message text.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewMessage(chatID int64, text string) MessageConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return MessageConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseChat: BaseChat{
|
|
|
|
ChatID: chatID,
|
|
|
|
ReplyToMessageID: 0,
|
|
|
|
},
|
|
|
|
Text: text,
|
2015-06-26 06:26:24 +02:00
|
|
|
DisableWebPagePreview: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-22 17:03:00 +02:00
|
|
|
// NewMessageToChannel creates a new Message that is sent to a channel
|
|
|
|
// by username.
|
2016-11-25 06:50:35 +01:00
|
|
|
//
|
2016-04-22 17:03:00 +02:00
|
|
|
// username is the username of the channel, text is the message text.
|
|
|
|
func NewMessageToChannel(username string, text string) MessageConfig {
|
|
|
|
return MessageConfig{
|
|
|
|
BaseChat: BaseChat{
|
|
|
|
ChannelUsername: username,
|
|
|
|
},
|
|
|
|
Text: text,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewForward creates a new forward.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, fromChatID is the source chat,
|
|
|
|
// and messageID is the ID of the original message.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return ForwardConfig{
|
2015-11-20 15:31:01 +01:00
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
2015-06-26 08:53:20 +02:00
|
|
|
FromChatID: fromChatID,
|
|
|
|
MessageID: messageID,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewPhotoUpload creates a new photo uploader.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, file is a string path to the file,
|
|
|
|
// FileReader, or FileBytes.
|
2016-01-08 16:16:47 +01:00
|
|
|
//
|
|
|
|
// Note that you must send animated GIFs as a document.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return PhotoConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
File: file,
|
|
|
|
UseExisting: false,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewPhotoShare shares an existing photo.
|
2015-06-26 08:10:53 +02:00
|
|
|
// You may use this to reshare an existing photo without reuploading it.
|
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, fileID is the ID of the file
|
|
|
|
// already uploaded.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewPhotoShare(chatID int64, fileID string) PhotoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return PhotoConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
FileID: fileID,
|
|
|
|
UseExisting: true,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewAudioUpload creates a new audio uploader.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, file is a string path to the file,
|
|
|
|
// FileReader, or FileBytes.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewAudioUpload(chatID int64, file interface{}) AudioConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return AudioConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
File: file,
|
|
|
|
UseExisting: false,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewAudioShare shares an existing audio file.
|
2016-01-03 23:54:24 +01:00
|
|
|
// You may use this to reshare an existing audio file without
|
|
|
|
// reuploading it.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, fileID is the ID of the audio
|
|
|
|
// already uploaded.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewAudioShare(chatID int64, fileID string) AudioConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return AudioConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
FileID: fileID,
|
|
|
|
UseExisting: true,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewDocumentUpload creates a new document uploader.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, file is a string path to the file,
|
|
|
|
// FileReader, or FileBytes.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return DocumentConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
File: file,
|
|
|
|
UseExisting: false,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewDocumentShare shares an existing document.
|
2016-01-03 23:54:24 +01:00
|
|
|
// You may use this to reshare an existing document without
|
|
|
|
// reuploading it.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, fileID is the ID of the document
|
|
|
|
// already uploaded.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewDocumentShare(chatID int64, fileID string) DocumentConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return DocumentConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
FileID: fileID,
|
|
|
|
UseExisting: true,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewStickerUpload creates a new sticker uploader.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, file is a string path to the file,
|
|
|
|
// FileReader, or FileBytes.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewStickerUpload(chatID int64, file interface{}) StickerConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return StickerConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
File: file,
|
|
|
|
UseExisting: false,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewStickerShare shares an existing sticker.
|
2016-01-03 23:54:24 +01:00
|
|
|
// You may use this to reshare an existing sticker without
|
|
|
|
// reuploading it.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, fileID is the ID of the sticker
|
|
|
|
// already uploaded.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewStickerShare(chatID int64, fileID string) StickerConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return StickerConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
FileID: fileID,
|
|
|
|
UseExisting: true,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewVideoUpload creates a new video uploader.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, file is a string path to the file,
|
|
|
|
// FileReader, or FileBytes.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewVideoUpload(chatID int64, file interface{}) VideoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return VideoConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
File: file,
|
|
|
|
UseExisting: false,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewVideoShare shares an existing video.
|
2015-06-26 08:10:53 +02:00
|
|
|
// You may use this to reshare an existing video without reuploading it.
|
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, fileID is the ID of the video
|
|
|
|
// already uploaded.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewVideoShare(chatID int64, fileID string) VideoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return VideoConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
FileID: fileID,
|
|
|
|
UseExisting: true,
|
|
|
|
},
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-18 03:40:42 +02:00
|
|
|
// NewVoiceUpload creates a new voice uploader.
|
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, file is a string path to the file,
|
|
|
|
// FileReader, or FileBytes.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig {
|
2015-08-18 03:40:42 +02:00
|
|
|
return VoiceConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
File: file,
|
|
|
|
UseExisting: false,
|
|
|
|
},
|
2015-08-18 03:40:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewVoiceShare shares an existing voice.
|
|
|
|
// You may use this to reshare an existing voice without reuploading it.
|
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, fileID is the ID of the video
|
|
|
|
// already uploaded.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewVoiceShare(chatID int64, fileID string) VoiceConfig {
|
2015-08-18 03:40:42 +02:00
|
|
|
return VoiceConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseFile: BaseFile{
|
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
|
|
|
FileID: fileID,
|
|
|
|
UseExisting: true,
|
|
|
|
},
|
2015-08-18 03:40:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-13 15:22:58 +02:00
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewLocation shares your location.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, latitude and longitude are coordinates.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return LocationConfig{
|
2016-01-03 23:54:24 +01:00
|
|
|
BaseChat: BaseChat{
|
2016-04-13 15:22:58 +02:00
|
|
|
ChatID: chatID,
|
|
|
|
},
|
|
|
|
Latitude: latitude,
|
|
|
|
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,
|
2016-01-03 23:54:24 +01:00
|
|
|
},
|
2016-04-13 15:22:58 +02:00
|
|
|
Title: title,
|
|
|
|
Address: address,
|
2015-11-20 16:30:50 +01:00
|
|
|
Latitude: latitude,
|
|
|
|
Longitude: longitude,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewChatAction sets a chat action.
|
2015-06-26 08:10:53 +02:00
|
|
|
// Actions last for 5 seconds, or until your next action.
|
|
|
|
//
|
2016-01-03 23:54:24 +01:00
|
|
|
// chatID is where to send it, action should be set via Chat constants.
|
2016-03-24 19:22:40 +01:00
|
|
|
func NewChatAction(chatID int64, action string) ChatActionConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return ChatActionConfig{
|
2015-11-20 15:08:53 +01:00
|
|
|
BaseChat: BaseChat{ChatID: chatID},
|
2015-11-20 15:31:01 +01:00
|
|
|
Action: action,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewUserProfilePhotos gets user profile photos.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// userID is the ID of the user you wish to get profile photos from.
|
|
|
|
func NewUserProfilePhotos(userID int) UserProfilePhotosConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return UserProfilePhotosConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
UserID: userID,
|
2015-06-26 06:26:24 +02:00
|
|
|
Offset: 0,
|
|
|
|
Limit: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewUpdate gets updates since the last Offset.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// offset is the last Update ID to include.
|
|
|
|
// You likely want to set this to the last Update ID plus 1.
|
2015-06-26 06:26:24 +02:00
|
|
|
func NewUpdate(offset int) UpdateConfig {
|
|
|
|
return UpdateConfig{
|
|
|
|
Offset: offset,
|
|
|
|
Limit: 0,
|
|
|
|
Timeout: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewWebhook creates a new webhook.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
|
|
|
// link is the url parsable link you wish to get the updates.
|
2015-06-26 06:26:24 +02:00
|
|
|
func NewWebhook(link string) WebhookConfig {
|
|
|
|
u, _ := url.Parse(link)
|
|
|
|
|
|
|
|
return WebhookConfig{
|
2015-11-21 12:26:39 +01:00
|
|
|
URL: u,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
2015-09-07 18:44:29 +02:00
|
|
|
|
2015-09-07 19:47:31 +02:00
|
|
|
// NewWebhookWithCert creates a new webhook with a certificate.
|
2015-09-07 18:44:29 +02:00
|
|
|
//
|
|
|
|
// link is the url you wish to get webhooks,
|
2016-01-03 23:54:24 +01:00
|
|
|
// file contains a string to a file, FileReader, or FileBytes.
|
2015-09-07 18:44:29 +02:00
|
|
|
func NewWebhookWithCert(link string, file interface{}) WebhookConfig {
|
|
|
|
u, _ := url.Parse(link)
|
|
|
|
|
|
|
|
return WebhookConfig{
|
|
|
|
URL: u,
|
|
|
|
Certificate: file,
|
|
|
|
}
|
|
|
|
}
|
2016-01-18 07:06:48 +01:00
|
|
|
|
|
|
|
// NewInlineQueryResultArticle creates a new inline query article.
|
2016-06-02 22:41:55 +02:00
|
|
|
func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle {
|
2016-01-18 07:06:48 +01:00
|
|
|
return InlineQueryResultArticle{
|
2016-04-12 15:56:05 +02:00
|
|
|
Type: "article",
|
|
|
|
ID: id,
|
|
|
|
Title: title,
|
|
|
|
InputMessageContent: InputTextMessageContent{
|
|
|
|
Text: messageText,
|
2016-06-02 22:41:55 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultArticleMarkdown creates a new inline query article with Markdown parsing.
|
|
|
|
func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle {
|
|
|
|
return InlineQueryResultArticle{
|
|
|
|
Type: "article",
|
|
|
|
ID: id,
|
|
|
|
Title: title,
|
|
|
|
InputMessageContent: InputTextMessageContent{
|
2016-06-02 22:57:39 +02:00
|
|
|
Text: messageText,
|
2016-06-02 22:41:55 +02:00
|
|
|
ParseMode: "Markdown",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultArticleHTML creates a new inline query article with HTML parsing.
|
|
|
|
func NewInlineQueryResultArticleHTML(id, title, messageText string) InlineQueryResultArticle {
|
|
|
|
return InlineQueryResultArticle{
|
|
|
|
Type: "article",
|
|
|
|
ID: id,
|
|
|
|
Title: title,
|
|
|
|
InputMessageContent: InputTextMessageContent{
|
2016-06-02 22:57:39 +02:00
|
|
|
Text: messageText,
|
2016-06-02 22:41:55 +02:00
|
|
|
ParseMode: "HTML",
|
2016-04-12 15:56:05 +02:00
|
|
|
},
|
2016-01-18 07:06:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultGIF creates a new inline query GIF.
|
|
|
|
func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF {
|
|
|
|
return InlineQueryResultGIF{
|
|
|
|
Type: "gif",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
|
|
|
|
func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
|
|
|
|
return InlineQueryResultMPEG4GIF{
|
|
|
|
Type: "mpeg4_gif",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultPhoto creates a new inline query photo.
|
|
|
|
func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto {
|
|
|
|
return InlineQueryResultPhoto{
|
|
|
|
Type: "photo",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-26 20:44:48 +02:00
|
|
|
// NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
|
|
|
|
func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto {
|
|
|
|
return InlineQueryResultPhoto{
|
|
|
|
Type: "photo",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
ThumbURL: thumb,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-18 07:06:48 +01:00
|
|
|
// NewInlineQueryResultVideo creates a new inline query video.
|
|
|
|
func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
|
|
|
|
return InlineQueryResultVideo{
|
|
|
|
Type: "video",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
}
|
|
|
|
}
|
2016-04-13 16:01:46 +02:00
|
|
|
|
2016-04-14 21:00:45 +02:00
|
|
|
// NewInlineQueryResultAudio creates a new inline query audio.
|
|
|
|
func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
|
|
|
|
return InlineQueryResultAudio{
|
|
|
|
Type: "audio",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
Title: title,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultVoice creates a new inline query voice.
|
|
|
|
func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
|
|
|
|
return InlineQueryResultVoice{
|
|
|
|
Type: "voice",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
Title: title,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultDocument creates a new inline query document.
|
|
|
|
func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
|
|
|
|
return InlineQueryResultDocument{
|
|
|
|
Type: "document",
|
|
|
|
ID: id,
|
|
|
|
URL: url,
|
|
|
|
Title: title,
|
|
|
|
MimeType: mimeType,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineQueryResultLocation creates a new inline query location.
|
|
|
|
func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
|
|
|
|
return InlineQueryResultLocation{
|
|
|
|
Type: "location",
|
|
|
|
ID: id,
|
|
|
|
Title: title,
|
|
|
|
Latitude: latitude,
|
|
|
|
Longitude: longitude,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-13 16:01:46 +02:00
|
|
|
// NewEditMessageText allows you to edit the text of a message.
|
|
|
|
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
|
|
|
|
return EditMessageTextConfig{
|
|
|
|
BaseEdit: BaseEdit{
|
|
|
|
ChatID: chatID,
|
|
|
|
MessageID: messageID,
|
|
|
|
},
|
|
|
|
Text: text,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewEditMessageCaption allows you to edit the caption of a message.
|
|
|
|
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
|
|
|
|
return EditMessageCaptionConfig{
|
|
|
|
BaseEdit: BaseEdit{
|
|
|
|
ChatID: chatID,
|
|
|
|
MessageID: messageID,
|
|
|
|
},
|
|
|
|
Caption: caption,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewEditMessageReplyMarkup allows you to edit the inline
|
|
|
|
// keyboard markup.
|
|
|
|
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
|
|
|
|
return EditMessageReplyMarkupConfig{
|
|
|
|
BaseEdit: BaseEdit{
|
2016-04-21 09:40:12 +02:00
|
|
|
ChatID: chatID,
|
|
|
|
MessageID: messageID,
|
2016-04-19 09:19:36 +02:00
|
|
|
ReplyMarkup: &replyMarkup,
|
2016-04-13 16:01:46 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 22:59:28 +02:00
|
|
|
|
|
|
|
// NewHideKeyboard hides the keyboard, with the option for being selective
|
|
|
|
// or hiding for everyone.
|
|
|
|
func NewHideKeyboard(selective bool) ReplyKeyboardHide {
|
2016-11-25 06:50:35 +01:00
|
|
|
log.Println("NewHideKeyboard is deprecated, please use NewRemoveKeyboard")
|
|
|
|
|
2016-04-14 22:59:28 +02:00
|
|
|
return ReplyKeyboardHide{
|
|
|
|
HideKeyboard: true,
|
|
|
|
Selective: selective,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-25 06:50:35 +01:00
|
|
|
// NewRemoveKeyboard hides the keyboard, with the option for being selective
|
|
|
|
// or hiding for everyone.
|
|
|
|
func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
|
|
|
|
return ReplyKeyboardRemove{
|
|
|
|
RemoveKeyboard: true,
|
|
|
|
Selective: selective,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-14 22:59:28 +02:00
|
|
|
// NewKeyboardButton creates a regular keyboard button.
|
|
|
|
func NewKeyboardButton(text string) KeyboardButton {
|
|
|
|
return KeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewKeyboardButtonContact creates a keyboard button that requests
|
|
|
|
// user contact information upon click.
|
|
|
|
func NewKeyboardButtonContact(text string) KeyboardButton {
|
|
|
|
return KeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
RequestContact: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewKeyboardButtonLocation creates a keyboard button that requests
|
|
|
|
// user location information upon click.
|
|
|
|
func NewKeyboardButtonLocation(text string) KeyboardButton {
|
|
|
|
return KeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
RequestLocation: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewKeyboardButtonRow creates a row of keyboard buttons.
|
|
|
|
func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
|
|
|
|
var row []KeyboardButton
|
|
|
|
|
2016-04-21 09:40:12 +02:00
|
|
|
row = append(row, buttons...)
|
2016-04-14 22:59:28 +02:00
|
|
|
|
|
|
|
return row
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewReplyKeyboard creates a new regular keyboard with sane defaults.
|
|
|
|
func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
|
|
|
|
var keyboard [][]KeyboardButton
|
|
|
|
|
2016-04-21 09:40:12 +02:00
|
|
|
keyboard = append(keyboard, rows...)
|
2016-04-14 22:59:28 +02:00
|
|
|
|
|
|
|
return ReplyKeyboardMarkup{
|
|
|
|
ResizeKeyboard: true,
|
|
|
|
Keyboard: keyboard,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineKeyboardButtonData creates an inline keyboard button with text
|
|
|
|
// and data for a callback.
|
|
|
|
func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
|
|
|
|
return InlineKeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
CallbackData: &data,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineKeyboardButtonURL creates an inline keyboard button with text
|
|
|
|
// which goes to a URL.
|
|
|
|
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
|
|
|
|
return InlineKeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
URL: &url,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineKeyboardButtonSwitch creates an inline keyboard button with
|
|
|
|
// text which allows the user to switch to a chat or return to a chat.
|
|
|
|
func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
|
|
|
|
return InlineKeyboardButton{
|
|
|
|
Text: text,
|
|
|
|
SwitchInlineQuery: &sw,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineKeyboardRow creates an inline keyboard row with buttons.
|
|
|
|
func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
|
|
|
|
var row []InlineKeyboardButton
|
|
|
|
|
2016-04-21 09:40:12 +02:00
|
|
|
row = append(row, buttons...)
|
2016-04-14 22:59:28 +02:00
|
|
|
|
|
|
|
return row
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewInlineKeyboardMarkup creates a new inline keyboard.
|
|
|
|
func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
|
|
|
|
var keyboard [][]InlineKeyboardButton
|
|
|
|
|
2016-04-21 09:40:12 +02:00
|
|
|
keyboard = append(keyboard, rows...)
|
2016-04-14 22:59:28 +02:00
|
|
|
|
|
|
|
return InlineKeyboardMarkup{
|
|
|
|
InlineKeyboard: keyboard,
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 23:30:41 +02:00
|
|
|
|
|
|
|
// NewCallback creates a new callback message.
|
|
|
|
func NewCallback(id, text string) CallbackConfig {
|
|
|
|
return CallbackConfig{
|
|
|
|
CallbackQueryID: id,
|
|
|
|
Text: text,
|
|
|
|
ShowAlert: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewCallbackWithAlert creates a new callback message that alerts
|
|
|
|
// the user.
|
|
|
|
func NewCallbackWithAlert(id, text string) CallbackConfig {
|
|
|
|
return CallbackConfig{
|
|
|
|
CallbackQueryID: id,
|
|
|
|
Text: text,
|
|
|
|
ShowAlert: true,
|
|
|
|
}
|
|
|
|
}
|