38 lines
984 B
Go
38 lines
984 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
neco "git.nefrace.ru/nefrace/nechotron"
|
|
"github.com/NicoNex/echotron/v3"
|
|
)
|
|
|
|
var MainState = neco.State{
|
|
Fn: func(u *neco.Update) (neco.Runnable, error) {
|
|
log.Println(u.Message.ID)
|
|
if len(u.Message.Photo) > 0 {
|
|
f, err := u.Bot.GetFile(u.Message.Photo[len(u.Message.Photo)-1].FileID)
|
|
if err != nil {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
log.Println(f.Result.FileID, f.Result.FilePath)
|
|
dl, err := u.Bot.DownloadFile(f.Result.FilePath)
|
|
if err != nil {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
// log.Println(string(dl))
|
|
_, err = u.Bot.SendPhoto(echotron.NewInputFileBytes("newfile.jpg", dl), u.ChatID(), &echotron.PhotoOptions{})
|
|
res, err := u.Bot.SendPhoto(echotron.NewInputFilePath("TEST.png"), u.ChatID(), &echotron.PhotoOptions{})
|
|
if err != nil {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
log.Println(res.Result.Photo[len(res.Result.Photo)-1].FileID)
|
|
return nil, err
|
|
}
|
|
return nil, nil
|
|
},
|
|
}
|