v1.0.0 beta 15

This commit is contained in:
2026-03-12 17:45:53 +03:00
parent 3b6bb82e04
commit d6e2daec04
28 changed files with 1224 additions and 126 deletions

View File

@@ -1,5 +1,7 @@
package tgapi
// UploadPhotoP holds parameters for uploading a photo using the Uploader.
// See https://core.telegram.org/bots/api#sendphoto
type UploadPhotoP struct {
BusinessConnectionID string `json:"business_connection_id,omitempty"`
ChatID int64 `json:"chat_id"`
@@ -22,11 +24,16 @@ type UploadPhotoP struct {
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// UploadPhoto uploads a photo and sends it as a message.
// file is the photo file to upload.
// See https://core.telegram.org/bots/api#sendphoto
func (u *Uploader) UploadPhoto(params UploadPhotoP, file UploaderFile) (Message, error) {
req := NewUploaderRequestWithChatID[Message]("sendPhoto", params, params.ChatID, file)
return req.Do(u)
}
// UploadAudioP holds parameters for uploading an audio file using the Uploader.
// See https://core.telegram.org/bots/api#sendaudio
type UploadAudioP struct {
BusinessConnectionID string `json:"business_connection_id,omitempty"`
ChatID int64 `json:"chat_id"`
@@ -51,11 +58,16 @@ type UploadAudioP struct {
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// UploadAudio uploads an audio file and sends it as a message.
// files are the audio file(s) to upload (typically one file).
// See https://core.telegram.org/bots/api#sendaudio
func (u *Uploader) UploadAudio(params UploadAudioP, files ...UploaderFile) (Message, error) {
req := NewUploaderRequestWithChatID[Message]("sendAudio", params, params.ChatID, files...)
return req.Do(u)
}
// UploadDocumentP holds parameters for uploading a document using the Uploader.
// See https://core.telegram.org/bots/api#senddocument
type UploadDocumentP struct {
BusinessConnectionID string `json:"business_connection_id,omitempty"`
ChatID int64 `json:"chat_id"`
@@ -77,11 +89,16 @@ type UploadDocumentP struct {
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// UploadDocument uploads a document and sends it as a message.
// files are the document file(s) to upload (typically one file).
// See https://core.telegram.org/bots/api#senddocument
func (u *Uploader) UploadDocument(params UploadDocumentP, files ...UploaderFile) (Message, error) {
req := NewUploaderRequest[Message]("sendDocument", params, files...)
return req.Do(u)
}
// UploadVideoP holds parameters for uploading a video using the Uploader.
// See https://core.telegram.org/bots/api#sendvideo
type UploadVideoP struct {
BusinessConnectionID string `json:"business_connection_id,omitempty"`
ChatID int64 `json:"chat_id"`
@@ -110,11 +127,16 @@ type UploadVideoP struct {
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// UploadVideo uploads a video and sends it as a message.
// files are the video file(s) to upload (typically one file).
// See https://core.telegram.org/bots/api#sendvideo
func (u *Uploader) UploadVideo(params UploadVideoP, files ...UploaderFile) (Message, error) {
req := NewUploaderRequest[Message]("sendVideo", params, files...)
return req.Do(u)
}
// UploadAnimationP holds parameters for uploading an animation using the Uploader.
// See https://core.telegram.org/bots/api#sendanimation
type UploadAnimationP struct {
BusinessConnectionID string `json:"business_connection_id,omitempty"`
ChatID int64 `json:"chat_id"`
@@ -141,11 +163,16 @@ type UploadAnimationP struct {
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// UploadAnimation uploads an animation (GIF or H.264/MPEG-4 AVC video without sound) and sends it as a message.
// files are the animation file(s) to upload (typically one file).
// See https://core.telegram.org/bots/api#sendanimation
func (u *Uploader) UploadAnimation(params UploadAnimationP, files ...UploaderFile) (Message, error) {
req := NewUploaderRequest[Message]("sendAnimation", params, files...)
return req.Do(u)
}
// UploadVoiceP holds parameters for uploading a voice note using the Uploader.
// See https://core.telegram.org/bots/api#sendvoice
type UploadVoiceP struct {
BusinessConnectionID string `json:"business_connection_id,omitempty"`
ChatID int64 `json:"chat_id"`
@@ -167,11 +194,16 @@ type UploadVoiceP struct {
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// UploadVoice uploads a voice note and sends it as a message.
// files are the voice file(s) to upload (typically one file).
// See https://core.telegram.org/bots/api#sendvoice
func (u *Uploader) UploadVoice(params UploadVoiceP, files ...UploaderFile) (Message, error) {
req := NewUploaderRequest[Message]("sendVoice", params, files...)
return req.Do(u)
}
// UploadVideoNoteP holds parameters for uploading a video note (rounded video) using the Uploader.
// See https://core.telegram.org/bots/api#sendvideonote
type UploadVideoNoteP struct {
BusinessConnectionID string `json:"business_connection_id,omitempty"`
ChatID int64 `json:"chat_id"`
@@ -191,15 +223,23 @@ type UploadVideoNoteP struct {
ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"`
}
// UploadVideoNote uploads a video note (rounded video) and sends it as a message.
// files are the video note file(s) to upload (typically one file).
// See https://core.telegram.org/bots/api#sendvideonote
func (u *Uploader) UploadVideoNote(params UploadVideoNoteP, files ...UploaderFile) (Message, error) {
req := NewUploaderRequest[Message]("sendVideoNote", params, files...)
return req.Do(u)
}
// UploadChatPhotoP holds parameters for uploading a chat photo using the Uploader.
// See https://core.telegram.org/bots/api#setchatphoto
type UploadChatPhotoP struct {
ChatID int64 `json:"chat_id"`
}
// UploadChatPhoto uploads a new chat photo.
// photo is the photo file to upload.
// See https://core.telegram.org/bots/api#setchatphoto
func (u *Uploader) UploadChatPhoto(params UploadChatPhotoP, photo UploaderFile) (Message, error) {
req := NewUploaderRequest[Message]("sendChatPhoto", params, photo)
return req.Do(u)