Testing state

This commit is contained in:
nefrace 2023-01-20 16:32:21 +03:00
parent 81601daaf1
commit 24fa86f4c9
3 changed files with 49 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import (
)
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())
}

View File

@ -1,7 +1,37 @@
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
},
}

14
types.go Normal file
View File

@ -0,0 +1,14 @@
package main
import "git.nefrace.ru/nefrace/tongo"
var _ tongo.Collectable = &User{}
type User struct {
tongo.Item
Username string
FirstName string
ID int64
}
func (User) Coll() string { return "users" }