2015-06-26 06:26:24 +02:00
|
|
|
package tgbotapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
)
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewMessage creates a new Message.
|
|
|
|
// Perhaps set a ChatAction of ChatTyping while processing.
|
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.
|
|
|
|
func NewMessage(chatID int, text string) MessageConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return MessageConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
Text: text,
|
|
|
|
DisableWebPagePreview: false,
|
2015-06-26 08:53:20 +02:00
|
|
|
ReplyToMessageID: 0,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
func NewForward(chatID int, fromChatID int, messageID int) ForwardConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return ForwardConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
|
|
|
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
|
|
|
// This requires a file on the local filesystem to upload to Telegram.
|
2015-06-26 08:53:20 +02:00
|
|
|
// Perhaps set a ChatAction of ChatUploadPhoto while processing.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-09-07 18:20:43 +02:00
|
|
|
// chatID is where to send it, file is a string path to the file, or FileReader or FileBytes.
|
|
|
|
func NewPhotoUpload(chatID int, file interface{}) PhotoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return PhotoConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingPhoto: false,
|
2015-09-07 18:20:43 +02:00
|
|
|
File: file,
|
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.
|
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, fileID is the ID of the file already uploaded.
|
|
|
|
func NewPhotoShare(chatID int, fileID string) PhotoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return PhotoConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingPhoto: true,
|
2015-06-26 08:53:20 +02:00
|
|
|
FileID: fileID,
|
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
|
|
|
// This requires a file on the local filesystem to upload to Telegram.
|
2015-06-26 08:53:20 +02:00
|
|
|
// Perhaps set a ChatAction of ChatRecordAudio or ChatUploadAudio while processing.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-09-07 18:20:43 +02:00
|
|
|
// chatID is where to send it, file is a string path to the file, or FileReader or FileBytes.
|
|
|
|
func NewAudioUpload(chatID int, file interface{}) AudioConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return AudioConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingAudio: false,
|
2015-09-07 18:20:43 +02:00
|
|
|
File: file,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewAudioShare shares an existing audio file.
|
2015-06-26 08:10:53 +02:00
|
|
|
// You may use this to reshare an existing audio file without reuploading it.
|
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, fileID is the ID of the audio already uploaded.
|
|
|
|
func NewAudioShare(chatID int, fileID string) AudioConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return AudioConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingAudio: true,
|
2015-06-26 08:53:20 +02:00
|
|
|
FileID: fileID,
|
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
|
|
|
// This requires a file on the local filesystem to upload to Telegram.
|
2015-06-26 08:53:20 +02:00
|
|
|
// Perhaps set a ChatAction of ChatUploadDocument while processing.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-09-07 18:20:43 +02:00
|
|
|
// chatID is where to send it, file is a string path to the file, or FileReader or FileBytes.
|
|
|
|
func NewDocumentUpload(chatID int, file interface{}) DocumentConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return DocumentConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingDocument: false,
|
2015-09-07 18:20:43 +02:00
|
|
|
File: file,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewDocumentShare shares an existing document.
|
2015-06-26 08:10:53 +02:00
|
|
|
// You may use this to reshare an existing document without reuploading it.
|
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, fileID is the ID of the document already uploaded.
|
|
|
|
func NewDocumentShare(chatID int, fileID string) DocumentConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return DocumentConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingDocument: true,
|
2015-06-26 08:53:20 +02:00
|
|
|
FileID: fileID,
|
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
|
|
|
// This requires a file on the local filesystem to upload to Telegram.
|
|
|
|
//
|
2015-09-07 18:20:43 +02:00
|
|
|
// chatID is where to send it, file is a string path to the file, or FileReader or FileBytes.
|
|
|
|
func NewStickerUpload(chatID int, file interface{}) StickerConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return StickerConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingSticker: false,
|
2015-09-07 18:20:43 +02:00
|
|
|
File: file,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewStickerShare shares an existing sticker.
|
2015-06-26 08:10:53 +02:00
|
|
|
// You may use this to reshare an existing sticker without reuploading it.
|
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, fileID is the ID of the sticker already uploaded.
|
|
|
|
func NewStickerShare(chatID int, fileID string) StickerConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return StickerConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingSticker: true,
|
2015-06-26 08:53:20 +02:00
|
|
|
FileID: fileID,
|
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
|
|
|
// This requires a file on the local filesystem to upload to Telegram.
|
2015-06-26 08:53:20 +02:00
|
|
|
// Perhaps set a ChatAction of ChatRecordVideo or ChatUploadVideo while processing.
|
2015-06-26 08:10:53 +02:00
|
|
|
//
|
2015-09-07 18:20:43 +02:00
|
|
|
// chatID is where to send it, file is a string path to the file, or FileReader or FileBytes.
|
|
|
|
func NewVideoUpload(chatID int, file interface{}) VideoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return VideoConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingVideo: false,
|
2015-09-07 18:20:43 +02:00
|
|
|
File: file,
|
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.
|
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, fileID is the ID of the video already uploaded.
|
|
|
|
func NewVideoShare(chatID int, fileID string) VideoConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return VideoConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
UseExistingVideo: true,
|
2015-06-26 08:53:20 +02:00
|
|
|
FileID: fileID,
|
2015-06-26 06:26:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-18 03:40:42 +02:00
|
|
|
// NewVoiceUpload creates a new voice uploader.
|
|
|
|
// This requires a file on the local filesystem to upload to Telegram.
|
|
|
|
// Perhaps set a ChatAction of ChatRecordVideo or ChatUploadVideo while processing.
|
|
|
|
//
|
2015-09-07 18:20:43 +02:00
|
|
|
// chatID is where to send it, file is a string path to the file, or FileReader or FileBytes.
|
|
|
|
func NewVoiceUpload(chatID int, file interface{}) VoiceConfig {
|
2015-08-18 03:40:42 +02:00
|
|
|
return VoiceConfig{
|
|
|
|
ChatID: chatID,
|
|
|
|
UseExistingVoice: false,
|
2015-09-07 18:20:43 +02:00
|
|
|
File: file,
|
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.
|
|
|
|
//
|
|
|
|
// chatID is where to send it, fileID is the ID of the video already uploaded.
|
|
|
|
func NewVoiceShare(chatID int, fileID string) VoiceConfig {
|
|
|
|
return VoiceConfig{
|
|
|
|
ChatID: chatID,
|
|
|
|
UseExistingVoice: true,
|
|
|
|
FileID: fileID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 08:53:20 +02:00
|
|
|
// NewLocation shares your location.
|
|
|
|
// Perhaps set a ChatAction of ChatFindLocation while processing.
|
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.
|
|
|
|
func NewLocation(chatID int, latitude float64, longitude float64) LocationConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return LocationConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
Latitude: latitude,
|
|
|
|
Longitude: longitude,
|
2015-06-26 08:53:20 +02:00
|
|
|
ReplyToMessageID: 0,
|
2015-06-26 06:26:24 +02:00
|
|
|
ReplyMarkup: nil,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
//
|
2015-06-26 08:53:20 +02:00
|
|
|
// chatID is where to send it, action should be set via CHAT constants.
|
|
|
|
func NewChatAction(chatID int, action string) ChatActionConfig {
|
2015-06-26 06:26:24 +02:00
|
|
|
return ChatActionConfig{
|
2015-06-26 08:53:20 +02:00
|
|
|
ChatID: chatID,
|
2015-06-26 06:26:24 +02:00
|
|
|
Action: action,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-06-26 08:53:20 +02:00
|
|
|
URL: u,
|
2015-06-26 06:26:24 +02:00
|
|
|
Clear: false,
|
|
|
|
}
|
|
|
|
}
|
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,
|
|
|
|
// file contains a string to a file, or a FileReader or FileBytes.
|
|
|
|
func NewWebhookWithCert(link string, file interface{}) WebhookConfig {
|
|
|
|
u, _ := url.Parse(link)
|
|
|
|
|
|
|
|
return WebhookConfig{
|
|
|
|
URL: u,
|
|
|
|
Clear: false,
|
|
|
|
Certificate: file,
|
|
|
|
}
|
|
|
|
}
|