add title
This commit is contained in:
parent
3f4be7b0ae
commit
7d8f7b58a8
4
TODO.md
4
TODO.md
@ -15,8 +15,7 @@
|
||||
* ✓ Implement atom
|
||||
* ✓ Cleanup
|
||||
* Show Feed name instead of Link
|
||||
* Change flags to os.Args[1] for config path
|
||||
* Make Rhash optional
|
||||
* ✓ Make Rhash optional
|
||||
|
||||
## Issues
|
||||
* ✓ Last record is not written fully to csv: *Fixed*. Had to Flush writer
|
||||
@ -52,6 +51,7 @@
|
||||
* Filter from app based on keyword
|
||||
* Move telegram auth token to credential file
|
||||
* Check if context is used correctly
|
||||
* Change flags to os.Args[1] for config path
|
||||
|
||||
### Log
|
||||
* Log to file
|
||||
|
@ -104,7 +104,7 @@ func ProcessFeed(feed FeedCfg, scheduler Scheduler, dbDir string, tgram telegram
|
||||
Time: time.Now(),
|
||||
FeedEntry: entry,
|
||||
}
|
||||
err := tgram.SendLink(entry.Link, feed.Channel, feed.Rhash)
|
||||
err := tgram.SendLink(entry.Link, feed.Channel, feed.Rhash, feed.Title)
|
||||
if err != nil {
|
||||
log.Error("failed to send to telegram", "feed", feed.Name, "link", entry.Link, "channel", feed.Channel, "rhash", feed.Rhash, "error", err)
|
||||
r.Status = Error
|
||||
|
@ -20,6 +20,7 @@ type FeedCfg struct {
|
||||
Cron string `yaml:"cron"`
|
||||
Proxy string `yaml:"proxy"`
|
||||
Type parser.FeedType `yaml:"type"`
|
||||
Title string `yaml:"title"`
|
||||
FTL *int `yaml:"first_time_limit"`
|
||||
FirstTimeLimit FeedLimit `yaml:"-"`
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
type TelegramSender interface {
|
||||
SendLink(link, channel, rhash string) error
|
||||
SendLink(link, channel, rhash, title string) error
|
||||
}
|
||||
|
||||
type telegramSender struct {
|
||||
@ -26,14 +26,17 @@ type telegramSender struct {
|
||||
rateLimiterPerSec *rate.Limiter
|
||||
}
|
||||
|
||||
func (ts *telegramSender) SendLink(link string, channel string, rhash string) error {
|
||||
func (ts *telegramSender) SendLink(link, channel, rhash, title string) error {
|
||||
if title == "" {
|
||||
title = "Link"
|
||||
}
|
||||
msg := struct {
|
||||
ChatID string `json:"chat_id"`
|
||||
Text string `json:"text"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
}{
|
||||
ChatID: channel,
|
||||
Text: fmt.Sprintf(`<a href="%s">➢</a> <a href="%s">Link</a>`, genIVLink(link, rhash), link),
|
||||
Text: fmt.Sprintf(`<a href="%s">➢</a> <a href="%s">%s</a>`, genIVLink(link, rhash), link, title),
|
||||
ParseMode: "HTML",
|
||||
}
|
||||
data, err := json.Marshal(msg)
|
||||
|
Loading…
Reference in New Issue
Block a user