Skip to content

I need some help sending image and receiving image, will help with some code #519

Discussion options

You must be logged in to vote

I found it

func SendImage(phone int64, url string, caption string) {
res, err := http.Get(url)

if err != nil {
	fmt.Println(err)
}
content, err := ioutil.ReadAll(res.Body)
if err != nil {
	fmt.Println(err)
}

bytes := tgbotapi.FileBytes{Name: "include/image.jpg", Bytes: content}
msg := tgbotapi.NewPhotoUpload(phone, bytes)

msg.Caption = caption
//msg.ReplyToMessageID = message.MessageID
mssg, e := bot.Send(msg)
if e != nil {
	fmt.Println(err)
}
fmt.Println(mssg)

}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by victormedranop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant