From 12cd485899f55058339faeca0f8523fbb0d2b334 Mon Sep 17 00:00:00 2001
From: Alexander Neonxp Kiryukhin
Date: Tue, 17 Dec 2024 20:51:07 +0300
Subject: Обновил публикацию в телеграм
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/app.go | 52 ++++++++++++++++++++--------------------------------
1 file changed, 20 insertions(+), 32 deletions(-)
(limited to 'app/app.go')
diff --git a/app/app.go b/app/app.go
index 756bad2..7baa73a 100644
--- a/app/app.go
+++ b/app/app.go
@@ -1,25 +1,21 @@
package app
import (
- "bytes"
"context"
+ "fmt"
"log/slog"
"os"
"strings"
- "text/template"
"time"
- "git.neonxp.ru/posse/templates"
-
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/microcosm-cc/bluemonday"
"github.com/mmcdole/gofeed"
)
type App struct {
- config *Config
- telegram *tgbotapi.BotAPI
- templates *template.Template
+ config *Config
+ telegram *tgbotapi.BotAPI
}
func New(cfg *Config) (*App, error) {
@@ -28,15 +24,9 @@ func New(cfg *Config) (*App, error) {
return nil, err
}
- tpl, err := template.ParseFS(templates.Templates, "*.gotmpl")
- if err != nil {
- return nil, err
- }
-
return &App{
- config: cfg,
- telegram: bot,
- templates: tpl,
+ config: cfg,
+ telegram: bot,
}, nil
}
@@ -85,8 +75,6 @@ func (a *App) iteration() error {
}
func (a *App) processItem(item *gofeed.Item) error {
- buf := bytes.NewBufferString("")
-
p := bluemonday.Policy{}
p.AllowStandardURLs()
p.AllowElements("b", "i", "code", "u", "strike", "pre", "br", "a")
@@ -98,26 +86,19 @@ func (a *App) processItem(item *gofeed.Item) error {
s = strings.ReplaceAll(s, "", "")
s = strings.ReplaceAll(s, "", "")
+ s = strings.ReplaceAll(s, "