telebot: move disable_content_type_detection from options to document

pull/486/head
Demian 2 years ago
parent f0291132d3
commit 6a0ece4b8f

@ -16,18 +16,19 @@ type Media interface {
// InputMedia represents a composite InputMedia struct that is
// used by Telebot in sending and editing media methods.
type InputMedia struct {
Type string `json:"type"`
Media string `json:"media"`
Caption string `json:"caption"`
Thumbnail string `json:"thumb,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
Entities Entities `json:"caption_entities,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"`
Title string `json:"title,omitempty"`
Performer string `json:"performer,omitempty"`
Streaming bool `json:"supports_streaming,omitempty"`
Type string `json:"type"`
Media string `json:"media"`
Caption string `json:"caption"`
Thumbnail string `json:"thumb,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
Entities Entities `json:"caption_entities,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"`
Title string `json:"title,omitempty"`
Performer string `json:"performer,omitempty"`
Streaming bool `json:"supports_streaming,omitempty"`
DisableTypeDetection bool `json:"disable_content_type_detection,omitempty"`
}
// Inputtable is a generic type for all kinds of media you
@ -143,10 +144,11 @@ type Document struct {
File
// (Optional)
Thumbnail *Photo `json:"thumb,omitempty"`
Caption string `json:"caption,omitempty"`
MIME string `json:"mime_type"`
FileName string `json:"file_name,omitempty"`
Thumbnail *Photo `json:"thumb,omitempty"`
Caption string `json:"caption,omitempty"`
MIME string `json:"mime_type"`
FileName string `json:"file_name,omitempty"`
DisableTypeDetection bool `json:"disable_content_type_detection,omitempty"`
}
func (d *Document) MediaType() string {
@ -160,8 +162,9 @@ func (d *Document) MediaFile() *File {
func (d *Document) InputMedia() InputMedia {
return InputMedia{
Type: d.MediaType(),
Caption: d.Caption,
Type: d.MediaType(),
Caption: d.Caption,
DisableTypeDetection: d.DisableTypeDetection,
}
}

@ -69,9 +69,6 @@ type SendOptions struct {
// Entities is a list of special entities that appear in message text, which can be specified instead of parse_mode.
Entities Entities
// DisableContentDetection abilities to disable server-side file content type detection.
DisableContentDetection bool
// AllowWithoutReply allows sending messages not a as reply if the replied-to message has already been deleted.
AllowWithoutReply bool
}

@ -90,6 +90,9 @@ func (d *Document) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error
if d.FileSize != 0 {
params["file_size"] = strconv.Itoa(d.FileSize)
}
if d.DisableTypeDetection {
params["disable_content_type_detection"] = "true"
}
msg, err := b.sendMedia(d, params, thumbnailToFilemap(d.Thumbnail))
if err != nil {

@ -209,10 +209,6 @@ func (b *Bot) embedSendOptions(params map[string]string, opt *SendOptions) {
}
}
if opt.DisableContentDetection {
params["disable_content_type_detection"] = "true"
}
if opt.AllowWithoutReply {
params["allow_sending_without_reply"] = "true"
}

Loading…
Cancel
Save