Skip to content

Commit a2f21c7

Browse files
committed
feat: 添加新的输入文件构造函数,支持字节和字符串类型的文件上传
1 parent 815f4bd commit a2f21c7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

telegram/message.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package telegram
22

33
import (
4+
"bytes"
45
"github.com/go-telegram/bot"
56
"github.com/go-telegram/bot/models"
67
)
@@ -21,6 +22,19 @@ func NewURLButton(text, url string) Button {
2122
}
2223
}
2324

25+
func NewBytesInputFile(name string, data []byte) models.InputFile {
26+
return &models.InputFileUpload{
27+
Filename: name,
28+
Data: bytes.NewReader(data),
29+
}
30+
}
31+
32+
func NewStringInputFile(url string) models.InputFile {
33+
return &models.InputFileString{
34+
Data: url,
35+
}
36+
}
37+
2438
type Message struct {
2539
Text string
2640
Media models.InputFile

0 commit comments

Comments
 (0)