From 654248a36f3fbbb13fdab857d5731a24ab04601d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Sun, 1 Feb 2026 12:25:35 +0500 Subject: [PATCH] Remove Facebook functionality from sender --- internal/models/config.go | 52 --------------------------------------- internal/send/send.go | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 52 deletions(-) create mode 100644 internal/send/send.go diff --git a/internal/models/config.go b/internal/models/config.go index c3688d5..07d6e81 100644 --- a/internal/models/config.go +++ b/internal/models/config.go @@ -1,12 +1,5 @@ package models -import ( - "log" - - "github.com/SevereCloud/vksdk/v2/api" - tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" -) - type Config struct { Dbpath string `yaml:"dbpath"` Telegram struct { @@ -20,49 +13,4 @@ type Config struct { Token string `yaml:"token"` OwnerId int64 `yaml:"ownerid"` } `yaml:"vk"` - Facebook struct { - Send bool `yaml:"send"` - Token string `yaml:"token"` - } `yaml:"facebook"` -} - -func (config Config) RunSend(senditems SendItems) { - for _, v := range senditems.ItemList { - if config.Telegram.Send { - log.Println("Send to telegram") - bot, err := tgbotapi.NewBotAPI(config.Telegram.Token) - if err != nil { - log.Panic(err) - } - bot.Debug = config.Telegram.SendDebug - - // s := "" + string(v.Title) + "\n" + html.UnescapeString(string(v.Description)) + - // "\nhttps://t.me/iv?url=" + v.Link + "&rhash=da76512d0ff2a2" + - // "\n\nСсылка на пост: " + v.Link - msg := tgbotapi.NewMessage(config.Telegram.ChatId, v.Link) - msg.ParseMode = "Html" - _, err = bot.Send(msg) - if err != nil { - log.Panic(err) - - } - log.Println("Sended to telegram") - } - if config.VK.Send { - log.Println("Send to VK") - vk := api.NewVK(config.VK.Token) - _, err := vk.WallPost(api.Params{ - "owner_id": config.VK.OwnerId, - "attachments": v.Link, - }) - if err != nil { - log.Fatal(err) - } - log.Println("Sended to VK") - } - if config.Facebook.Send { - log.Println("Send to Facebook") - log.Println("Sending to facebook is not implemented yet") - } - } } diff --git a/internal/send/send.go b/internal/send/send.go new file mode 100644 index 0000000..0ee2850 --- /dev/null +++ b/internal/send/send.go @@ -0,0 +1,48 @@ +package send + +import ( + "log" + "ssender/internal/models" + + "github.com/SevereCloud/vksdk/v2/api" + tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" +) + +func RunSend(senditems *models.SendItems, config models.Config) error { + for _, v := range senditems.ItemList { + if config.Telegram.Send { + log.Println("Send to telegram") + bot, err := tgbotapi.NewBotAPI(config.Telegram.Token) + if err != nil { + return err + } + bot.Debug = config.Telegram.SendDebug + + // s := "" + string(v.Title) + "\n" + html.UnescapeString(string(v.Description)) + + // "\nhttps://t.me/iv?url=" + v.Link + "&rhash=da76512d0ff2a2" + + // "\n\nСсылка на пост: " + v.Link + msg := tgbotapi.NewMessage(config.Telegram.ChatId, v.Link) + msg.ParseMode = "Html" + _, err = bot.Send(msg) + if err != nil { + return err + + } + log.Println("Sended to telegram") + } + if config.VK.Send { + log.Println("Send to VK") + vk := api.NewVK(config.VK.Token) + _, err := vk.WallPost(api.Params{ + "owner_id": config.VK.OwnerId, + "attachments": v.Link, + }) + if err != nil { + return err + } + log.Println("Sended to VK") + } + + } + return nil +}