Testing state
This commit is contained in:
parent
81601daaf1
commit
24fa86f4c9
3
main.go
3
main.go
|
@ -7,6 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
neko := nechotron.NewTron("1698825178:AAHy4Er7z768CmYy9M5drJOMQO2S-QnwdTI", nil)
|
neko := nechotron.NewTron("1698825178:AAHy4Er7z768CmYy9M5drJOMQO2S-QnwdTI", &MainState)
|
||||||
|
neko.ApiServer = "http://192.168.100.15:7373"
|
||||||
log.Fatal(neko.DispatchPoll())
|
log.Fatal(neko.DispatchPoll())
|
||||||
}
|
}
|
||||||
|
|
34
states.go
34
states.go
|
@ -1,7 +1,37 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import neco "git.nefrace.ru/nefrace/nechotron"
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
func MainState(u *neco.Update) (neco.Runnable, error) {
|
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
|
return nil, nil
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue