fix all golint errors, add info about audio uploads
This commit is contained in:
parent
5b2104f974
commit
a17651c8fe
5 changed files with 290 additions and 258 deletions
162
helpers.go
162
helpers.go
|
@ -4,195 +4,195 @@ import (
|
|||
"net/url"
|
||||
)
|
||||
|
||||
// Creates a new Message.
|
||||
// Perhaps set a ChatAction of CHAT_TYPING while processing.
|
||||
// NewMessage creates a new Message.
|
||||
// Perhaps set a ChatAction of ChatTyping while processing.
|
||||
//
|
||||
// chatId is where to send it, text is the message text.
|
||||
func NewMessage(chatId int, text string) MessageConfig {
|
||||
// chatID is where to send it, text is the message text.
|
||||
func NewMessage(chatID int, text string) MessageConfig {
|
||||
return MessageConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
Text: text,
|
||||
DisableWebPagePreview: false,
|
||||
ReplyToMessageId: 0,
|
||||
ReplyToMessageID: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new forward.
|
||||
// NewForward creates a new forward.
|
||||
//
|
||||
// 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 {
|
||||
// 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 {
|
||||
return ForwardConfig{
|
||||
ChatId: chatId,
|
||||
FromChatId: fromChatId,
|
||||
MessageId: messageId,
|
||||
ChatID: chatID,
|
||||
FromChatID: fromChatID,
|
||||
MessageID: messageID,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new photo uploader.
|
||||
// NewPhotoUpload creates a new photo uploader.
|
||||
// This requires a file on the local filesystem to upload to Telegram.
|
||||
// Perhaps set a ChatAction of CHAT_UPLOAD_PHOTO while processing.
|
||||
// Perhaps set a ChatAction of ChatUploadPhoto while processing.
|
||||
//
|
||||
// chatId is where to send it, filename is the path to the file.
|
||||
func NewPhotoUpload(chatId int, filename string) PhotoConfig {
|
||||
// chatID is where to send it, filename is the path to the file.
|
||||
func NewPhotoUpload(chatID int, filename string) PhotoConfig {
|
||||
return PhotoConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingPhoto: false,
|
||||
FilePath: filename,
|
||||
}
|
||||
}
|
||||
|
||||
// Shares an existing photo.
|
||||
// NewPhotoShare shares an existing photo.
|
||||
// You may use this to reshare an existing photo without reuploading it.
|
||||
//
|
||||
// chatId is where to send it, fileId is the Id of the file already uploaded.
|
||||
func NewPhotoShare(chatId int, fileId string) PhotoConfig {
|
||||
// chatID is where to send it, fileID is the ID of the file already uploaded.
|
||||
func NewPhotoShare(chatID int, fileID string) PhotoConfig {
|
||||
return PhotoConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingPhoto: true,
|
||||
FileId: fileId,
|
||||
FileID: fileID,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new audio uploader.
|
||||
// NewAudioUpload creates a new audio uploader.
|
||||
// This requires a file on the local filesystem to upload to Telegram.
|
||||
// Perhaps set a ChatAction of CHAT_RECORD_AUDIO or CHAT_UPLOAD_AUDIO while processing.
|
||||
// Perhaps set a ChatAction of ChatRecordAudio or ChatUploadAudio while processing.
|
||||
//
|
||||
// chatId is where to send it, filename is the path to the file.
|
||||
func NewAudioUpload(chatId int, filename string) AudioConfig {
|
||||
// chatID is where to send it, filename is the path to the file.
|
||||
func NewAudioUpload(chatID int, filename string) AudioConfig {
|
||||
return AudioConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingAudio: false,
|
||||
FilePath: filename,
|
||||
}
|
||||
}
|
||||
|
||||
// Shares an existing audio file.
|
||||
// NewAudioShare shares an existing audio file.
|
||||
// You may use this to reshare an existing audio file without reuploading it.
|
||||
//
|
||||
// chatId is where to send it, fileId is the Id of the audio already uploaded.
|
||||
func NewAudioShare(chatId int, fileId string) AudioConfig {
|
||||
// chatID is where to send it, fileID is the ID of the audio already uploaded.
|
||||
func NewAudioShare(chatID int, fileID string) AudioConfig {
|
||||
return AudioConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingAudio: true,
|
||||
FileId: fileId,
|
||||
FileID: fileID,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new document uploader.
|
||||
// NewDocumentUpload creates a new document uploader.
|
||||
// This requires a file on the local filesystem to upload to Telegram.
|
||||
// Perhaps set a ChatAction of CHAT_UPLOAD_DOCUMENT while processing.
|
||||
// Perhaps set a ChatAction of ChatUploadDocument while processing.
|
||||
//
|
||||
// chatId is where to send it, filename is the path to the file.
|
||||
func NewDocumentUpload(chatId int, filename string) DocumentConfig {
|
||||
// chatID is where to send it, filename is the path to the file.
|
||||
func NewDocumentUpload(chatID int, filename string) DocumentConfig {
|
||||
return DocumentConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingDocument: false,
|
||||
FilePath: filename,
|
||||
}
|
||||
}
|
||||
|
||||
// Shares an existing document.
|
||||
// NewDocumentShare shares an existing document.
|
||||
// You may use this to reshare an existing document without reuploading it.
|
||||
//
|
||||
// chatId is where to send it, fileId is the Id of the document already uploaded.
|
||||
func NewDocumentShare(chatId int, fileId string) DocumentConfig {
|
||||
// chatID is where to send it, fileID is the ID of the document already uploaded.
|
||||
func NewDocumentShare(chatID int, fileID string) DocumentConfig {
|
||||
return DocumentConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingDocument: true,
|
||||
FileId: fileId,
|
||||
FileID: fileID,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new sticker uploader.
|
||||
// NewStickerUpload creates a new sticker uploader.
|
||||
// This requires a file on the local filesystem to upload to Telegram.
|
||||
//
|
||||
// chatId is where to send it, filename is the path to the file.
|
||||
func NewStickerUpload(chatId int, filename string) StickerConfig {
|
||||
// chatID is where to send it, filename is the path to the file.
|
||||
func NewStickerUpload(chatID int, filename string) StickerConfig {
|
||||
return StickerConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingSticker: false,
|
||||
FilePath: filename,
|
||||
}
|
||||
}
|
||||
|
||||
// Shares an existing sticker.
|
||||
// NewStickerShare shares an existing sticker.
|
||||
// You may use this to reshare an existing sticker without reuploading it.
|
||||
//
|
||||
// chatId is where to send it, fileId is the Id of the sticker already uploaded.
|
||||
func NewStickerShare(chatId int, fileId string) StickerConfig {
|
||||
// chatID is where to send it, fileID is the ID of the sticker already uploaded.
|
||||
func NewStickerShare(chatID int, fileID string) StickerConfig {
|
||||
return StickerConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingSticker: true,
|
||||
FileId: fileId,
|
||||
FileID: fileID,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new video uploader.
|
||||
// NewVideoUpload creates a new video uploader.
|
||||
// This requires a file on the local filesystem to upload to Telegram.
|
||||
// Perhaps set a ChatAction of CHAT_RECORD_VIDEO or CHAT_UPLOAD_VIDEO while processing.
|
||||
// Perhaps set a ChatAction of ChatRecordVideo or ChatUploadVideo while processing.
|
||||
//
|
||||
// chatId is where to send it, filename is the path to the file.
|
||||
func NewVideoUpload(chatId int, filename string) VideoConfig {
|
||||
// chatID is where to send it, filename is the path to the file.
|
||||
func NewVideoUpload(chatID int, filename string) VideoConfig {
|
||||
return VideoConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingVideo: false,
|
||||
FilePath: filename,
|
||||
}
|
||||
}
|
||||
|
||||
// Shares an existing video.
|
||||
// NewVideoShare shares an existing video.
|
||||
// You may use this to reshare an existing video without reuploading it.
|
||||
//
|
||||
// chatId is where to send it, fileId is the Id of the video already uploaded.
|
||||
func NewVideoShare(chatId int, fileId string) VideoConfig {
|
||||
// chatID is where to send it, fileID is the ID of the video already uploaded.
|
||||
func NewVideoShare(chatID int, fileID string) VideoConfig {
|
||||
return VideoConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
UseExistingVideo: true,
|
||||
FileId: fileId,
|
||||
FileID: fileID,
|
||||
}
|
||||
}
|
||||
|
||||
// Shares your location.
|
||||
// Perhaps set a ChatAction of CHAT_FIND_LOCATION while processing.
|
||||
// NewLocation shares your location.
|
||||
// Perhaps set a ChatAction of ChatFindLocation while processing.
|
||||
//
|
||||
// chatId is where to send it, latitude and longitude are coordinates.
|
||||
func NewLocation(chatId int, latitude float64, longitude float64) LocationConfig {
|
||||
// chatID is where to send it, latitude and longitude are coordinates.
|
||||
func NewLocation(chatID int, latitude float64, longitude float64) LocationConfig {
|
||||
return LocationConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
Latitude: latitude,
|
||||
Longitude: longitude,
|
||||
ReplyToMessageId: 0,
|
||||
ReplyToMessageID: 0,
|
||||
ReplyMarkup: nil,
|
||||
}
|
||||
}
|
||||
|
||||
// Sets a chat action.
|
||||
// NewChatAction sets a chat action.
|
||||
// Actions last for 5 seconds, or until your next action.
|
||||
//
|
||||
// chatId is where to send it, action should be set via CHAT constants.
|
||||
func NewChatAction(chatId int, action string) ChatActionConfig {
|
||||
// chatID is where to send it, action should be set via CHAT constants.
|
||||
func NewChatAction(chatID int, action string) ChatActionConfig {
|
||||
return ChatActionConfig{
|
||||
ChatId: chatId,
|
||||
ChatID: chatID,
|
||||
Action: action,
|
||||
}
|
||||
}
|
||||
|
||||
// Gets user profile photos.
|
||||
// NewUserProfilePhotos gets user profile photos.
|
||||
//
|
||||
// userId is the Id of the user you wish to get profile photos from.
|
||||
func NewUserProfilePhotos(userId int) UserProfilePhotosConfig {
|
||||
// userID is the ID of the user you wish to get profile photos from.
|
||||
func NewUserProfilePhotos(userID int) UserProfilePhotosConfig {
|
||||
return UserProfilePhotosConfig{
|
||||
UserId: userId,
|
||||
UserID: userID,
|
||||
Offset: 0,
|
||||
Limit: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// Gets updates since the last Offset.
|
||||
// NewUpdate gets updates since the last Offset.
|
||||
//
|
||||
// offset is the last Update Id to include.
|
||||
// You likely want to set this to the last Update Id plus 1.
|
||||
// offset is the last Update ID to include.
|
||||
// You likely want to set this to the last Update ID plus 1.
|
||||
func NewUpdate(offset int) UpdateConfig {
|
||||
return UpdateConfig{
|
||||
Offset: offset,
|
||||
|
@ -201,14 +201,14 @@ func NewUpdate(offset int) UpdateConfig {
|
|||
}
|
||||
}
|
||||
|
||||
// Creates a new webhook.
|
||||
// NewWebhook creates a new webhook.
|
||||
//
|
||||
// link is the url parsable link you wish to get the updates.
|
||||
func NewWebhook(link string) WebhookConfig {
|
||||
u, _ := url.Parse(link)
|
||||
|
||||
return WebhookConfig{
|
||||
Url: u,
|
||||
URL: u,
|
||||
Clear: false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue