From f240e35bbeb6c45ef79f6511b5485e610a501e88 Mon Sep 17 00:00:00 2001 From: lulzette Date: Thu, 11 Jan 2024 22:20:34 +0300 Subject: [PATCH] =?UTF-8?q?=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=83?= =?UTF-8?q?=D0=BC=D0=B5=D0=B5=D1=82=20=D0=B2=D1=8B=D1=82=D0=B0=D1=81=D0=BA?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BF=D1=80=D0=B8=D0=BA=D1=80?= =?UTF-8?q?=D0=B5=D0=BF=D0=BB=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5=20=D1=84=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B8,=20=D0=BD=D0=BE=20=D1=81=D0=BA=D0=BE=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=20=D0=B2=D1=81=D0=B5=D0=B3=D0=BE=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=D0=B5=D0=B6=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vk-to-smtp.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/vk-to-smtp.go b/vk-to-smtp.go index a500e72..14398d5 100644 --- a/vk-to-smtp.go +++ b/vk-to-smtp.go @@ -24,12 +24,12 @@ import ( */ func main() { - // Get token and group id from ENV + // Init: Get token and group id from ENV token := os.Getenv("vktoken") - groupId, err := strconv.Atoi(os.Getenv("vkgroupid")) - if err != nil { - log.Fatal(err) - } + //groupId, err := strconv.Atoi(os.Getenv("vkgroupid")) + //if err != nil { + // log.Fatal(err) + //} // Init VK vk := api.NewVK(token) @@ -37,8 +37,9 @@ func main() { // Fill params for wallGet wallGetParams := params.NewWallGetBuilder() wallGetParams.Count(10) + wallGetParams.Domain("podvalsound") wallGetParams.Extended(true) - wallGetParams.OwnerID(groupId) + //wallGetParams.OwnerID(groupId) // Do WallGet posts, err := vk.WallGet(wallGetParams.Params) @@ -61,7 +62,22 @@ func main() { fmt.Println(ownerName[0].Name) fmt.Println("Text:") fmt.Println(item.Text) + fmt.Println("Attach: ") + // проходимся по аттачам если есть + if item.Attachments != nil { + //fmt.Println(item.Attachments) + for _, attach := range item.Attachments { + // если это фото - вытаскиваем урл + photosObj := attach.Photo + if photosObj.Sizes != nil { + for _, photoSizeObj := range photosObj.Sizes { + if photoSizeObj.Type == "y" { + fmt.Println(photoSizeObj.URL) + } + } + } + } + } } } - }